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 1: Sample CDK log output.

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).

Figure 2: VPC section of the AWS console.

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

  1. Google Kubernetes Engine: https://cloud.google.com/kubernetes-engine/
  2. Amazon EKS: https://aws.amazon.com/eks/
  3. Azure Kubernetes Service: https://azure.microsoft.com/en-us/services/kubernetes-service/
  4. AWS CloudFormation: https://aws.amazon.com/about-aws/whats-new/2011/02/25/introducing-aws-cloudformation/
  5. CloudFormation function reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
  6. Terraform announcement: https://www.hashicorp.com/blog/terraform-announcement
  7. Terraform license: https://github.com/hashicorp/terraform/blob/master/LICENSE
  8. CloudFormation drift detection: https://aws.amazon.com/blogs/aws/new-cloudformation-drift-detection/
  9. null_resource: https://www.terraform.io/docs/provisioners/null_resource.html
  10. External data sources: https://www.terraform.io/docs/providers/external/data_source.html
  11. Writing custom providers: https://www.terraform.io/docs/extend/writing-custom-providers.html
  12. Troposphere: https://github.com/cloudtools/troposphere
  13. Sceptre: https://sceptre.cloudreach.com/latest/
  14. Ansible and AWS integration: https://www.ansible.com/integrations/cloud/amazon-web-services
  15. AWS CDK Developer Preview: https://aws.amazon.com/blogs/developer/aws-cdk-developer-preview/
  16. npm: https://www.npmjs.com/
  17. Yarn: https://yarnpkg.com/en/
  18. TypeScript: https://www.typescriptlang.org/
  19. AWS CDK Toolkit docs: https://awslabs.github.io/aws-cdk/tools.html#command-line-toolkit-cdk
  20. Code for this article: ftp://ftp.linux-magazine.com/pub/listings/admin-magazine.com/49
  21. VPCs and subnets: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html

The Author

Bradley Campbell currently consults as a cloud architect. He has experience in software engineering, DevOps, cloud architecture, and data engineering and architecture across a variety of verticals, mostly focused in finance. Bradley holds all nine AWS certifications and two of three Google Cloud certifications, is a Jenkins Certified Engineer, and is CompTIA Security+ CE certified. His programming background is primarily centered around Python, Perl, Go, and JavaScript, although he is always keen on exploring new languages and skills to add to his toolbox. You can find him at https://bradcod.es or http://@geekmuse.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



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.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=