kk.*_*kk. 6 amazon-web-services aws-cloudformation aws-parameter-store
坚持使用 AWS Parameter Store 中的 SecureString。我试图将数据库密码称为:
DatabasePassword:
Type: AWS::SSM::Parameter::Value<SecureString>
NoEcho: 'true'
Default: /environment/default/database_password
Description: The database admin account password
Run Code Online (Sandbox Code Playgroud)
这会引发错误:
调用 CreateStack 操作时发生错误 (ValidationError):模板格式错误:无法识别的参数类型:SecureString
但是,如果我引用此参数String而不是SecureString它会引发不同的错误:
调用 CreateStack 操作时发生错误 (ValidationError):模板引用的参数 [/environment/default/database_password] 具有 CloudFormation 不支持的类型。
我确实尝试使用'{{resolve:ssm-secure:parameter-name:version}}',它适用于数据库配置:
MasterUsername: !Ref DatabaseUsername
MasterUserPassword: '{{resolve:ssm-secure:/environment/default/database_password:1}}'
Run Code Online (Sandbox Code Playgroud)
但是,我使用的是 AWS Fargate docker 容器,我将这些值作为环境变量提供:
Environment:
- Name: DATABASE_HOSTNAME
Value: !Ref DatabaseHostname
- Name: DATABASE_USERNAME
Value: !Ref DatabaseUsername
- Name: DATABASE_PASSWORD
Value: '{{resolve:ssm-secure:/environment/default/database_password:1}}'
Run Code Online (Sandbox Code Playgroud)
这会引发错误:
调用 CreateStack 操作时发生错误 (ValidationError):SSM Secure reference is not supported in: [AWS::ECS::TaskDefinition/Properties/ContainerDefinitions/Environment]
无法在我的实现中使用安全字符串。这个问题有什么解决方法吗?AWSSecureString去年宣布支持,但找不到文档。我发现的只是使用resolve它仅在某些情况下有效。
参考:
CloudFormation 不支持SecureString作为模板参数类型。您可以在下面的文档中进行确认,让我引用它。
此外,AWS CloudFormation不支持将模板参数定义为 SecureString Systems Manager 参数类型。但是,您可以使用动态参数模式将安全字符串指定为某些资源的参数值。
参考:https : //docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#aws-ssm-parameter-types
正如您提到的,您“可以”使用 解决它dynamic parameter patterns,但只有有限的资源支持它。ECS并且Fargate没有。
参考:https : //docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html
也许您可以使用 解决它Secrets Manager,而不是将密码设置为容器的环境变量,您的应用程序在运行时从 中获取密码Secrets Manager,这也提高了您的安全性,密码不会在容器内以明文形式存在。
您可以在下面看到此解决方案的一个示例,它不适用于容器,但使用环境变量和Secrets Manager.
参考:https : //aws.amazon.com/blogs/security/how-to-securely-provide-database-credentials-to-lambda-functions-by-using-aws-secrets-manager/
| 归档时间: |
|
| 查看次数: |
8058 次 |
| 最近记录: |