« Previous 1 2 3 4 5
The AWS CDK for software-defined deployments
Dreaming of Clouds
Just Build It, Already
From your (AWS authenticated) CLI in the root of the project, run:
$ npm run build $ cdk deploy -c ENV=qa
You will get some absolutely beautiful log output (a small sample of my own output from a run is included in Figure 1), and within about three minutes, you'll have a VPC, subnets, routes, route tables, route table associations, and NAT gateways – all the building blocks of an AWS networking setup – neatly provisioned in your account.
Figure 2 shows the VPC section of my AWS console, which shows the VPC created by the CDK. You'll also notice that it's appropriately assigned a 10.200.0.0/16
base CIDR, as defined for any qa
environment in the cdk.json
file (Listing 5).
Cleaning Up After Yourself
You now have code to provision a well-designed VPC, so what do you do now? Tear it down! Although it might seem counterintuitive to destroy these resources, your application CDK code is not quite ready, yet. (Come back for a future installment, where I show you how to build it out.) Until that code is ready, you can reap the cost-savings benefits of your infrastructure-as-code solution by tearing it down. From your CLI, the command
$ cdk destroy -c ENV=qa
should take care of destroying these resources until you're ready to come back and add on!
Conclusion
The AWS CDK provides an extremely flexible and powerful tool to fuel infrastructure-as-code solutions in the world of cloud-powered, API-driven infrastructure hosting. Even a jaded cloud architect can appreciate the power a tool like this has, to build bridges between development and cloud operations teams, where it seems previous tools have been less successful. Even better, it provides backward compatibility with CloudFormation, if needed. With support for C#, Java, and TypeScript, it offers programmers of different backgrounds the chance to leverage its power. I highly suggest giving the AWS CDK a try for your next project.
Infos
- Google Kubernetes Engine: https://cloud.google.com/kubernetes-engine/
- Amazon EKS: https://aws.amazon.com/eks/
- Azure Kubernetes Service: https://azure.microsoft.com/en-us/services/kubernetes-service/
- AWS CloudFormation: https://aws.amazon.com/about-aws/whats-new/2011/02/25/introducing-aws-cloudformation/
- CloudFormation function reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
- Terraform announcement: https://www.hashicorp.com/blog/terraform-announcement
- Terraform license: https://github.com/hashicorp/terraform/blob/master/LICENSE
- CloudFormation drift detection: https://aws.amazon.com/blogs/aws/new-cloudformation-drift-detection/
- null_resource: https://www.terraform.io/docs/provisioners/null_resource.html
- External data sources: https://www.terraform.io/docs/providers/external/data_source.html
- Writing custom providers: https://www.terraform.io/docs/extend/writing-custom-providers.html
- Troposphere: https://github.com/cloudtools/troposphere
- Sceptre: https://sceptre.cloudreach.com/latest/
- Ansible and AWS integration: https://www.ansible.com/integrations/cloud/amazon-web-services
- AWS CDK Developer Preview: https://aws.amazon.com/blogs/developer/aws-cdk-developer-preview/
- npm: https://www.npmjs.com/
- Yarn: https://yarnpkg.com/en/
- TypeScript: https://www.typescriptlang.org/
- AWS CDK Toolkit docs: https://awslabs.github.io/aws-cdk/tools.html#command-line-toolkit-cdk
- Code for this article: ftp://ftp.linux-magazine.com/pub/listings/admin-magazine.com/49
- VPCs and subnets: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html
« Previous 1 2 3 4 5
Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
Support Our Work
ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.