简体   繁体   English

在新启动的 EC2 实例中自动从 AWS 密钥管理器检索密钥的最佳方法是什么?

[英]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.

相关问题 AWS:如何在 EC2 实例上获取 PHP 以读取 Secrets Manager 密钥? - AWS: How to get PHP on an EC2 instance to read a Secrets Manager secret? AWS EC2-如何在新启动的实例上安装现有EBS(/) - AWS EC2 - how to mount existing EBS (on /) on a newly launched instance EC2 实例如何访问 Aws Secrets Manager - How does an EC2 instance access the Aws Secrets Manager 从 EC2 实例访问 AWS 机密管理器时出现权限错误 - Permission error when accessing AWS secrets manager from an EC2 instance AWS Secrets manager 可从 EC2 实例访问,但在从部署在同一实例上的 docker 容器运行时抛出 NoCredentialsError - AWS Secrets manager accessible from EC2 instance but throws NoCredentialsError when running from the docker container deployed on the same instance 从管理器检索机密并将其在ec2 cfn-init中使用 - Retrieve a secret from manager and use it in ec2 cfn-init 使用复制将200 GB数据库从ec2实例导入RDS Postgresql的最佳方法是什么? - What's the best way to get a 200 GB database from ec2 instance into RDS Postgresql by using Replication…? aws - 秘密管理器 - 当我想从 ec2 访问时如何保护秘密? - aws - secrets manager - how to secure secrets when I want to access from ec2? 从 AWS Secrets Manager 检索密钥 - Retrieve secrets from AWS Secrets Manager 从 AWS 机密管理器获取所有机密 - get all secrets from AWS secret manager
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM