CI Deployment
Last updated
Last updated
This guide outlines the essential steps for deploying the AWS Data Stack Template in a production environment.
A best practice when deploying with Terraform is to create dedicated credentials that Terraform will use during the deployment.
Terraform should only use these users and have the minimal rights required.
For AWS, we provide ready-to-use policies and scripts to create users with your admin account quickly.
This script will:
create a new user called <ENVIRONMENT>_AWS_ADMIN
assign him this
create files .env.<environment>.secrets
and .env.<environment>.variables
The default version of the template does not contain a CICD.
To add it, run:
The GitHub Actions workflow requires AWS credentials to deploy the project.
You must, therefore, create the necessary variables and secrets in your GitHub repository.
If you have the GitHub CLI installed and are authorized for your repository, run the following commands from the project root:
This command will automatically create the required variables in GitHub based on your AWS profile and the .env files you previously created.
Alternatively, you can manually set them up in the GitHub console.
That's it; you are now ready to deploy.
You must use a dedicated S3 bucket to store the Terraform state for production deployment.
To create the bucket, run the following command:
This command will:
Create a new S3 bucket named <environment>-<aws-region>-terraform-state-bucket
.
Configure the appropriate bucket policies and enable encryption and versioning.
If you have deployed the template using the Quick Start guide (with a local state).
You can either:
Destroy and start fresh
terragrunt run-all destroy
Migrate the state:
export AWS_REGION=<bucket_region>
export ENVIRONMENT=<env>
terragrunt run-all init -migrate-state -input=true
The CI pipeline runs on every merge to the main branch and deploys to the environment defined in the variables.
The CI pipeline will start automatically once you push your changes to the repository.
The CI pipeline consists of two jobs:
Terragrunt-apply: Deploys the infrastructure using Terragrunt
Deploy-dockers: Builds and deploys Docker containers in pipelines/ingest
and pipelines/transform
.Only the folders with changes will be processed if the CI pipeline runs after a merge.
After deployment is complete, verify the setup in your AWS console:
Navigate to the AWS Step Functions service
Locate your pipeline's step function (e.g., prod-chess-step-function
)
Execute the step function with an empty payload
Monitor the execution to ensure the pipeline runs successfully
Perform schema migration: it runs the command make migrate
in all pipelines/ingest/*-schema
folders. (see )