{"id":21693208,"url":"https://github.com/eunchurn/terraform-ecs-codeploy-blue-green","last_synced_at":"2026-05-19T14:36:24.912Z","repository":{"id":61582738,"uuid":"552774405","full_name":"eunchurn/terraform-ecs-codeploy-blue-green","owner":"eunchurn","description":"Terraform ECS Fargate API with Prisma Blue-Green Deployment, CodePipeline, CodeBuild, CodeDeploy, CodeStar(Github), RDS(Serverless PostgreSQL), ALB, Route53, AutoScaling","archived":false,"fork":false,"pushed_at":"2023-12-15T08:53:19.000Z","size":40,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-07T01:03:06.466Z","etag":null,"topics":["acm","alb","blue-green-deployment","codebuild","codedeploy","codepipeline","ecs-cluster","ecs-fargate","ecs-service","postgresql","prisma-orm","rds-aurora","rds-postgres","rds-serverless","route53","secrets-manager","ssm","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eunchurn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-10-17T07:56:42.000Z","updated_at":"2024-11-25T11:21:09.000Z","dependencies_parsed_at":"2025-03-20T14:04:03.225Z","dependency_job_id":"fa773866-864e-47fd-8737-b9cabdf7e35f","html_url":"https://github.com/eunchurn/terraform-ecs-codeploy-blue-green","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eunchurn/terraform-ecs-codeploy-blue-green","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eunchurn%2Fterraform-ecs-codeploy-blue-green","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eunchurn%2Fterraform-ecs-codeploy-blue-green/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eunchurn%2Fterraform-ecs-codeploy-blue-green/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eunchurn%2Fterraform-ecs-codeploy-blue-green/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eunchurn","download_url":"https://codeload.github.com/eunchurn/terraform-ecs-codeploy-blue-green/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eunchurn%2Fterraform-ecs-codeploy-blue-green/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273983110,"owners_count":25202095,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["acm","alb","blue-green-deployment","codebuild","codedeploy","codepipeline","ecs-cluster","ecs-fargate","ecs-service","postgresql","prisma-orm","rds-aurora","rds-postgres","rds-serverless","route53","secrets-manager","ssm","terraform"],"created_at":"2024-11-25T18:18:53.784Z","updated_at":"2026-05-19T14:36:24.840Z","avatar_url":"https://github.com/eunchurn.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform ECS Fargate API with Prisma Blue-Green Deployment\n\n[Blog post](https://www.eunchurn.com/blog/development/2022-10-16-tWIL-Terraform)\n\nThe Infrastructure as Code for ECS Fargate API with Prisma ORM, PostgreSQL, Secret Manager, CodePipeline, CodeBuild, CodeDeploy, Route53, ACM, SSM, ALB\n\n## Terraform installation\n\n### Terraform install for Apple Silicon\n\n[Reference](https://discuss.hashicorp.com/t/template-v2-2-0-does-not-have-a-package-available-mac-m1/35099/4)\n\n- 1. Remove any existing Terraform binary (/usr/bin/terraform and/or /usr/local/bin/terraform)\n- 2. Install [m1-terraform-provider-helper](https://github.com/kreuzwerker/m1-terraform-provider-helper)\n  - 2.1. `brew install kreuzwerker/taps/m1-terraform-provider-helper`\n- 3. Install Terraform\n  - 3.1. `brew tap hashicorp/tap`\n  - 3.2. `brew install hashicorp/tap/terraform`\n- 4. Install the hashicorp/template version v2.2.0\n  - 4.1. `m1-terraform-provider-helper activate`\n  - 4.2. `m1-terraform-provider-helper install hashicorp/template -v v2.2.0`\n\n```\n➜  ~ terraform --version\nTerraform v1.3.1\non darwin_arm64\n+ provider registry.terraform.io/hashicorp/aws v4.33.0\n+ provider registry.terraform.io/hashicorp/random v3.4.3\n+ provider registry.terraform.io/hashicorp/template v2.2.0\n```\n\n## Initial setting state\n\n- 초기에는 `default` workspace 를 사용한다.\n- `terraform.tfstate`와 `.terraform.lock.hcl`을 Remote로 관리하기 위해 상태관리 인프라를 먼저 배포하고 Terraform을 backed 설정을 변경한다. =\u003e 아래 코드만 남기고 모두 주석 처리\n\n```hcl\nlocals {\n  availability_zones = [\"${var.region}a\", \"${var.region}b\", \"${var.region}c\"]\n}\n\nprovider \"aws\" {\n  region = var.region\n}\n\nmodule \"terraform_state\" {\n  source                               = \"./modules/terraform-state\"\n  s3_terraform_state_bucket_name       = \"mystack-terraform-running-state\"\n  s3_terraform_state_key               = \"global/s3/terraform.tfstate\"\n  dynamodb_terraform_state_locks_table = \"mystack-terraform-running-locks\"\n}\n\n```\n\n- 이후 아래 Terraform backend 설정하고 `terraform init`으로 S3로 백엔드를 설정한다.\n\n```hcl\n terraform {\n   backend \"s3\" {\n     bucket = \"mystack-terraform-running-state\"\n     key    = \"global/s3/terraform.tfstate\"\n     region = \"ap-northeast-2\"\n     dynamodb_table = \"mystack-terraform-running-locks\"\n     encrypt        = true\n   }\n }\n```\n\n- 이후 `terraform_state` 모듈은 주석처리하고 Workspace를 생성하여 각 스테이징 환경에 따라 State를 나누는 과정을 한다. ex) `dev`\n\n```\nterraform workspace new dev\nterraform apply\n```\n\n- Apple Silicon Mac의 경우 Lock을 다음으로 업데이트한다. `terraform providers lock -platform=linux_amd64`\n- 이후 주석처리한 모든 module들을 해제하고 각 워크스페이스를 `terraform workspace select` 명령을 통해 체크아웃한 후 배포 한다.\n\n## CodeStar Connection\n\nGitHub 리포 연결을 위해서는 콘솔에서 직접 연결해야 함. CodePipeline 에서 Setting\n\n`terraform apply` 이후\n\nCodePipeline \u003e Settings \u003e Connections\n\nStatus = Pending 인 커넥션 선택 후 `Update pending connection` 으로 Github 연결\n\n## Workspace Migration\n\n\u003chttps://stackoverflow.com/questions/66979732/in-terraform-is-it-possible-to-move-to-state-from-one-workspace-to-another\u003e\n\n# Terraform Workspace\n\n## Check workspace\n\n```\nterraform workspace list\n```\n\n- `dev`: 개발 인프라\n- `staged`: E2E 테스트 인프라\n- `prod`: Production 인프라\n\n## Select workspace\n\n- `dev` 워크스페이스 선택\n\n```\nterraform workspace select ${workspace name}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feunchurn%2Fterraform-ecs-codeploy-blue-green","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feunchurn%2Fterraform-ecs-codeploy-blue-green","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feunchurn%2Fterraform-ecs-codeploy-blue-green/lists"}