Skip to content

Instantly share code, notes, and snippets.

@PaulDuvall
Last active November 18, 2021 21:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulDuvall/ce466d5417c30bafc238771109a18f51 to your computer and use it in GitHub Desktop.
Save PaulDuvall/ce466d5417c30bafc238771109a18f51 to your computer and use it in GitHub Desktop.
MyDBInstance:
Type: AWS::RDS::DBInstance
Properties:
AllocatedStorage: 20
DBInstanceClass: db.t2.micro
Engine: mysql
MasterUsername: !Join ['', ['{{resolve:secretsmanager:', !Ref MyRDSInstanceRotationSecret, ':SecretString:username}}' ]]
MasterUserPassword: !Join ['', ['{{resolve:secretsmanager:', !Ref MyRDSInstanceRotationSecret, ':SecretString:password}}' ]]
BackupRetentionPeriod: 0
DBInstanceIdentifier: 'rotation-instance'
VPCSecurityGroups:
- !ImportValue 'MySecurityGroupLambda'
DBSubnetGroupName:
Ref: "DBSubnetGroup"
#This is a SecretTargetAttachment resource which updates the referenced Secret resource with properties about
#the referenced RDS instance
SecretRDSInstanceAttachment:
Type: AWS::SecretsManager::SecretTargetAttachment
Properties:
SecretId: !Ref MyRDSInstanceRotationSecret
TargetId: !Ref MyDBInstance
TargetType: AWS::RDS::DBInstance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment