4.13 The AWS Command Line & EC2
Command Line (CLI) is pre-installed on Amazon Linux AMI. Using SSH to login to your console:
AWS CLI
Format: aws + [service_name] + [operation_name]
aws configure: configure your CLI based on your user information.
aws s3 ls: list all of your S3 buckets.
aws s3 help: to get help about S3 commands.
cd ~: go to home directory.
cd .aws: in this hidden directory, there are two files, "config" and "credentials". Note that your aws_access_key_id and aws_secret_access_key are in the "credentials" file, so don't upload this file to your Github. If you loss your these two keys, what you need to immediately do is delete the user and create a new one or generate new keys. Using Roles instead of User's keys can help your to secure your information (see next lab).
aws ec2 describe-instances: this command will describe all your running EC2 instances, and your terminated instances. This description is JSON format. You can find the "InstanceId" of your instance in the description.
aws ec2 terminate-instances --instance-ids [InstanceId]: this command will terminate your EC2 instance, i.e. self-destruct the EC2 instance.
Last updated
Was this helpful?