CloudFormation 秘密

CloudFormation Secrets

我想坚持"all infrastructure is code"的政策。但是,我看不到使用 CloudFormation 来处理机密的方法。

SecretsManager 要求您以纯文本形式指定 SecretString。即使您从某处注入解密值,纯文本字符串也会显示在模板视图的 CF 控制台中:/

SSM中也不可能使用加密字符串。文档说,"AWS CloudFormation doesn't support creating a SecureString parameter type."

难道真的没有办法使用 CloudFormation 以代码的形式安全地管理机密吗?

您可以使用 Secret resource in CloudFormation to create SecretsManager secrets. There is a way to generate a value in the SecretString (which uses the GenerateRandomPassword API). Look at the GenerateSecretString 属性.

这应该可以帮助您生成密码,而无需在模板中对其进行硬编码。

还有一个 RotationSchedule 资源可帮助您设置机密的自动轮换。

要使用存储在 SecretsManager 机密或 Parameter Store 参数中的机密值,请使用 dynamic references。动态 refs 保证秘密值不被记录在 CFN 中或显示在控制台中。

目前无法在参数 Store/Systems 管理器中 create/generate SecureString 参数。