0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS CDKでRDSデータベースを作成する方法

Posted at

背景

あWSで開発していて、RDSデータベースを複製し、検証・開発する必要があります。そこで、瞬時に新しいデータベースを作れるように、
AWS CDKでデータベースを作成するスクリプトを作ります。

1. How to code

import AWS = require("aws-sdk");
AWS.config.update({ region: "ap-northeast-1" });
const rds = new AWS.RDS();

function rdsGenerator() {
    const rdsParams = {
        DBInstanceIdentifier: "production-replica-fortools",
        DBInstanceClass: "db.m3.medium",
        AvailabilityZone: "ap-northeast-1a",
        Engine: "mysql",
        MasterUsername: "MYACCOUNTID",
        MasterUserPassword: "MYPASSWORD",
        AllocatedStorage: 10,
        PubliclyAccessible: false,
        DBSubnetGroupName: "default-vpc-9qe6ce5d",
        VpcSecurityGroupIds: ["sg-eqweq5b9b"],
        StorageType: "standard"
    };

    rds.createDBInstance(rdsParams, function(err, data) {
        if (err) {
            console.log("error. Failed to create database instance", err);
        } else {
            console.log("successfully create database instance ", data);
        }
    });
}

rdsGenerator();
0
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?