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_nameCreate and manage cryptographic keys such as rds encryption key for easy integration to a wide range of AWS services.
npm run buildcompile typescript to jsnpm run watchwatch for changes and compilenpm run testperform 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 bootstrapDeploys the CDK Toolkit stack, required to deploy stacks containing assetscdk deployDeploys the specified stack(s)cdk deploy '*'Deploys all stacks at oncecdk destroyDestroys the specified stack(s)cdk destroy '*'Destroys all stacks at oncecdk diffCompares the specified stack with the deployed stack or a local CloudFormation templatecdk metadataDisplays metadata about the specified stackcdk initCreates a new CDK project in the current directory from a specified templatecdk contextManages cached context valuescdk docs (doc)Opens the CDK API reference in your browsercdk doctorChecks your CDK project for potential problems
As this cdk stack will using AWS Key Management Service, please refer the following link for pricing