AWS::SecretsManager 转换 - Amazon CloudFormation
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

AWS::SecretsManager 转换

使用 AWS::SecretsManager 转换(由 Amazon CloudFormation 托管的宏)来指定执行密钥轮换的 Amazon Lambda 函数。当 创建更改集使用更改集更新堆栈 且模板引用 AWS::SecretsManager 时,Amazon CloudFormation 生成执行密钥轮换的 Amazon Lambda 函数。使用 AWS::SecretsManager::RotationSchedule 资源的 HostedRotationLambda 属性类型指定所需 Amazon Lambda 函数的属性。

Amazon Lambda 函数位于已处理模板的嵌套堆栈AWS::CloudFormation::Stack 资源)中。此资源随后链接到 Amazon 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 属性类型指定要创建的密钥轮换 Amazon Lambda 函数的属性。

备注

有关使用宏的一般注意事项,请参阅创建 Amazon CloudFormation 宏定义时的注意事项

示例

下面的部分模板示例演示如何使用 AWS::SecretsManager 转换根据在 AWS::SecretsManager::RotationSchedule 资源的 HostedRotationLambda 属性类型中指定的属性,为单个用户在 MySQL 数据库上为密钥轮换指定 Amazon 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