web3-storage / backup-infra

AWS Infrastructure managed by Terraform for running Backup Tool
1 stars 2 forks source link

Backup Infra

This project contains code to provision Cloud infrastructure for Backup tool.

Pre Requisites

Stacks

Deploy

AWS_REGION=us-west-2 TS_ENV=prod terraspace up artifactory
AWS_REGION=us-west-2 TS_ENV=prod terraspace up log

Make a first image push to registry. Also, remember to feed source CIDs bucket list (See next topic). terraspace up ecs-cluster won't work before doing so

Merge a PR to main in https://github.com/web3-storage/backup and an updated docker image is built and pushed to a private ECR repository with the tag format ${iso-date}-${short-commit-sha}.

Grab that new tag name from the workflow run (or check the ECR listing in aws console) and update backup_image_version in terraspace/app/stacks/ecs-cluster/tfvars/base.tfvars, then run terraspace up ecs-cluster

AWS_REGION=us-west-2 TS_ENV=prod terraspace up ecs-cluster

Add/Remove source data files URLs

Update data_urls_map (terraspace/app/stacks/ecs-cluster/tfvars/base.tfvars) by adding a new file, or removing an existing, to/from set. Then, run:

AWS_REGION=us-west-2 TS_ENV=prod terraspace up ecs-cluster

Stop

AWS_REGION=us-west-2 TS_ENV=prod terraspace down ecs-cluster

CloudWatch logs are preserved for further analysis

Workflows

Currently, there isn't workflows configured for this project. Commands need to be executed from developer machine

Troubleshooting

Error acquiring the state lock

Don't ctrl+c a terraspace command. You'll have claimed the lock, and it doesn't gracefully handle a kill signal, and now you've snapped the key off line lock and subsequent commands will fail with a:

AWS_REGION=us-west-2 TS_ENV=prod terraspace all plan
...
terraspace plan artifactory:  │ Error: Error acquiring the state lock
terraspace plan log:  │ Error: Error acquiring the state lock

To fix it, go to the dynamo db explorer, find the ID of the stack that are failing

screenshot showing lock id in dynamo db

and run terraspace force_unlock <stack> <id> to free the lock. You may have to do this for multple stack'n'lock combos.

# e.g.
AWS_REGION=us-west-2 TS_ENV=prod terraspace force_unlock artifactory 689fa081-b637...