# file: docs/cheat-sheets/aws/aws-cli-cheat-sheet.sh
# aws ec2
aws ec2 describe-instances --profile prd
aws ec2 describe-instances --region us-east-1 --output=text --profile rnd | grep -i INSTANCES
aws ec2 describe-dhcp-options --region us-east-1 --output=text --profile rnd
aws ec2 describe-internet-gateways --output=text --profile prd
aws ec2 monitor-instances --instance-ids i-033b311170f00db51 --region us-east-1 --output=text --profile rnd
aws ec2 describe-vpcs --profile prd
# aws elb
aws elb describe-load-balancers --profile prd | grep -i listener
# aws route53
aws route53 list-resource-record-sets --hosted-zone-id "$hosted_zone_id" --profile prd
# test the dns answer in the aws route53
for record_type in $record_types ; do \
aws route53 test-dns-answer \
--hosted-zone-id "$hosted_zone_id" \
--record-name "$record_name" \
--record-type "$record_type" \
--resolver-ip "$resolver_ip" \
--profile "prd" ;
done
# aws iam
aws iam list-server-certificates --profile prd
aws iam upload-server-certificate \
--server-certificate-name "$server_certificate_name" \
--certificate-body file://"$certificate_body_file" \ # BEGIN CERTIFICATE -> END CERTIFICATE
--certificate-chain file://"$cerftificate_chain_file" \
--private-key file://"$private_key_file" \ # rsa start -> rsa stop
--profile prd
# install aws cli via python pip package manager
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
sudo python get-pip.py
sudo pip install --upgrade awscli
sudo apt-get install python-pip
sudo pip install awscli
# or via os package manager
# install the aws-cli package
sudo apt-get install -y awscli
sudo yum install -y awscli
# aws cloudformation
aws cloudformation describe-stacks --output=table --profile prd
# in aws admin console :
# Services => iam => users => <<your_username>> => Security Credentials => Access Keys
# configure the aws cli
cat << "EOF" > ~/.aws/credentials
[dev]
aws_access_key_id = <<your_aws_access_key_id_in_the_dev_environment>>
aws_secret_access_key = <<your_aws_secret_access_key_in_dev_env>>
[prd]
aws_access_key_id = <<your_aws_access_key_id_in_the_prd_environment>>
aws_secret_access_key = <<your_aws_secret_access_key_in_prd_env>>
[default]
aws_access_key_id = <<your_aws_access_key_id_in_the_dev_environment>>
aws_secret_access_key = <<your_aws_secret_access_key_in_dev_env>>
EOF
# set-up the ~/.boto confs
cat << "EOF" > ~/.boto
[profile dev]
aws_access_key_id = <<your_aws_access_key_id_in_the_dev_environment>>
aws_secret_access_key = <<your_aws_secret_access_key_in_dev_env>>
[profile prd]
aws_access_key_id = <<your_aws_access_key_id_in_the_prd_environment>>
aws_secret_access_key = <<your_aws_secret_access_key_in_prd_env>>
[profile default]
aws_access_key_id = <<your_aws_access_key_id>>
aws_secret_access_key = <<your_aws_secret_access_key_in_dev_env>>
EOF
# how-to configure your default regions and formats
# src: http://docs.aws.amazon.com/cli/latest/topic/config-vars.html
cat << "EOF" > ~/.aws/config
[profile rnd]
output = text
region = us-east-1
[profile prd]
output = text
region = us-east-1
[default]
output = text
region = Global
EOF
# eof file: docs/cheat-sheets/aws/aws-cli-cheat-sheet.sh
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!