从CLI获取帐户信息

获取AWS的AWS账户ID
.

0

linux命令:aws sts get-caller-identity --output text | awk {'print $1'} $1'} {'print awk | text --output get-caller-identity sts aws aws sts get-caller-identity --output text | awk {'print $1'}rootopen.com
linux命令:aws sts get-caller-identity --output text | awk {'print $1'} $1'} {'print awk | text --output get-caller-identity sts aws aws sts get-caller-identity --output text | awk {'print $1'}rootopen.com
yxza 2018-01-28 16:48:48
输出

评论

相关推荐

使用AWS CLI工具生成列表实例,然后将它们传递给JQ以仅显示其启动时间和实例ID。 最后使用排序将它们按运行时顺序排出。 查找几个月前发布并已忘记的所有这些实例。

linux命令:aws ec2 describe-instances | jq '.["Reservations"]|.[]|.Instances|.[]|.LaunchTime + " " + .InstanceId' | sort -n -n sort | .InstanceId' + " " + '.["Reservations"]|.[]|.Instances|.[]|.LaunchTime jq | describe-instances ec2 aws aws ec2 describe-instances | jq '.["Reservations"]|.[]|.Instances|.[]|.LaunchTime + " " + .InstanceId' | sort -nrootopen.com
linux命令:aws ec2 describe-instances | jq '.["Reservations"]|.[]|.Instances|.[]|.LaunchTime + " " + .InstanceId' | sort -n -n sort | .InstanceId' + " " + '.["Reservations"]|.[]|.Instances|.[]|.LaunchTime jq | describe-instances ec2 aws aws ec2 describe-instances | jq '.["Reservations"]|.[]|.Instances|.[]|.LaunchTime + " " + .InstanceId' | sort -nrootopen.com
.

你可以在aws cli中本地执行过滤,而不使用jq(尽管jq太棒了!)

linux命令:aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,LaunchTime]' --output text | sort -n -k 2 2 -k -n sort | text --output 'Reservations[*].Instances[*].[InstanceId,LaunchTime]' --query describe-instances ec2 aws aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,LaunchTime]' --output text | sort -n -k 2rootopen.com
linux命令:aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,LaunchTime]' --output text | sort -n -k 2 2 -k -n sort | text --output 'Reservations[*].Instances[*].[InstanceId,LaunchTime]' --query describe-instances ec2 aws aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,LaunchTime]' --output text | sort -n -k 2rootopen.com
.

使用基于python的AWS CLI(https://aws.amazon.com/cli/)和JSON查询工具JQ(https://stedolan.github.io/jq/)

linux命令:aws ec2 describe-instances --query "Reservations[*].Instances[*]" | jq '.[]|.[]|(if .Tags then (.Tags[]|select(.Key == "Name").Value) else empty end)+", " +.InstanceId' +.InstanceId' " end)+", empty else "Name").Value) == (.Tags[]|select(.Key then .Tags '.[]|.[]|(if jq | "Reservations[*].Instances[*]" --query describe-instances ec2 aws aws ec2 describe-instances --query "Reservations[*].Instances[*]" | jq '.[]|.[]|(if .Tags then (.Tags[]|select(.Key == "Name").Value) else empty end)+", " +.InstanceId'rootopen.com
linux命令:aws ec2 describe-instances --query "Reservations[*].Instances[*]" | jq '.[]|.[]|(if .Tags then (.Tags[]|select(.Key == "Name").Value) else empty end)+", " +.InstanceId' +.InstanceId' " end)+", empty else "Name").Value) == (.Tags[]|select(.Key then .Tags '.[]|.[]|(if jq | "Reservations[*].Instances[*]" --query describe-instances ec2 aws aws ec2 describe-instances --query "Reservations[*].Instances[*]" | jq '.[]|.[]|(if .Tags then (.Tags[]|select(.Key == "Name").Value) else empty end)+", " +.InstanceId'rootopen.com
.

使用基于python的AWS CLI(https://aws.amazon.com/cli/)和JSON查询工具JQ(https://stedolan.github.io/jq/)

linux命令:aws ec2 describe-snapshots --filter 'Name=volume-id,Values=vol-abcd1234' | jq '.[]|max_by(.StartTime)|.SnapshotId' '.[]|max_by(.StartTime)|.SnapshotId' jq | 'Name=volume-id,Values=vol-abcd1234' --filter describe-snapshots ec2 aws aws ec2 describe-snapshots --filter 'Name=volume-id,Values=vol-abcd1234' | jq '.[]|max_by(.StartTime)|.SnapshotId'rootopen.com
linux命令:aws ec2 describe-snapshots --filter 'Name=volume-id,Values=vol-abcd1234' | jq '.[]|max_by(.StartTime)|.SnapshotId' '.[]|max_by(.StartTime)|.SnapshotId' jq | 'Name=volume-id,Values=vol-abcd1234' --filter describe-snapshots ec2 aws aws ec2 describe-snapshots --filter 'Name=volume-id,Values=vol-abcd1234' | jq '.[]|max_by(.StartTime)|.SnapshotId'rootopen.com
.

查找CF域的id可能很痛苦,不要再用这个技巧了。

linux命令:aws cloudfront list-distributions | jq -r '.DistributionList | .Items | .[] | .Id + " " + .Aliases.Items[]' .Aliases.Items[]' + " " + .Id | .[] | .Items | '.DistributionList -r jq | list-distributions cloudfront aws aws cloudfront list-distributions | jq -r '.DistributionList | .Items | .[] | .Id + " " + .Aliases.Items[]'rootopen.com
linux命令:aws cloudfront list-distributions | jq -r '.DistributionList | .Items | .[] | .Id + " " + .Aliases.Items[]' .Aliases.Items[]' + " " + .Id | .[] | .Items | '.DistributionList -r jq | list-distributions cloudfront aws aws cloudfront list-distributions | jq -r '.DistributionList | .Items | .[] | .Id + " " + .Aliases.Items[]'rootopen.com
.

跨区域Amazon EC2 AMI副本

linux命令:aws ec2 describe-regions --output text | cut -f 3 | xargs -I {} aws ec2 copy-image --source-region eu-west-1 --region {} --source-image-id ami-xxxxx --name "MyAmi" "MyAmi" --name ami-xxxxx --source-image-id {} --region eu-west-1 --source-region copy-image ec2 aws {} -I xargs | 3 -f cut | text --output describe-regions ec2 aws aws ec2 describe-regions --output text | cut -f 3 | xargs -I {} aws ec2 copy-image --source-region eu-west-1 --region {} --source-image-id ami-xxxxx --name "MyAmi"rootopen.com
linux命令:aws ec2 describe-regions --output text | cut -f 3 | xargs -I {} aws ec2 copy-image --source-region eu-west-1 --region {} --source-image-id ami-xxxxx --name "MyAmi" "MyAmi" --name ami-xxxxx --source-image-id {} --region eu-west-1 --source-region copy-image ec2 aws {} -I xargs | 3 -f cut | text --output describe-regions ec2 aws aws ec2 describe-regions --output text | cut -f 3 | xargs -I {} aws ec2 copy-image --source-region eu-west-1 --region {} --source-image-id ami-xxxxx --name "MyAmi"rootopen.com
.
共收录0条命令行
这里是记录和分享命令行的地方, 所有命令行都可以进行评论、提交替代方案.

推荐
    热门命令