将文件直接通过管道传输到 AWS SSM 参数存储?

Min*_*ieh 6 amazon-web-services aws-cli

只是想知道如何将文件直接通过管道传输到 aws ssm 参数存储?例如

# Put into ssm parameter store
cat my_github_private.key | aws ssm put-parameter --region ap-southeast-1 --name MY_GITHUB_PRIVATE_KEY --type SecureString --key-id alias/aws/ssm --value ??? 
# And read it back 
aws ssm get-parameter --region ap-southeast-1 --name MY_GITHUB_PRIVATE_KEY --with-decryption --query Parameter.Value --output text > my_github_private.key.1
# Two should be identical
diff my_github_private.key my_github_private.key.1
Run Code Online (Sandbox Code Playgroud)

tkw*_*rgs 9

stdin您可以直接添加到命令行参数中,而不是从中获取值?

aws ssm put-parameter \
    --region ap-southeast-1 \
    --name MY_GITHUB_PRIVATE_KEY \
    --type SecureString \
    --key-id alias/aws/ssm \
    --value file://my_github_private.key
Run Code Online (Sandbox Code Playgroud)

注意:--value "$(cat my_github_private.key)"也有效

  • Github [aws-cli repo] (https://github.com/aws/aws-cli/issues/3132) 的另一个回应:`aws ssm put-parameter \ --region ap-southeast-1 \ --name MY_GITHUB_PRIVATE_KEY \ --type SecureString \ --key-id alias/aws/ssm \ --value file://path/to/my_github_private.key` 它们都可以工作。谢谢你们。 (5认同)