bla*_*ops 22 bash amazon-web-services docker
任何人都可以告诉我如何使用单线程自动化bash配置bash?
例:
$ aws configure --profile user2
AWS Access Key ID [None]: AKIAI44QH8DHBEXAMPLE
AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: text
Run Code Online (Sandbox Code Playgroud)
应用程序:我想在Docker入口点内自动执行此操作!
jar*_*mod 28
如果运行,aws configure set help您将看到可以在命令行上单独提供设置,它们将被写入相关的凭据或配置文件.例如:
aws configure set aws_access_key_id AKIAI44QH8DHBEXAMPLE
您还可以以交互方式运行此操作以修改默认凭据:
aws configure
或者以交互方式运行它以创建/修改命名的配置文件:
aws configure --profile qa
Erd*_* G. 27
aws configure set aws_access_key_id "AKIAI44QH8DHBEXAMPLE" --profile user2 && aws configure set aws_secret_access_key "je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY" --profile user2 && aws configure set region "us-east-1" --profile user2 && aws configure set output "text" --profile user2
Run Code Online (Sandbox Code Playgroud)
注意:设置区域是可选的(如果没有任何区域,也不要将其设置为空字符串,否则会出现错误);以及用户配置文件,如果您不设置它,它将进入默认设置。
使用秘密,然后使用关联的环境变量:
aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile user2 && aws configure set aws_secret_access_key "$AWS_ACCESS_KEY_SECRET" --profile user2 && aws configure set region "$AWS_REGION" --profile user2 && aws configure set output "text" --profile user2
Run Code Online (Sandbox Code Playgroud)
aws configure set help以获取命令行选项。小智 11
我认为这就是一句话的答案
aws configure set aws_access_key_id $YOUR_ACCESS_KEY_ID; aws configure set aws_secret_access_key $YOUR_SECRET_ACCESS_KEY; aws configure set default.region $YOUR_AWS_DEFAULT_REGION
Run Code Online (Sandbox Code Playgroud)
如果要自动化,则应使用文件而不是CLI。您的CLI仅写那些文件。
? cat ~/.aws/config
[profile_1]
output = json
region = eu-west-1
[profile_2]
output = json
region = eu-west-1
? cat ~/.aws/credentials
[profile_1]
aws_access_key_id =
aws_secret_access_key =
[profile_2]
aws_access_key_id =
aws_secret_access_key =
Run Code Online (Sandbox Code Playgroud)
对于那些倾向于使用bash的人来说,以下内容可以很好地发挥作用并将秘密隐藏在脚本之外。此外,它还将一次性将您的输入保存到命名配置文件。
printf "%s\n%s\nus-east-1\njson" "$KEY_ID" "$SECRET_KEY" | aws configure --profile my-profile
Run Code Online (Sandbox Code Playgroud)
aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile profile_name_here && aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile profile_name_here && aws configure set region "$AWS_REGION" --profile profile_name_here && aws configure set output "json" --profile profile_name_here
Run Code Online (Sandbox Code Playgroud)
profile_name_here是要保存到您的 aws 配置中的 aws 配置文件名称。用你自己的替换它。
访问密钥
aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile profile_name_here
秘密访问密钥
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile profile_name_here
地区
aws configure set region "$AWS_REGION" --profile profile_name_here
输出
aws configure set output "json" --profile profile_name_here
此处指定的值是json ,但您可以从aws docs支持的输出格式列表中替换它。
如果您使用 CI,$AWS_ACCESS_KEY_ID、$AWS_SECRET_ACCESS_KEY和$AWS_REGION是AWS 凭证文件或环境变量中的变量。您还可以使用常规字符串值替换它们,但这并不安全。
| 归档时间: |
|
| 查看次数: |
11966 次 |
| 最近记录: |