{"id":26584113,"url":"https://github.com/chrispsheehan/fargate-nextjs-webapp","last_synced_at":"2025-03-23T09:18:59.556Z","repository":{"id":218121144,"uuid":"745466251","full_name":"chrispsheehan/fargate-nextjs-webapp","owner":"chrispsheehan","description":"Run nextjs in AWS with Fargage, ECS and App load balancer.","archived":false,"fork":false,"pushed_at":"2024-11-14T12:16:25.000Z","size":209,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-14T12:18:32.500Z","etag":null,"topics":["aws","cicd","ecs-fargate","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/chrispsheehan.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":"2024-01-19T11:52:36.000Z","updated_at":"2024-11-13T11:59:19.000Z","dependencies_parsed_at":"2024-02-08T20:48:29.570Z","dependency_job_id":"4ee25a02-3b51-4c9c-b785-327b60c14166","html_url":"https://github.com/chrispsheehan/fargate-nextjs-webapp","commit_stats":null,"previous_names":["chrispsheehan/fargate-nextjs-webapp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispsheehan%2Ffargate-nextjs-webapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispsheehan%2Ffargate-nextjs-webapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispsheehan%2Ffargate-nextjs-webapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispsheehan%2Ffargate-nextjs-webapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrispsheehan","download_url":"https://codeload.github.com/chrispsheehan/fargate-nextjs-webapp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245078797,"owners_count":20557361,"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":["aws","cicd","ecs-fargate","terraform"],"created_at":"2025-03-23T09:18:59.033Z","updated_at":"2025-03-23T09:18:59.551Z","avatar_url":"https://github.com/chrispsheehan.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fargate-nextjs-webapps\n\nNew image pushed to ecr upon changes detected in `/src` and subsequently deployed to ecs.\n\n## run dev locally\n\n```sh\nnpm i\nnpm run build\nnpm run start\n```\n\n## overview\n\n`/app` is the frontend (client side) code\n`/pages` is the backend (server side) code\n\n## env vars\n\n[reference](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser)\n\n`AWS_REGION` used to get ssm on server side\n\n`NEXT_PUBLIC_WOODLAND_CREATURE` is exposed to browser\n\n`API_KEY_SSM_PARAM_NAME` key to get value from ssm on refresh\n\n`STATIC_SECRET` secret injected into container on startup\n\n## terraform\n\nRequired deployment iam privileges.\n\n```json\n[\n    \"dynamodb:*\", \n    \"s3:*\", \n    \"ecr:*\", \n    \"iam:*\", \n    \"ecs:*\",\n    \"ec2:*\", \n    \"elasticloadbalancing:*\",\n    \"ssm:*\",\n    \"logs:*\"\n]\n```\n\n\n## ci\n\nCommits to `main` will kick off a deployment.\n\nRequired github action variables.\n- `AWS_ACCOUNT_ID`\n- `AWS_REGION`\n- `AWS_ROLE` role with deployment privileges\n- `AWS_ROLE_VALIDATE_ONLY` role with readonly privileges (can be same as `AWS_ROLE`)\n\n\n## gotchas\n\n- health checks failing trigging a rollback. \n  - issue: ECS will override env vars. `HOSTNAME` is required to enable a container to hit localhost for health checks.\n  - debug: local docker run health check simulation works fine.\n  - fix: \n    - add install for `curl` in dockerfile\n    - add the `HOSTNAME` env var with value `0.0.0.0` to the ECS task definition\n    - hit `http://0.0.0.0:${container_port}` in the task health check","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispsheehan%2Ffargate-nextjs-webapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrispsheehan%2Ffargate-nextjs-webapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispsheehan%2Ffargate-nextjs-webapp/lists"}