aws-cloudformation - 为什么建议在 AWS SecretsManager 中手动配置预先存在的 key ,而不是通过 CDK/Cloudformation?

标签 aws-cloudformation aws-cdk

引自 aws cdk docs :

If you need to use a pre-existing secret, the recommended way is to manually provision the secret in AWS SecretsManager and use the Secret.fromSecretArn or Secret.fromSecretAttributes method to make it available in your CDK Application

这是为什么呢?是不是因为将纯文本 secret 保存到代码中并不理想?

或者我们不希望 secret 出现在 cloudformation 模板中?

最佳答案

是的,是的。早期的 CDK 版本甚至不允许将文本值传递给 Secret 构造函数。我们only recently got secretStringBeta1: string并提出严厉警告:

It is highly encouraged to leave this field undefined and allow SecretsManager to create the secret value. The secret string -- if provided -- will be included in the output of the cdk as part of synthesis, and will appear in the CloudFormation template in the console. This can be secure(-ish) if that value is merely reference to another resource (or one of its attributes), but if the value is a plaintext string, it will be visible to anyone with access to the CloudFormation template (via the AWS Console, SDKs, or CLI).

我们的 CDK 代码和生成的模板应该是 deterministic and version-controlled ,如果使用明文 secret ,进一步增加泄露的风险。

编辑:根据 @gshpychka 的评论,使用 Secret.fromSecretArn 导入的安全替代方法是构造一个没有 secret 值的新 Secret 。这将创建一个带有随 secret 码的 secret ,您可以在控制台中进行部署后更改该密码。这种方法有助于将 key 的生命周期与堆栈联系起来,并允许您在堆栈的上下文中设置其属性。

关于aws-cloudformation - 为什么建议在 AWS SecretsManager 中手动配置预先存在的 key ,而不是通过 CDK/Cloudformation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70849198/

相关文章:

amazon-web-services - AWS Systems Manager 如何在自动化步骤之间添加延迟

c# - 使用 IAmazonDynamoDB 或 IDynamoDBContext (两者都?)

amazon-web-services - 将 ApplicationListenerRule 添加到现有的 ApplicationListener 会出现错误 'A listener already exists on this port for this load balancer'

aws-cdk - 与现有代码管道一起使用的 AWS CDK 管道

amazon-web-services - CDK : Possible to put the stack created for EdgeFunction resource in another (cross-region) stack?

amazon-web-services - SQS订阅SNS : How to specify multiple TopicArns in CloudFormation?

node.js - Node createStack 的 CloudFormation aws-sdk 错误 UnexpectedParameter : Unexpected key 'ClientRequestToken'

aws-cloudformation - 如何获取 AWS KMS Key Arn 并通过 CloudFormation 将其传递到 IAM 角色内联策略中?

python - Cloudfront 提供通过 AWS CDK Python 为 S3 存储桶源创建的访问被拒绝响应,无需公共(public)访问

amazon-web-services - 具有 EC2 和 Fargate 实例的 AWS 混合集群