Run these steps the first time.
- Install Terraform and
aws cli
- Create an AWS access key and store it locally in a credentials file ( see AWS Configuration basics and Where are the configuration settings stored for more info)
- Optionally, install sops to decrypt encrypted variable files in the repository.
If you get a 403 error when deploying or destroying resources with terraform despite having configured a valid AWS
access key, you may need to set up MFA. Install both AWS CLI and jq, and make sure you have aws
and jq
in path. Then
download and execute the [get-mfa-vars.sh](https://gist.github.com/mvaaltola/0abced5790401f2454444fb2ffd4acc0)
script,
and finally run . /tmp/aws-mfa-token
to temporarily set the correct MFA environment variables in your shell.
- Decrypt
tarmo.tfvars.enc.json
by runningsops -d tarmo.tfvars.enc.json > tarmo.tfvars.json
. Alternatively, copy tfvars.sample.json to a new file calledtarmo.tfvars.json
- Create two new IAM users for CI/CD and take down the username and credentials. These users can be used to configure CD deployment from
Github. If CD is already configured, use existing users:
- User to upload frontend to S3. Fill this user in
AWS_S3_USER
part intarmo.tfvars.json
. Fill credentials in Github secretsAWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
. - User to update lambda functions. Fill this user in
AWS_LAMBDA_USER
part intarmo.tfvars.json
. Fill credentials in Github secretsAWS_LAMBDA_UPLOAD_ACCESS_KEY_ID
andAWS_LAMBDA_UPLOAD_SECRET_ACCESS_KEY
.
- User to upload frontend to S3. Fill this user in
- Change the values in
tarmo.tfvars.json
as required - Create zip packages for the lambda functions by running
make build-lambda -C ..
(this has to be done only once since github actions can be configured to update functions).
To launch the instances, run the following commands:
terraform init
terraform apply --var-file tarmo.tfvars.json
Note: Setting up the instances takes a couple of minutes.
Take down the following outputs:
- frontend_route53_dns_record
- tileserver_route53_dns_record
Shut down and destroy the instances with terraform destroy --var-file tarmo.tfvars.json
You can interact with the lambda functions using the Makefile.
For example populate first few pages from Lipas with
make populate-lipas