Amazon ECS deployment example using GitHub Actions and Terraform and ecspresso.
The following are available.
- A test environment is created for each pull request
- When merged into the main branch, a staging environment will be created
- Create the production environment by manually executing GitHub Actions
- GitHub's OIDC is used for authentication with AWS
Add the following to Secrets.
Name | Value |
---|---|
AWS_ACCOUNT_ID | AWS account ID |
PERSONAL_ACCESS_TOKEN | A GitHub personal access token |
DOMAIN | Domain name of the environment |
TFSTATE_BUCKET | S3 bucket to store tfstate |
SLACK_BOT_TOKEN | Slack App's Bot Token from the OAuth & Permissions page |
SLACK_CHANNEL | Slack channel name |
Add the following to Environment Variable on Local.
Name | Value |
---|---|
PERSONAL_ACCESS_TOKEN | A GitHub personal access token |
Fix the following in deploy-production.sh
for your environment.
Variable | Description |
---|---|
ORG | GitHub Organization Name |
REPO | GitHub Repository Name |
BRANCH | Branch Name |
This repository does not place workflows in .gihub/workflows
, so move workflows
under .github
.
Create a host zone for the domain.
cd terraform/common
terraform init -backend-config='bucket=<The bucket name set in TFSTATE_BUCKET>'
terraform apply -var domain='<Domain name>' -var repository='<GitHub Org/Repository name>'
I used the following as a reference.