Amazon Q Developer Workshop

Amazon Q Logo

Module 4: Deploying with AWS CDK

In this module, you'll learn how to deploy your application to AWS using the AWS Cloud Development Kit (CDK). You'll create a deployment that uses Amazon S3 for hosting your static files and Amazon CloudFront for content delivery.

Prerequisites

Step 1: Create AWS Cloud Development Kit (CDK) via CLI

  1. Add Context files to CLI
/context add *
  1. Create Infrastructure as code (IaC) -> AWS Cloud Development Kit (CDK)
Use AWS Cloud Development Kit (CDK) to implement infrastructure as code in Python by use AWS solutions to host web application in Amazon S3 private bucket and deliver web through Amazon CloudFront.
  1. Verify output

Amazon Q Developer will create CDK and provide instruction to deploy to AWS

04_cdk_created

Step 2: Deploy CDK

  1. Deploy CDK to AWS Environment
Deploy this CDK Stack
  1. Get the Amazon CloudFront URL

Amazon Q Developer will deploy CDK to AWS and show Amazon CloudFront in output terminal. URL format: XXXXXXXX.cloudfront.net

Copy Amazon CloudFront URL

04_cdk_deployed_output

Step 3: View web application in web browser

  1. Open Amazon CloudFront URL in web browser
04_cdk_deployed_view

Step 4: Explore AWS Resources

  1. Access to AWS Console
04_aws_access
  1. Navigate to Amazon CloudFront
04_cloudfront_access
  1. Explore Amazon CloudFront

Select Amazon CloudFront which have the same domain name as your web application

04_cloudfront
  1. Copy Amazon S3 Bucket name from Amazon CloudFront Origin

Goto Tab Origin then copy Amazon S3 Bucket name which locate as prefix of Original domain

04_cloudfront_to_s3
  1. Navigate to Amazon S3
04_s3_access
  1. Access to Amazon S3 Bucket

Search for your bucket and click to see the content inside your bucket

04_s3_bucket

You will see your web content is here!

04_s3_object
  1. Navigate to AWS CloudFormation
04_cloudformation
  1. Explore your AWS CloudFormation stack

This show CDK utilizes the AWS CloudFormation service to perform deployments

04_cloudformation_list

Step 5: Draw architecture diagram

  1. Generate architecture diagram in draw.io format
please generate an architecture diagram for this application that I can load on drawio
04_draw_gen
  1. Download draw.io output file
04_draw_download
  1. Open draw.io in web browser

Open via https://app.diagrams.net/

04_draw_view

Step 5: Clean up

  1. Delete all files
!rm -rf *
  1. Clear the conversation history
/clear
  1. Clear all files from current context
/context clear

(Optional) Advanced Topics: Ask anything on Amazon Q Developer!!

Setting up a custom domain name:

How do I configure a custom domain name for my CloudFront distribution using CDK?

Implementing CI/CD for automatic deployments:

How can I set up a GitHub Actions workflow to automatically deploy my Sudoku app when I push changes?

Adding monitoring and analytics:

How can I add monitoring and analytics to my deployed Sudoku application?

Conclusion

Congratulations! You've successfully:

  1. Set up Amazon Q Developer in your development environment both IDE and CLI
  2. Created a Basic Web application with Amazon Q's assistance
  3. Created documentation as README file
  4. Enhanced your application with advanced prompting techniques
  5. Deployed your application to AWS using CDK
  6. Created architecture diagram to show ouy stack

Next Steps

Congratulations! You now have a fully functional Sudoku web application deployed on AWS infrastructure and have architecture diagram ready!

In the next module, we will do some coding challege to get the prize!!!

Go to Amazon Q Developer Code Challenge! →