Sometimes clicking through the UI is challenging and prone to mistakes. Use Terraform and custom modules to apply the same changes!
If you're starting fresh, check out fresh-start before beginning with this exercise.
- Install dependencies
- Ensure that you have an existing S3 bucket, data sources, and artifacts (main.py, .egg). If not check out fresh-start.
- Delete all manually created resources from the
data-ingestionanddata-transformationsections if you created them in a previous exercise (e.g. Glue Job, Crawler, IAM roles) - Ensure you have an active AWS CLI Session
- Install Python (version 3.7), for example with Pyenv
- Install Terraform (required version 1.1.3)
docker run -it -v $(pwd):/app ghcr.io/data-derp/python-aws-terraform-container:master bashAll workloads can be run within this container once you have set up an active AWS CLI Session
cd iac/data-ingestion
# Change these variables
export PROJECT_NAME=awesome-project
export MODULE_NAME=awesome-module
export AWS_DEFAULT_REGION=eu-central-1 (or another valid AWS region)
terraform init && terraform apply -var "project-name=${PROJECT_NAME}" -var "module-name=${MODULE_NAME}" -auto-approvecd iac/data-transformation
# Change these variables
export PROJECT_NAME=awesome-project
export MODULE_NAME=awesome-module
export AWS_DEFAULT_REGION=eu-central-1
terraform init && terraform apply -var "project-name=${PROJECT_NAME}" -var "module-name=${MODULE_NAME}" -auto-approvecd iac/data-workflow
# Change these variables
export PROJECT_NAME=awesome-project
export MODULE_NAME=awesome-module
export AWS_DEFAULT_REGION=eu-central-1
terraform init && terraform apply -var "project-name=${PROJECT_NAME}" -var "module-name=${MODULE_NAME}" -auto-approveRun the Workflow in the AWS Console and watch it turn green!
To destroy all of the resources you created using Terraform, run this from the root of the repository:
export AWS_DEFAULT_REGION=eu-central-1
for p in data-workflow data-transformation data-ingestion
do
pushd "./iac/${p}" > /dev/null
terraform destroy -var "project-name=${PROJECT_NAME}" -var "module-name=${MODULE_NAME}" -auto-approve
popd > /dev/null
done