AWS Connection Info in build steps

I am running script build steps and need some basic information about the AWS connection created by using the ProvideAwsCredentials feature.

Is there an API to retrieve information such as the account number and region of the account being used within the current context?

0
1 comment
Official comment

Hello, Michael Hammond!
When there is a ProvideAwsCredentials BuildFeature, agent will create a temporary file with chosen AWS Connection credentials, the path to this file is stored in the AWS_SHARED_CREDENTIALS_FILE environment variable.

The aws_region information should be added to this file to the default profile as well, sorry, it is a bug and it will be fixed soon, please, see this issue.
As for the account id, aws does not provide a way to store it inside this credentials file, but you can get the AWS Account ID using this command (aws cli will automatically find the mentioned file with credentials):

aws sts get-caller-identity --query 'Account' --output text

If you need to get region and account id information in another way, please, let us know what would be the most convenient way. We could add them as parameters when the build is running, feel free to create a feature request.

Please sign in to leave a comment.