
Hello! My name is Tofig, and I am excited to teach you how to create continuous delivery pipelines on AWS using real code with CDK.
In this course we will create a pipeline that will deploy a demo application. We will start from scratch so you will be able to follow along and I highly recommend that you do, as I think that will make learning more fun and effective.
Before we jump into the course, I would like to remind you that there are several ways you can get help along the way. If at any point you get stuck or have questions, check the Q&A section of the lecture to see if anyone else already had this question. You can also send me a direct message on Udemy by going to profile and clicking “Send Message”. Finally, you can also email me directly on my email here. This is my first course on Udemy, and I am eager to get feedback, so if you feel that some lecture is hard to understand or can be improved, please let me know and I will do my best to improve the course.
Finally, I would like to remind you that all code written throughout this course can be found in these GitHub repos, so if you get stuck or need a reference, you can find the code with all the commits in there. Each lecture where we write code will additionally include link to the source code at that particular commit.
Now that introductions are done, let’s jump into the course and learn!
In this lecture we will:
Create AWS Budget to track our spending
Set up a notification when total AWS cost goes above the budget
In this lecture we will:
Use CDK CLI to create our CDK project
Deploy our project on AWS
Prerequisite instructions:
Creating new AWS account: https://aws.amazon.com/free
Installing AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
Creating IAM User (needed to set up local credentials): https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html
Configuring AWS CLI credentials: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-methods
Installing NPM: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
Installing AWS CDK: https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html#getting_started_install
In this lecture we will:
Learn about CDK app, stack, and construct concepts
Understand difference between L1, L2, and L3 constructs
Understand how CDK code is converted into AWS resources
In this lecture we will:
Learn about typical CDK project code structure
Understand why CDK dependencies need to be under devDependencies
Understand how CDK resource tree is created and where the entry point to our application is
In this lecture we will:
Create new Budget CDK construct that encapsulates L1 CfnBudget construct, exposing only properties that we want to control
Create new Billing stack with new Budget construct
Learn how to use CDK and CloudFormation documentation
In this lecture we will:
Write unit tests for CDK constructs that verify specific properties
Write snapshot testing for CDK stacks
In this lecture we will:
- Discuss in high level the pipeline that we want to build in this course
- Discuss the first milestone that we are going to accomplish in this section
In this lecture we will:
- Understand what CodePipeline stages and actions are
- Discuss how actions communicate with each other via Artifacts
In this lecture we will:
Create GitHub token to provide access for CodePipeline
Create Pipeline with a Source action that reads from our GitHub repo
In this lecture we will:
Add new 'Build' stage to our pipeline with 'CodeBuild' action that builds our CDK source code
Learn how to write simple CodeBuild build specification file
Deploy our pipeline and see it in action
In this lecture we will:
Add new "Pipeline Update" stage to our pipeline that deploys pipeline template via CloudFormation
Deploy changes and verify that everything works
In this lecture we will:
Add unit test to the CDK build action and observe what happens when build fails
Understand why storing build-specs in a separate file is better than storing them inline in CDK
Fix pipeline CDK unit test and unblock the pipeline
In this lecture we will:
Use jest-junit to generate junit XML test reports for jest
Configure our build specs to extract jest test reports to make user friendly reporting in CodeBuild
In this lecture we will review our objectives for the section and go over changes that we will make to our pipeline
In this lecture we will:
Create a new node project and write a basic express server
Wrap this server using serverless-express helper to make it usable within lambda
Test that our server is working locally
Push changes to a new GitHub repository
In this lecture we will create a new service stack that contains:
Lambda function
API-Gateway HTTP API with Proxy integration that redirects all requests to Lambda
In this lecture we will update our pipeline to add a new source action so that it listens to changes in the service code repository
In this lecture we will:
Add service build action to the build stage of our pipeline
Create build specs for our service code inside service package
Learn about restartExecutionOnUpdate property of Pipeline CDK construct that removes the need to manually restart pipeline when its changed
In this lecture we will:
Refactor our PipelineStack to support adding multiple service stages
Learn how to override CloudFormation input parameters when deploying service stack
Add production stage to our pipeline
Deploy service and verify that it works
In this lecture we will:
Add test for the new addServiceStage method in our PipelineStack
Learn how to write more fine-grained tests using fuzzy property matching with CDK assert library
In this lecture we will:
Add new method to our PipelineStack for adding a billing stack to a pipeline stage
Add unit tests for the new method
Use the new method to add Billing stack deployment to our production stage
In this lecture we will review our current pipeline state and discuss what we want to achieve by the end of this section
In this lecture we will:
Modify ServiceStack class to support creating multiple instances without causing name clashes
Add a new "Test" stage to our pipeline which deploys another instance of ServiceStack
In this lecture we will write a basic integration test using axios library to call our service endpoint and verify that it returns expected response.
In this lecture we will:
Update our pipeline to create integration test action inside the test stage
Learn how we can pass service endpoint from the service stack to the pipeline stack without creating backwards dependency
In this lecture we will learn how to send emails on failures in pipeline by reacting to state changes in CodePipeline at action, stage, or pipeline levels. We will also learn how to filter out events using EventBridge rules and forward them to emails via SNS topics.
In this lecture we will discuss why gradual deployments and canaries are useful, and what we want to achieve in this section
In this lecture we will update our CDK to the latest version, as 1.99 has a bug, which was fixed in later versions (https://github.com/aws/aws-cdk/issues/14503) that would have prevented us from creating alarm on API-G errors.
In this lecture we will learn how to use CodeDeploy deployment groups and Lambda function aliases to create gradual deployments with weighted traffic routing.
In this lecture we will:
Configure auto-rollback on our lambda deployment group based on attached alarms
Attach service error alarm to our deployment group
Test our rollback by pushing bad commit to our service code
In this lecture we will discuss why we need Canaries and how we can use CloudWatch Synthetics service to create canaries that generate synthetic traffic to our service endpoints.
In this lecture we will learn how to write a basic canary lambda that validates that API returns successful (200) response using built-in Synthetics library that comes as part of CloudWatch Synthetics runtime environment.
For more details on what helpers are available for CloudWatch Synthetics canaries see links attached to this lecture
In this lecture we will create a reusable CDK construct called ServiceHealthCanary that creates a Canary, which runs every minute for 5 minutes, after each deployment.
In this lecture we will write a unit test for our ServiceHealthCanary construct that will validate that we create correct CloudFormation resource and that api endpoint environment variable is passed correctly. See attached resources for a link to the CloudFormation page for AWS::Synthetics::Canary resource
In this lecture we will:
Use our newly created ServiceHealthCanary construct inside Service stack to create a new canary
Deploy our changes and validate that canary is running as expected
In this lecture we will add alarm that will trigger if canary fails and will send us an email notification
In this lecture we will discuss why multi-region deployments are needed, how they work, and what we want to achieve in this section
In this lecture we will:
Explicitly specify account and region when creating stacks
Explicitly specify account and region in CodePipeline actions
Bootstrap new environment using CDK
Create cross-region support stack using CDK
In this lecture we will discuss how cross-account deployment pipelines work and what the benefits of separating stages into different accounts are
In this lecture we will:
Bootstrap second account using new style cdk bootstrap
Add new stage to our pipeline that deploys service to another account
Deploy the changes and validate that cross-account deployments succeed
In this lecture we will:
Discuss why we need to migrate to CDK v2
Go through differences between CDK v1 and v2
In this lecture we will:
Update our dependencies in package.json
Update cdk.json configuration file
Fix imports in our source code
In this lecture we will:
Fix imports in unit tests
Learn how to use Template and Match utilities in CDK unit tests
Complete CDK v2 migration
In this lecture we will learn how to delete all AWS resources that were created as part of this course
Congratulations for reaching the end of this course! We've covered a lot of topics, and I hope that you will be able to apply at least some of what you learned in your work. CDK is evolving very fast, and they keep releasing new features and high level constructs all the time. Even in the few months that it took me to complete this course, CDK went from version 1.99 to 1.111. CDK version 2 is already in beta and new CDKPipelines construct, which is supposed to significantly improve pipeline management, is already in developer preview.
Moreover, as it's open sourced, we are seeing more and more 3-rd party solutions. I wouldn't be surprized if by the time you're watching this video, there are significant improvements to creating continuous delivery pipelines on CDK. Nevertheless, I think that what you've learned in this course will remain useful, as it teaches some of the fundamentals around how CDK and AWS services like CodePipeline and CodeBuild work. My hope is that as new versions and improvements emerge, you will have enough foundational knowledge to understand whether and how these changes are applicable to your use cases.
Thank you for taking your time to watch this course and congratulations again for getting to the end! Happy building!
Want to build awesome continuous delivery pipelines using real code instead of json and yaml files? You'll learn that in this couse
How about adding automated integration tests? Want to spice that up with gradual deployments, synthetic traffic, and multi-region/multi-account deployments! This course has got you covered!
Thinking of starting a new project and want to embrace continuous integration? You've got to have CD pipeline for that, and I'll teach you how to create one!
--------
Welcome to my course! My name is Tofig and I am a software developer and a Solution Architect with over 6 years of experience building on AWS.
In this course we will learn how to build continuous deployment pipelines on AWS. Our pipeline will pick up changes from the repository, build them, and deploy through a series of steps, such as deployment to test and production environments. And the great thing is that we will build all this deployment infrastructure in a real programming language, Typescript, using AWS Cloud Development Kit. CDK is a game changer for infrastructure development, as it allows us to define cloud infrastructure in a reusable and composable way.
Deployment automation is a highly demanded skill, especially in the world of microservices. In this course you will learn skills that will boost speed and quality of your deployments. As a result, you and your team will work faster and more efficiently.
This course is going to be very hands-on. Together, we will take a demo application and build a fully automated pipeline for it from scratch. We will start with a simple pipeline that takes changes from the repository, builds them and deploys to production. Then we will gradually increase complexity by adding more functionality to it. For example, we will add deployment to test environment, automated testing, monitoring, alarming, and rollbacks. You will learn how to work with AWS services such as CodePipeline, CodeBuild, and CodeDeploy. You will also learn how to use AWS CDK to define AWS infrastructure using a real code, with compile time checks and unit testing.
We are going to explore every step of the way in details to make sure that you understand exactly what and why we are building and how it all works. We will build everything in a scalable and production ready way, without taking any shortcuts, so that you can take what you learned and apply it in your daily work immediately. Every topic we cover will include explanation of how and when it can be applied in a real world scenario, so that you are able to make right decisions in your own projects. All the code is available for you on GitHub, so that you can refer to it if needed.
So sign up now and become a continuous deployment master, taking you and your team to the next level of development experience!