Is there a way to run initial SQL when creating an RDS database instance using CloudFormation?

后端 未结 4 1445
北海茫月
北海茫月 2020-12-24 05:21

I am creating an RDS instance using CloudFormation using this:

\"Resources\": {
        \"myDB\": {
            \"Type\": \"AWS::RDS::DBInstance\",
                     


        
4条回答
  •  再見小時候
    2020-12-24 05:47

    Another option is to use DBSnapshotIdentifier property for AWS::RDS::DBInstance resource. The only catch is that you need to have a DB loaded in AWS to create the snapshot in the first place. From then on, you can automate your cloudformation stack to be using it though.

    DBSnapshotIdentifier: Name (ARN) of the DB snapshot that's used to restore the DB instance.

    If the property contains a value (other than an empty string), AWS CloudFormation creates a database from the specified snapshot.

    After you restore a DB instance with a DBSnapshotIdentifier property, you must specify the same DBSnapshotIdentifier property for any future updates to the DB instance. When you specify this property for an update, the DB instance is not restored from the DB snapshot again, and the data in the database is not changed. However, if you don't specify the DBSnapshotIdentifier property, an empty DB instance is created, and the original DB instance is deleted.

    Look in the doc from more info: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html#cfn-rds-dbinstance-dbsnapshotidentifier

提交回复
热议问题