如何从命令行使用多个 AWS 账户? [英] How to use multiple AWS accounts from the command line?

查看:39
本文介绍了如何从命令行使用多个 AWS 账户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Amazon EC2 上托管了两个不同的应用程序(第二个即将上线).

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

我如何在命令行 (Mac OS X) 上使用两个帐户,但保留 EC2 密钥 &证书分开?我需要在每个 ec2-* 命令之前更改我的环境变量吗?

How can I work with both accounts at the command line (Mac OS X) but keep the EC2 keys & certificates separate? Do I need to change my environment variables before each ec2-* command?

使用别名并将其设置为内嵌环境是否可行?类似的东西:

Would using an alias and having it to the setting of the environment in-line work? Something like:

alias ec2-describe-instances1 = export EC2_PRIVATE_KEY=/path; ec2-describe-instances

推荐答案

您应该能够使用以下命令选项来代替 EC2_PRIVATE_KEY(甚至 EC2_CERT>) 环境变量:

You should be able to use the following command-options in lieu of the EC2_PRIVATE_KEY (and even EC2_CERT) environment variables:

  • -K <私钥>
  • -C <证书>

您可以将这些放在别名中,例如

You can put these inside aliases, e.g.

alias ec2-describe-instances1 ec2-describe-instances -K /path/to/key.pem

这篇关于如何从命令行使用多个 AWS 账户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆