Skip to content

almmiko/aws-previews-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Infrastructure for Preview Environments terraform aws

The AWS infrastructure for showcasing How to Build Preview Environments for Modern CI/CD Workflows Using Terraform CDK.

You will deploy Create React App, but you can replace the app with any other front-end framework.

The AWS infrastructure is managed using Terraform Cloud Development Kit.

Getting Started

Install terraform CLI.

To install Terraform CDK run:

npm install --global cdktf-cli@latest

Create an AWS profile with permission to have access to:

  • IAM
  • S3
  • CloudFront
  • VPC
  • Lambda
  • LambdaExecute
  • Route53
  • CertificateManager

Install dependencies:

cd terraform
npm i

Configuration

In terraform/main.ts file add your configuration:

const configuration = {
    BUCKET_NAME: "",
    AWS_REGION: "",
    AWS_PROFILE: "",
    DOMAIN_NAME: "",
    WILCARD_DOMAIN_NAME: "",
};

To build the example app

cd app
npm i
npm run build

To upload the example app, replace placeholder values in the terraform/utils/s3-upload.js file and run:

npm run s3:upload

Commands

To run deployment plan:

npm run plan

To deploy resources:

npm run deploy

To synthesize infrastructure configuration:

npm run synth

To destroy deployed resources:

npm run destroy

⚠️ Lambda@Edge can't be destroyed in one run. Wait until AWS removes replicas and re-run destroy command.

License licence-MIT

This project is licensed under the MIT License - see the LICENSE file for details.