aws-cloudformation - 在 Aws 控制台模板选项卡中隐藏 CloudFormation/SAM secret

标签 aws-cloudformation serverless-application-model

假设我在 Cloud Formation(或 SAM)模板中有以下 secret ,我将其作为堆栈的一部分部署到我的 AWS IAM 账户(当然还有由运行云的脚本动态分配的 SecretString 的敏感值)编队部署):

Resources:
 
  MySecret:
    Type: AWS::SecretsManager::Secret
    Properties:
      Name: MySecret
      Description: Embarssing fact I want to keep secret
      SecretString: "I_think_Twighlight_Sparkle_is_cool"

当我检查 aws 控制台上的堆栈页面时,我注意到"template"选项卡以纯文本形式显示了整个模板,包括此 secret 。

这对我来说似乎非常不可取,我想知道是否有某种方法可以减轻我所缺少的。虽然只有有权访问 IAM 账户的人才能访问 aws 控制台,但以纯文本形式弹出 secret 似乎是不可取的,除非有人特别要求查看它们。

有人知道缓解这种情况的好方法吗?

最佳答案

根据您的解释,我假设您只想在从控制台查看时隐藏明文值。使用您的方法可以得到的最接近的结果是使用 NoEcho在参数中。

您可以执行的示例是将要屏蔽的字符串移动到参数中,然后将参数属性 NoEcho 设置为 True,然后您只需在资源中引用该参数值即可。

但是,正如文档指出的那样,这并不能解决模板内值可见的问题:

"we recommend you use dynamic parameters in the stack template to reference sensitive information that is stored and managed outside of CloudFormation"

这意味着,使用当前的架构,您无法隐藏模板中的值。相反,您需要引用模板外部的值或创建一个精心设计的 custom resource这创造了你的 secret 值(value)。除此之外,正如您所指出的,可以通过 IAM 权限进行限制。

关于aws-cloudformation - 在 Aws 控制台模板选项卡中隐藏 CloudFormation/SAM secret ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62923270/

相关文章:

amazon-web-services - AWS cfn-hup 配置中的 post.add、post.update 与 post.delete

amazon-web-services - 如何使用 cloudformation 迁移到以前版本的堆栈?

amazon-web-services - AWS S3创建错误: "The event is not supported for notifications (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument"

aws-lambda - 如何使用 SAM 模板 cloudformation 在不同的 aws 账户中调用 lambda

amazon-web-services - 无服务器云信息 : cast environment variable to number

amazon-web-services - 如何使用 aws codepipeline 和 cloudformation 在 github 中仅部署更改的 lambda 函数?

amazon-s3 - 如何指定S3 bucket region SAM模板

amazon-web-services - 无法上传 HelloWorldFunction 资源的 CodeUri 参数引用的工件 None

node.js - AWS CI/CD 工作流程的最佳路径是什么? Cloudformation、SAM 还是无服务器框架?

amazon-web-services - aws cli 命令输出作为 cloudformation 模板中的值