AWS CLI

インストール

Arch Linux

# pacman -S aws-cli

Ubuntu

# apt install awscli

Raspbian

# pip3 install awscli --upgrade

$ aws --version
aws-cli/1.20.34 Python/3.9.6 Linux/5.13.13-arch1-1 botocore/1.21.34
EC2

$ aws ec2 describe-instances

S3

$ aws s3 ls s3://s1.example.com

$ aws s3 cp index.html s3://s1.example.com/

$ aws s3 rm s3://s1.ekzemplaro.org/test01.txt

$ aws s3 sync . s3://s1.ekzemplaro.org --delete

$ aws s3 ls

$ aws s3api list-buckets

IAM

$ aws iam list-access-keys

$ aws iam list-users

$ aws iam list-roles

DynamoDB

$ aws dynamodb list-tables

$ aws dynamodb delete-table --table-name table_aa

$ aws dynamodb list-tables --endpoint-url http://localhost:8000

$ aws dynamodb describe-table --table-name table_aa

$ aws dynamodb scan --table-name cities --endpoint-url http://localhost:8000

$ aws dynamodb get-item --table-name cities --key '{"key": {"S": "t0921"}}' --endpoint-url http://localhost:8000

$ aws dynamodb scan --table-name cities --endpoint-url http://localhost:8000 --query 'Count'

$ aws dynamodb scan --table-name tbl_raspberry --select "COUNT"
$ aws dynamodb query --table-name tbl_raspberry --key-conditions '{"id_raspberry": { "AttributeValueList": [ { "S" : "ras0002" } ] , "ComparisonOperator": "EQ" } }'

$ aws dynamodb delete-item --table-name cities --key '{"id_city": {"S": "t3011"}}'

Lambda

$ aws lambda list-functions

$ aws lambda list-functions | grep FunctionName

$ aws lambda delete-function --function-name func01

API Gateway

$ aws apigateway get-rest-apis

$ aws apigateway get-rest-api --rest-api-id 1234123412

$ aws apigateway delete-rest-api --rest-api-id 1234123412

Cloud Watch

$ aws cloudwatch list-metrics --namespace "AWS/ApiGateway"

$ aws logs describe-log-groups | grep logGroupName

$ aws logs delete-log-group --log-group-name "/aws/lambda/example01"

IOT

$ aws iot create-thing --thing-name sunflower

$ aws iot list-things

$ aws iot describe-thing --thing-name sunflower

$ aws iot delete-thing --thing-name sunflower

$ aws iot list-topic-rules

$ aws iot get-topic-rule --rule-name rule001

$ aws iot describe-endpoint

RDS

$ aws rds describe-db-instances

$ aws rds describe-db-instances | grep DBInstanceIdentifier

$ aws rds delete-db-instance --db-instance-identifier sample-test --skip-final-snapshot

SNS

$ aws sns list-topics

$ aws sns create-topic --name example01

$ aws sns delete-topic --topic-arn "arn:aws:sns:ap-northeast-1:111111159025:example01"

$ aws sns subscribe --topic-arn "arn:aws:sns:ap-northeast-1:111111159025:example01" --protocol email --notification-endpoint "aaa@example.com"

$ aws sns list-subscriptions

$ aws sns unsubscribe --subscription-arn arn:aws:sns:ap-northeast-1:111111159025:example01:1328f057-de93-4c15-512e-8bb2268db8c4

Route53

$ aws route53 list-hosted-zones

$ aws route53 list-resource-record-sets --hosted-zone-id /hostedzone/Z005****


credentials.csv をダウンロードしたら

.aws/credentials に値を入れる

[default]
aws_access_key_id = AKIAJ*******
aws_secret_access_key = HilYZJZ3McInc4D**********
.aws/config

[default]
output = json
region = ap-northeast-1

AWS CLI バージョン 2 のインストール

Arch Linux

yay aws-cli-v2
cd /usr/share/aws-cli/v2/
sudo rm current
sudo ln -s /usr/share/aws-cli/v2/2.0.19 current

Return

Feb/09/2022 AM 08:15