AWS::SecretsManager
转换
使用 AWS::SecretsManager
转换(由 AWS CloudFormation 托管的宏)来指定执行密钥轮换的 AWS Lambda 函数。当 创建更改集 或 使用更改集更新 CloudFormation 堆栈 且模板引用 AWS::SecretsManager
时,AWS CloudFormation 生成执行密钥轮换的 AWS Lambda 函数。使用 AWS::SecretsManager::RotationSchedule
资源的 HostedRotationLambda
属性类型指定所需 AWS Lambda 函数的属性。
AWS Lambda 函数位于已处理模板的嵌套堆栈(AWS::CloudFormation::Stack 资源)中。此资源随后链接到 AWS Secrets Manager 轮换 Lambda 函数AWS::SecretsManager::RotationSchedule
资源中指定的 RotationType)。
用量
在模板的顶层使用 AWS::SecretsManager
转换。AWS::SecretsManager
不能用作嵌入在任何其他模板部分中的转换。
转换声明的值必须为文字字符串。您无法使用参数或函数来指定转换值。
模板顶层的语法
要在模板顶层的 Transform
部分中包含 AWS::SecretsManager
,请使用以下语法。
JSON
{ "Transform": "AWS::SecretsManager-2020-07-23", . . . }
YAML
Transform: AWS::SecretsManager-2020-07-23
参数
AWS::SecretsManager
转换不接受任何参数。而是使用堆栈模板中 AWS::SecretsManager::RotationSchedule
资源的 HostedRotationLambda
属性类型指定要创建的密钥轮换 AWS Lambda 函数的属性。
备注
有关使用宏的一般注意事项,请参阅创建 CloudFormation 宏定义时的注意事项。
示例
下面的部分模板示例演示如何使用 AWS::SecretsManager
转换根据在 AWS::SecretsManager::RotationSchedule
资源的 HostedRotationLambda
属性类型中指定的属性,为单个用户在 MySQL 数据库上为密钥轮换指定 AWS Lambda 函数。
有关演示 RDS 数据库、Amazon Redshift 集群和 Document DB 集群的密钥轮换的完整模板示例,请参阅 AWS::SecretsManager::RotationSchedule 中的示例部分。
JSON
{ "AWSTemplateFormatVersion": "2010-09-09", "Transform": "AWS::SecretsManager-2020-07-23", "Resources": { . . . "MySecretRotationSchedule": { "Type": "AWS::SecretsManager::RotationSchedule", "DependsOn": "SecretRDSInstanceAttachment", "Properties": { "SecretId": { "Ref": "MyRDSInstanceRotationSecret" }, "HostedRotationLambda": { "RotationType": "MySQLSingleUser", "RotationLambdaName": "SecretsManagerRotation", "VpcSecurityGroupIds": { "Fn::GetAtt": [ "TestVPC", "DefaultSecurityGroup" ] }, "VpcSubnetIds": { "Fn::Join": [ ",", [ { "Ref": "TestSubnet01" }, { "Ref": "TestSubnet02" } ] ] } }, "RotationRules": { "AutomaticallyAfterDays": 30 } } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Transform: AWS::SecretsManager-2020-07-23 Resources: . . . MySecretRotationSchedule: Type: AWS::SecretsManager::RotationSchedule DependsOn: SecretRDSInstanceAttachment Properties: SecretId: !Ref MyRDSInstanceRotationSecret HostedRotationLambda: RotationType: MySQLSingleUser RotationLambdaName: SecretsManagerRotation VpcSecurityGroupIds: !GetAtt TestVPC.DefaultSecurityGroup VpcSubnetIds: Fn::Join: - "," - - Ref: TestSubnet01 - Ref: TestSubnet02 RotationRules: AutomaticallyAfterDays: 30