Skip to content

Commit 78a0cfa

Browse files
rsmaso-awsRolando Santamaria Maso
andauthored
extending documentation (#3)
Co-authored-by: Rolando Santamaria Maso <rsmaso@amazon.de>
1 parent 6e14166 commit 78a0cfa

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,41 @@ The source code and documentation in this repository describe how to support Ama
66
> Through this documentation and examples we focus on Amazon RDS for MySQL, but the concept being described can be applied to any other supported RDS engine.
77
88
### Potential use cases
9-
- Initialize databases with their corresponding schema or table structures.
9+
- Initialize databases.
1010
- Initialize/maintain users and their permissions.
1111
- Initialize/maintain stored procedures, views or other database resources.
1212
- Execute other custom logic as part of a resource initialization process.
13+
- Improve segregation of duties/least privilege by providing a flexible hook in the IaC, in order to manage RDS instances initialization.
14+
- Initialize database tables. (see note below)
15+
- Seed database tables with initial datasets. (see note below)
1316

14-
### Pre-Requisites:
17+
> NOTE: Please be aware that application specific initilization logic (for example: database tables structure and initial seeding of data) is a concern that is commonly managed on the application side. Overall, we advice to keep infrastructure initialization/management separated from application specific initialization.
18+
19+
### Pre-Requisites
1520
- Node.js v14+ installed on your local machine: https://nodejs.org/en/download/
1621
- Docker installed on your local machine: https://docs.docker.com/get-docker/
1722
- CDK v1.122+ installed and configured on your local machine: https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html
1823

24+
### Installation and Deployment steps
25+
- Git clone or download the repository:
26+
https://github.com/aws-samples/amazon-rds-init-cdk.git
27+
- Install NPM dependencies on project directory:
28+
```
29+
npm install
30+
```
31+
- Deploy the solution on your configured AWS account:
32+
```
33+
cdk deploy
34+
```
35+
36+
> NOTE: For demo purposes, the example CDK stack `demos/rds-init-example.ts` creates a new VPC/Subnets to provision the RDS instance and Lambda funtions. In case you would prefer to re-use existing VPC and Subnets, you can easily do so by importing an existing VPC resource: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.Vpc.html#static-fromwbrlookupscope-id-options
37+
38+
#### Cleanup
39+
To avoid incurring future charges, delete the provisioned CDK Stack and related resources. This can be done by executing the following command and subsequent steps:
40+
```
41+
cdk destroy
42+
```
43+
1944
## Technical implementation
2045
In order to achieve custom logic execution during the deployment flow of a CDK stack, we make use of CloudFormation Custom Resources. In the context of CDK, we use the `AwsCustomResource` construct to invoke a deployed lambda containing the RDS initialization logic (execute SQL scripts).
2146

@@ -140,7 +165,6 @@ export class RdsInitStackExample extends Stack {
140165
})
141166
}
142167
}
143-
144168
```
145169

146170
#### Configuration options
@@ -183,7 +207,7 @@ The initializer function will be executed under one the following circumstances:
183207

184208
## Useful CDK commands for this repository
185209

186-
- `cdk deploy` Deploy the example `rds-init-example` Stack to your default AWS account/region
210+
- `cdk deploy` Deploy the CDK stack to your default AWS account/region
187211
- `cdk diff` Compare deployed stack with current local state
188212
- `cdk synth` Generates a synthesized CloudFormation template
189213

0 commit comments

Comments
 (0)