terraform.aws-baseline-infra/modules/util/resource-list/list-tgw.sh

7 lines
530 B
Bash
Raw Normal View History

2022-12-08 10:42:05 +08:00
#!/bin/bash
eval "$(jq -r '@sh "asrolearn=\(.asrolearn)"')"
eval "$(aws sts assume-role --role-arn $asrolearn --role-session-name awscli | jq -cr '"export AWS_ACCESS_KEY_ID=" + .Credentials.AccessKeyId, "export AWS_SECRET_ACCESS_KEY=" + .Credentials.SecretAccessKey, "export AWS_SESSION_TOKEN=" + .Credentials.SessionToken')"
2022-12-08 10:42:05 +08:00
RESULTS=$(aws ec2 describe-transit-gateways --query 'TransitGateways[].TransitGatewayId' --output text --no-cli-pager | sed 's/\t/\n/g' | sort | xargs)
jq -n --arg result "$RESULTS" '{"result":$result}'