{"id":18573168,"url":"https://github.com/localstack-samples/multi-iac-devops","last_synced_at":"2025-04-10T07:31:51.827Z","repository":{"id":191229800,"uuid":"680238639","full_name":"localstack-samples/multi-iac-devops","owner":"localstack-samples","description":"Sample shows using IaC to deploy S3 bucket to LocalStack and AWS in local DevOps env","archived":false,"fork":false,"pushed_at":"2024-05-13T11:46:19.000Z","size":2587,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-03-24T18:06:37.781Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/localstack-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-18T17:25:23.000Z","updated_at":"2025-01-15T20:08:23.000Z","dependencies_parsed_at":"2024-03-20T19:54:15.229Z","dependency_job_id":"cc5ab140-e8db-4215-ae0d-265c8dac19bd","html_url":"https://github.com/localstack-samples/multi-iac-devops","commit_stats":null,"previous_names":["localstack-samples/multi-iac-devops"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localstack-samples%2Fmulti-iac-devops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localstack-samples%2Fmulti-iac-devops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localstack-samples%2Fmulti-iac-devops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localstack-samples%2Fmulti-iac-devops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/localstack-samples","download_url":"https://codeload.github.com/localstack-samples/multi-iac-devops/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248176389,"owners_count":21060058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T23:08:15.505Z","updated_at":"2025-04-10T07:31:51.268Z","avatar_url":"https://github.com/localstack-samples.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi-IaC Pipeline Solution\n\nExample with multiple IaC pipelines to setup a basic AWS solution with Terraform CDK, AWS CDK, and Pulumi.\nThe purpose of this sample is to\n\n1. Demonstrate a standard directory layout for IaC, src code\n2. Demonstrate DevOps environment configuration that supports CI pipelines that deploy to LocalStack and AWS\n3. Demonstrate DevOps tooling with multiple flavors of IaC\n4. Demonstrate integration tests running against solutions deployed to LocalStack\n5. Demonstrate Typescript Lambda Hot Reloading in LocalStack\n\n## Multi-IaC DevOps APIGW Lambda Solution\n\nFeatures deploying an HTTP API Gateway, Lambda, as well as S3 and other resources.\n\n![APIGW Solution](./docs/img/solution-diags-overview.drawio.png \"APIGW Solution\")\n\n## Multi-IaC DevOps Private Application Load Balancer to Lambda Solution\n\nFeatures deploying a VPC, Private Application Load Balancer (ALB), and Lambda.\n\n![ALB Solution](./docs/img/solution-diags-priv-alb.drawio.png \"ALB Solution\")\n\n## Cloudfront S3 React UI Solution with Jest Test\n\nFeatures deploying a Cloudfront distribution, S3 bucket, and a React web app.\nCheckout the test [here](./auto_tests/jest/cloudfront.test.ts).\nThe Terraform pipeline is [here](./iac/terraform/hcl/react-ui/main.tf).\n\n![Cloudfront Solution](./docs/img/solution-diags-cloudfront-jest.drawio.png \"Cloudfront Solution\")\n\n## Private Jumphost on Private VPC Subnet Solution\n\nFeatures using private jumphost in private VPC for secure access to protected resources.\nThis jumphost does not have a public IP and does not allow any inbound network traffic.\n\n![Private Jumphost Solution](./docs/img/solution-diags-priv-jumphost.drawio.png \"Private Jumphost Solution\")\n\n## Cloud Infrastructure, Platform, Solution Layers\n\nAWS Customers build cloud-based solutions in layers 3-5. DevOps CI pipelines can also be broken down separately\nalong layer boundaries. The [Terraform CDK main.ts](./iac/terraform/cdk/main.ts) file has App solution pipelines\nat layer 5 and account level VPC configuration pipelines at level 3.\n\n![Cloud Arch Layers](./docs/img/solution-diags-layers.drawio.png \"Cloud Arch Layers\")\n\n# Deploying the App to LocalStack\n\nTo deploy your infrastructure, follow the steps below.\n\n### Prerequisites\n\n1. [Install unzip](https://www.tecmint.com/install-zip-and-unzip-in-linux/)\n\n2. [Install LATEST AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)\n\n3. [Install Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli)\n\n4. [Install JQ](https://jqlang.github.io/jq/download/)\n\n5. [Install Docker](https://docs.docker.com/engine/install/)\n\n6. [Install Node Version Manager (NVM)](https://github.com/nvm-sh/nvm#installing-and-updating)\n\n7. Select Node version 18\n\n```shell\nnvm install 18\n```\n\n8. Install Terraform CDK\n   Install cdktf in the node 18 version you just installed in step (4).\n\n```shell\nnpm install --global cdktf-cli@^0.18.0\n```\n\n9. Install `make`, `gcc`, `g++`, etc. For MacOS, run `brew install make gcc openssl readline sqlite3 xz` and for Ubuntu\n   machines\n   run `apt install build-essential libbz2-dev libssl-dev libreadline-dev libffi-dev zlib1g-dev libsqlite3-dev liblzma-dev`.\n\n10. Install `zlib1g-dev`. For MacOS, run `xcode-select --install` and for Ubuntu machines run `apt install zlib1g-dev`.\n\n11. [Install Pyenv](https://github.com/pyenv/pyenv#installation). Make sure\n    the [prerequisites](https://github.com/pyenv/pyenv/wiki/Common-build-problems#prerequisites) are also there.\n\n### Steps\n\nFrom the working directory:\n\n1. Set your LocalStack pro key. Add this line of code to a file named `.env-gdc-local` at the root of this project. Set\n   your actual LocalStack key.\n\n      ```bash\n      export LOCALSTACK_AUTH_TOKEN=\u003cyour key\u003e\n      ```\n\n2. Start LocalStack.\n\n      ```bash\n      make start-localstack\n      ```\n\n![Start LocalStack](./docs/img/start-localstack.png \"Start LocalStack\")\n\n3. Setup an AWS_PROFILE for LocalStack.\n\n#### Add this to your `~/.aws/config` file\n\n```text\n[profile localstack]\nregion=us-east-1\noutput=json\nendpoint_url = http://localhost:4566\n```\n\n#### Add this to your `~/.aws/credentials` file\n\n```text\n[localstack]\naws_access_key_id=test\naws_secret_access_key=test\n```\n\n4. Setup the virtual Python environment.\n\n```sh\npyenv install 3.11 \u0026\u0026 \\\n   pyenv local 3.11 \u0026\u0026 \\\n   python -m venv .venv \u0026\u0026 \\\n   . .venv/bin/activate \u0026\u0026 \\\n   pip install -r devops-tooling/requirements.txt\n```\n\n# IaC Pipelines\n\n## Terraform CDK Instructions\n\n[Solution Guide for Terraform CDK](./docs/README-cdktf.md \"Solution Guide for TerraformCDK\")\n\n## AWS CDK\n\n[Solution Guide for AWS CDK](./docs/README-awscdk.md \"Solution Guide for AWS CDK\")\n\n## Pulumi Instructions (Work in Progress)\n\n[Solution Guide for Pulumi](./docs/README-pulumi.md \"Solution Guide for Pulumi\")\n\n# Tests\n\nFirst export the following env vars:\n\n```bash\nexport LOCALSTACK_AUTH_TOKEN=\u003cauth-token\u003e\nexport DOCKER_COMPOSE_FLAGS=\"--build\"\nexport BUILDKIT_PROGRESS=plain\n```\n\nAnd then run the AWS CDK and the Terraform-based AWS CDK deployments:\n\n```\nexport CI_TEST_NAME=awscdk make run-ci-test\nexport CI_TEST_NAME=awscdktf make run-ci-test\n```\n\n***Note: If you run the above tests with Rosetta turned on, and still want to go with `arm64`, you need to\nexport `export OVERRIDE_LOCAL_ARCH=arm64`.***\n\n# Hot Reloading!\n\nThe Lambda is setup for hot reloading in this project on LocalStack by default. After everything is deployed by\nfollowing one of complete\nIaC deployments above, you can work with the Lambda in hot-reload mode.\nSee [LocalStack Hot Reloading](https://docs.localstack.cloud/user-guide/tools/lambda-tools/hot-reloading)\n\nNow, your DevX looks like a rapid TDD cycle. There's a test in `auto_tests/test_apigw_name.py`.\nRun watch to do a build whenever code changes in the Lambda.\n\n```shell\nmake watch-lambda\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalstack-samples%2Fmulti-iac-devops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocalstack-samples%2Fmulti-iac-devops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalstack-samples%2Fmulti-iac-devops/lists"}