amazon-web-services - 使用 CloudFormation(和 Lambda 轮换模板)的 Aurora Serverless 密码轮换设置
问题描述
AWS 为一些受支持的 RDS 引擎提供了完全配置且随时可用的轮换支持,包括 Amazon Aurora(也无服务器?)
我正在尝试使用以下方法在我的 CloudFormation 模板中设置密码轮换AWS::SecretsManager::RotationSchedule
(请注意,这不是一个功能齐全的模板,只是一个说明):
DBCluster:
Type: AWS::RDS::DBCluster
Properties:
Engine : aurora
EngineMode : serverless
EngineVersion : 5.6.10a
Secret:
Type: AWS::SecretsManager::Secret
Properties:
GenerateSecretString:
SecretStringTemplate: '{"username": "admin"}'
GenerateStringKey: password
PasswordLength: 20
ExcludeCharacters: '"@/\'
SecretTargetAttachment:
Type: AWS::SecretsManager::SecretTargetAttachment
Properties:
SecretId: !Ref Secret
TargetId: !Ref DBCluster
TargetType: AWS::RDS::DBCluster
SecretRotation:
Type: AWS::SecretsManager::RotationSchedule
Properties:
SecretId: !Ref UserAdminSecret
RotationLambdaARN: <ARN_GET_FROM_SERVERLESS_APPLICATION_REPOSITORY>
RotationRules:
AutomaticallyAfterDays: 1
但 AWS Lambda 轮换函数失败并显示以下消息:
“数据库引擎必须设置为 'mysql' 才能使用此旋转 lambda”:KeyError
AWS 提供的 AWS Lambda 轮换功能似乎不支持 Aurora Serverless。
是否有使用现有 Lambda 轮换模板设置 Aurora Serverless 密钥轮换的简单方法?
任何可用于为 Aurora Serverless 编写我自己的轮换函数的示例?
解决方案
RotationSchedule 资源依赖于 SecretTargetAttachment 资源。附件资源更新您的秘密字符串值以包含连接信息,例如数据库引擎、端口和端点。
不幸的是,CloudFormation 无法了解两种资源之间的这种隐式依赖关系。您需要使用附件资源的逻辑 ID 在 RotationSchedule 资源上放置一个DependsOn 。
请参阅此示例中的 RotationSchedule 资源 - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-secretsmanager-rotationschedule.html#aws-resource-secretsmanager-rotationschedule--examples
推荐阅读
- c - 使用 Contiki OS 在 rpl 协议中实现多首选父级
- javascript - 如何使用 TinyMCE 显示格式化内容
- angular - 当“ng-select”点击“下拉菜单”之外的某个地方时没有关闭
- c# - C#如何在接受或拒绝Outlook约会时获取收件人添加的评论
- ruby-on-rails - 将 javascript 变量附加到 erb 标记中
- corda - 如何为每个节点加载不同的 UI
- javascript - 在所有情况下都使用 new Function() 不安全吗?
- java - 如何在 dropwizard 中禁用 cron 作业
- hyperledger - 将资产的特定属性导入另一个资产以在 Hyperledger Composer 中进行交易
- c# - 将字符串从 CP866 转换为 UTF8