AWS CLI

2016-07-24  本文已影响995人  abrocod

CLI Configuration

Quick configuration

$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json

To update any of your settings, simply run aws configure
again and enter new values as appropriate.

# can specify a particular profile name:
$ aws configure --profile profilename

The AWS CLI looks for credentials and configuration settings in the following order:

Configure by using credential and config files

#~/.aws/credentials
[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

[user2]
aws_access_key_id=AKIAI44QH8DHBEXAMPLE
aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
#~/.aws/config
[default]
region=us-west-2
output=json

[profile user2]
region=us-east-1
output=text

$ aws ec2 describe-instances --profile user2

$ export AWS_DEFAULT_PROFILE=user2

aws ec2 describe-instances --profile jinchao-full-access --output table --region us-west-2


CLI basic command

General

aws configure
aws configure --profile profile-name

S3:

aws s3 ls

EC2

aws ec2 describe-instances --instance-ids <instance-id>

aws ec2 start-instances --instance-ids <instance-id>
aws ec2 stop-instances --instance-ids <instance-id>
aws ec2 reboot-instances --instance-ids <instance-id>
aws ec2 terminate-instances --instance-ids <instance-id>

aws ec2 get-console-output --instance-id <instance-id>

aws ec2 describe-security-groups --group-names <group-name>

IAM

VPC

aws ec2 describe-vpcs
aws ec2 describe-subnets --filters Name=vpc-id,Values=<vpc-id>
aws ec2 describe-route-tables --filters Name=vpc-id,Values=<vpc-id>
aws ec2 describe-network-acls --filters Name=vpc-id,Values=<vpc-id>
aws ec2 describe-vpc-peering-connections

Lambda

上一篇 下一篇

猜你喜欢

热点阅读