AWS::SecretsManager 轉換程序 - AWS CloudFormation

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

AWS::SecretsManager 轉換程序

使用轉AWS::SecretsManager換 (由 AWS CloudFormation主控的巨集) 來指定執行秘密旋轉的 AWS Lambda 函數。當建立變更集使用變更集更新堆疊和範本參考時AWS::SecretsManager, AWS CloudFormation 會產生執行密碼旋轉的 AWS Lambda 函數。使用AWS::SecretsManager::RotationSchedule資源的HostedRotationLambda屬性類型來指定所需 AWS Lambda 函數的屬性。

該 AWS Lambda 函數位於已處理模板中的嵌套堆棧AWS::CloudFormation::Stack資源)中。然後,此資源會根據資源中RotationType指定的資AWS::SecretsManager::RotationSchedule源,連結至 AWS Secrets Manager 輪換 Lambda 函數儲存庫中適當的函數範本。

用量

在範本的最上層使用 AWS::SecretsManager 轉換。您無法將 AWS::SecretsManager 作為內嵌於任何其他範本區段的轉換使用。

轉換宣告的值必須是常值字串。您不能使用參數或函數來指定轉換值。

範本最上層的語法

若要在範本的最上層包含 AWS::SecretsManager,請在 Transform 區段中使用下列語法。

JSON

{ "Transform": "AWS::SecretsManager-2020-07-23", . . . }

YAML

Transform: AWS::SecretsManager-2020-07-23

參數

AWS::SecretsManager 轉換不接受任何參數。而是使用堆棧模板中AWS::SecretsManager::RotationSchedule資源的屬性類型來指定要創建的秘密旋轉 AWS Lambda 函數的屬性。HostedRotationLambda

備註

如需有關使用巨集的一般考量,請參閱建立 CloudFormation 巨集定義時的考量

範例

下列部分範本範例示範如何使用轉AWS::SecretsManager換指定 AWS Lambda 函式,根據資源的屬性類型中指定的屬性,在 MySQL AWS::SecretsManager::RotationSchedule 資料庫上為單一使用者指定秘密旋轉的函數。HostedRotationLambda

如需完整範本範例,說明 RDS 資料庫、Amazon Redshift 叢集和文件資料庫叢集的秘密輪換,請參閱的範例一節。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