Use this CDK stack to create an encryption key for the RDS database.
Create and manage cryptographic keys and control their use across a wide range of AWS services and in your applications.
- Deploy an encryption key for the RDS database.
You will need the following before utilize this CDK stack:
- AWS CLI
- AWS Account and User
- Node.js
- IDE for your programming language
- AWS CDK Tookit
- AWS Toolkit VSCode Extension
Define project-name and env context variables in cdk.json
{
"context": {
"project-name": "container",
"env": "dev",
"profile": "devopsrepo"
}
}
Get projectName and env from context variables
const projectName = this.node.tryGetContext('project-name');
const env = this.node.tryGetContext('env');
Create encryption key for RDS database
const rdsKey = new kms.Key(this, 'RdsKey', {
alias: `${projectName}/${env}/rds`,
description: 'Encryption key for RDS',
enableKeyRotation: true,
removalPolicy: cdk.RemovalPolicy.DESTROY
});
- alias - Define alias name for this encryption key.
- description - Define description for this encryption key.
- enableKeyRotation - Allow AWS KMS rotates the key.
- removalPolicy - Destroy this key when destroying this stack.
Deploy the stack to your aws account.
cdk deploy
or
cdk deploy --profile your_profile_name
Create and manage cryptographic keys such as rds encryption key for easy integration to a wide range of AWS services.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit tests
cdk list (ls)
Lists the stacks in the appcdk synthesize (synth)
Synthesizes and prints the CloudFormation template for the specified stack(s)cdk bootstrap
Deploys the CDK Toolkit stack, required to deploy stacks containing assetscdk deploy
Deploys the specified stack(s)cdk deploy '*'
Deploys all stacks at oncecdk destroy
Destroys the specified stack(s)cdk destroy '*'
Destroys all stacks at oncecdk diff
Compares the specified stack with the deployed stack or a local CloudFormation templatecdk metadata
Displays metadata about the specified stackcdk init
Creates a new CDK project in the current directory from a specified templatecdk context
Manages cached context valuescdk docs (doc)
Opens the CDK API reference in your browsercdk doctor
Checks your CDK project for potential problems
As this cdk stack will using AWS Key Management Service, please refer the following link for pricing