Create an Amazon Secrets Manager secret with Amazon CloudFormation - Amazon Secrets Manager
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Create an Amazon Secrets Manager secret with Amazon CloudFormation

This example creates a secret named CloudFormationCreatedSecret-a1b2c3d4e5f6. The secret value is the following JSON, with a 32-character password that is generated when the secret is created.

{ "password": "EXAMPLE-PASSWORD", "username": "saanvi" }

This example uses the following CloudFormation resource:

For information about creating resources with Amazon CloudFormation, see Learn template basics in the Amazon CloudFormation User Guide.

JSON

{ "Resources": { "CloudFormationCreatedSecret": { "Type": "AWS::SecretsManager::Secret", "Properties": { "Description": "Simple secret created by Amazon CloudFormation.", "GenerateSecretString": { "SecretStringTemplate": "{\"username\": \"saanvi\"}", "GenerateStringKey": "password", "PasswordLength": 32 } } } } }

YAML

Resources: CloudFormationCreatedSecret: Type: 'AWS::SecretsManager::Secret' Properties: Description: Simple secret created by Amazon CloudFormation. GenerateSecretString: SecretStringTemplate: '{"username": "saanvi"}' GenerateStringKey: password PasswordLength: 32