How to use multiple AWS Accounts from the command line?

前端 未结 7 1650
故里飘歌
故里飘歌 2020-12-22 16:35

I\'ve got two different apps that I am hosting (well the second one is about to go up) on Amazon EC2.

How can I work with both accounts at the command line (Mac OS X

相关标签:
7条回答
  • 2020-12-22 17:29

    Maybe it still help someone. You can set it manually.

    1) Set in file

    ~/.aws/credentials
    

    this

    [default]
    aws_access_key_id={{aws_access_key_id}}
    aws_secret_access_key={{aws_secret_access_key}}
    
    [{{profile_name}}]
    aws_access_key_id={{aws_access_key_id}}
    aws_secret_access_key={{aws_secret_access_key}}
    
    • {{aws_access_key_id}} you can get in section AWS Console > Identity and Access Management > Security Credentials > Access Keys

    2) Set in file

    ~/.aws/config
    

    this

    [default]
    region={{region}}
    output={{output:"json||text"}}
    
    [profile {{profile_name}}]
    region={{region}}
    output={{output:"json||text"}}
    

    3) Test it with AWS Command Line and command and output will be JSON

    aws ec2 describe-instances --profile {{profile_name}}
    

    Ref

    http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles

    0 讨论(0)
提交回复
热议问题