You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-4Lines changed: 28 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,41 @@ The source code and documentation in this repository describe how to support Ama
6
6
> 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.
7
7
8
8
### Potential use cases
9
-
- Initialize databases with their corresponding schema or table structures.
9
+
- Initialize databases.
10
10
- Initialize/maintain users and their permissions.
11
11
- Initialize/maintain stored procedures, views or other database resources.
12
12
- 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)
13
16
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
15
20
- Node.js v14+ installed on your local machine: https://nodejs.org/en/download/
16
21
- Docker installed on your local machine: https://docs.docker.com/get-docker/
17
22
- CDK v1.122+ installed and configured on your local machine: https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html
- 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
+
19
44
## Technical implementation
20
45
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).
21
46
@@ -140,7 +165,6 @@ export class RdsInitStackExample extends Stack {
140
165
})
141
166
}
142
167
}
143
-
144
168
```
145
169
146
170
#### Configuration options
@@ -183,7 +207,7 @@ The initializer function will be executed under one the following circumstances:
0 commit comments