Skip to content

Latest commit

 

History

History
93 lines (37 loc) · 2.15 KB

AWS-Commands.md

File metadata and controls

93 lines (37 loc) · 2.15 KB

To view User-Data & Instance Meta-Data:

curl http://169.254.169.254/latest/user-data/

curl http://169.254.169.254/latest/meta-data/

To see the instance region:

  • curl http://169.254.169.254/latest/dynamic/instance-identity/document|grep region|awk -F\" '{print $4}'
    (or)
  • curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | python -c "import json,sys; print json.loads(sys.stdin.read())['region']"
    (or)
  • curl -s 169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/.$//'

All the above commands must be executed on the shell of the target instance

To view ec2 instances in the desired region:

  • aws ec2 describe-instances --region us-east-1

To start an ec2 instances with instance id:

  • aws ec2 start-instances --instance-ids i-04b97d9163360d14f

To start an ec2 instances with instance id:

  • aws ec2 stop-instances --instance-ids i-04b97d9163360d14f

To start an ec2 instances with instance id:

  • aws ec2 terminate-instances --instance-ids i-04b97d9163360d14f

To view S3 buckets :

  • aws s3 ls

To view contents of desired bucket in S3 :

  • aws s3 ls s3://okoye3

To sync contents of local directory to desired bucket in S3 :

  • aws s3 sync s3://okoye3 .

To sync contents of local directory to desired bucket in S3 :

  • aws s3 sync . s3://okoye3

To delete the bucket:

if bucket is empty : aws s3 rb s3://name of the bucket

if bucket has contents : aws s3 rb s3://name of the bucket --force

To know the IAM users of the account:

For reference: docs.aws.amazon.com