切换 AWS CLI 区域的命令是:

huangapple go评论67阅读模式
英文:

Command to switch the region on aws cli

问题

以下是要翻译的内容:

"切换 AWS CLI 区域的命令是什么?我想切换到另一个区域,我的 Lambda 函数在那里。我尝试了以下命令,但它们不起作用:

aws --region <region_name>
aws set region <region_name>
aws configure region <region_name>
aws lambda .... --region <region_name>
```"

<details>
<summary>英文:</summary>

&lt;br/&gt;

What is the command to switch the region on aws cli. I want to switch to another region where my lambdas are present&lt;br/&gt;
I have tried these commands but they doesn&#39;t work&lt;br/&gt;

aws --region <region_name>
aws set region <region_name>
aws configure region <region_name>
aws lambda .... --region <region_name>


</details>


# 答案1
**得分**: 3

你可以设置`AWS_REGION`环境变量,这样AWS CLI将在后续的调用中使用它:
```bash
export AWS_REGION=us-east-1

然后,如果你使用

aws lambda ...

命令,它将在该区域执行。

另外,如果你希望将此更改持久化,你可以修改你的~/.aws/credentials文件并在那里设置区域。

英文:

You can set the AWS_REGION environment variable so that the AWS CLI would use it in the subsequent calls:

export AWS_REGION=us-east-1

Then if you use

aws lambda ...

command it would be executed in that region.

Alternatively, if you want this change to be persisted you can change your ~/.aws/credentials file and set the region there.

答案2

得分: 2

--region &lt;region&gt; 应该可以胜任工作。在大多数情况下,我使用region参数作为我的配置文件的一部分。如果在您的情况下不起作用,请检查环境变量。

参考链接:命令行选项 - AWS命令行界面

英文:

As far as I can tell --region &lt;region&gt; should do the job. In most of the cases I use the region parameter as a part of my profile. If it doesn't work in your case, check the environment variable.

Reference: Command line options - AWS Command Line Interface

答案3

得分: 0

AWS CLI提供了在任何时候设置区域的方法。您可以使用以下命令来设置区域:

aws configure --region <region>

例如:

aws configure --region us-east-2

之后,CLI将要求您输入ID和密钥。您可以看到它将使用现有凭据,只需按回车键继续。如果它要求输入区域,请提供新的区域然后按回车,就这样!您已经可以继续前进了。

英文:

AWS cli provides the way to set region at anytime you wish. You can use following command to set the region

aws configure --region &lt;region&gt;

For example:

aws configure --region us-east-2

After this cli will ask you ID and Secret, You can see it will come with existing creds just hit enter and move ahead. If it ask for region give the new region and hit enter, That's it! You are good to go ahead.

huangapple
  • 本文由 发表于 2023年2月23日 20:39:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75544962.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定