So I'm trying to list the customer gateways in an account using AWS CLI. The problem is that I can only get it to work with credentials from a profile, not from environment variables.
I know I must be missing something simple here, but I can't for the life of me see what.
If I use a profile defined in ~/.aws/credentials, everything works fine:
$ aws sts get-caller-identity --profile devops-preprod-deploy
{
"UserId": "AROAT6IOCTARVOTPZB4CD:botocore-session-1576056489",
"Account": "123149340123",
"Arn": "arn:aws:sts::123149340123:assumed-role/pdapreprod-deployment-role/botocore-session-1576056489"
}
$ aws ec2 describe-customer-gateways --profile devops-preprod-deploy
{
"CustomerGateways": [
{
"BgpAsn": "65000",
"CustomerGatewayId": "cgw-0123851d01236295b",
"IpAddress": "123.58.165.123",
"State": "available",
"Type": "ipsec.1",
"Tags": [
{
"Key": "Name",
"Value": "Office"
}
]
}
]
}
If I use assume role and put the temporary credentials in the environment, it doesn't work:
$ export AWS_ACCESS_KEY_ID="ASIBT6IOCTNRTS..."
$ export AWS_SECRET_ACCESS_KEY="rNFhltabK9Rfk69xj/2..."
$ export AWS_SESSION_TOKEN="FwoGZXIvYXdzELT///////..."
$ aws sts get-caller-identity
{
"UserId": "AROAT6IOCTARVOTPZB4CD:pdapreprod-deployment-role",
"Account": "123149340123",
"Arn": "arn:aws:sts::123149340123:assumed-role/pdapreprod-deployment-role/myname"
}
$ aws ec2 describe-customer-gateways
{
"CustomerGateways": []
}
What am I doing wrong?