[英]What's the best way to automatically retrieve a secret from AWS secrets manager in a newly launched EC2 instance?
I have an app I'm deploying using a CloudFormation template with an AutoScaling Policy.我有一个使用带有 AutoScaling 策略的 CloudFormation 模板部署的应用程序。
I'm storing credentials for the app in AWS Secrets Manager.我将应用程序的凭证存储在 AWS Secrets Manager 中。
I need to retrieve the credentials and copy them over to the application config during the instance's bootup process.我需要在实例的启动过程中检索凭据并将它们复制到应用程序配置中。
What's the best way of securely achieving this?安全地实现这一目标的最佳方法是什么?
Baking them into the AMI isn't an option because the credentials will be changing much more frequently than the image.将它们烘焙到 AMI 中不是一种选择,因为凭证的更改频率将比图像更频繁。
You can pass a script in the UserData
field, which will be executed when the Amazon EC2 instance first boots.您可以在UserData
字段中传递一个脚本,该脚本将在 Amazon EC2 实例首次启动时执行。
It can use the AWS Command-Line Interface (CLI) to retrieve the secret from AWS Secrets Manager.它可以使用AWS 命令行界面 (CLI)从 AWS Secrets Manager 中检索密钥。 You can then write some funky shell script to insert it into the desired configuration file.然后,您可以编写一些时髦的 shell 脚本将其插入所需的配置文件中。
See:看:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.