Is there a way to export an AWS CLI Profile to Environment Variables?

后端 未结 7 947
半阙折子戏
半阙折子戏 2020-12-29 23:41

When working with certain third-party tools like Terraform, it\'s not easily possible to specify an AWS CLI profile, and I like working with the environment variables better

7条回答
  •  时光取名叫无心
    2020-12-30 00:07

    For sts assume role case, based on Frederic's idea, I figured out a workable shell script as followings:

    aws-env.sh:

    #!/bin/bash
    export AWS_ACCESS_KEY_ID=$(aws configure get default.aws_access_key_id)
    export AWS_SECRET_ACCESS_KEY=$(aws configure get default.aws_secret_access_key)
    export AWS_SESSION_TOKEN=$(aws configure get default.aws_session_token)
    
    echo AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
    echo AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
    echo AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN
    
    bash -i
    

    Hope this helps.

提交回复
热议问题