How to add or mirror a new region
DRAFT
Problem
Solution
The current primary region is us-west-2
and the new desired region is us-east-2
Additional region
-
Create root stacks of the new region e.g.
ue2*.yaml
-
Update VPC CIDR documentation
-
Create minimal components in the yaml such as
vpc
,transit-gateway
, and perhapscompliance
(or others) if applicable -
Deploy minimal components
-
Optionally deploy
dns-delegated
if a new Hosted Zone is required per region -
This is no longer used going forward as we can use a single Hosted Zone for
<stage>.example.com
and create multi domain records within it such aspostgres-example.ue2
without having to create aue2.<stage>.example.com
HZ. -
Optionally deploy
transit-gateway-cross-region
component to peer both regions
TBD
-
Optionally deploy new github runners (if applicable)
-
Retrieve the new github runner IAM role arn
-
Update
iam-primary-roles
to include the new IAM role and deploy it to updateidentity-cicd
role -
Optionally deploy new
spacelift-worker-pool
(if applicable) -
Set a worker pool id map in the
spacelift
component -
Set a
worker_pool_name
global variable in the new region -
Update
iam-primary-roles
to include the new IAM role and deploy it to updateidentity-ops
role
If new region needs to be a mirror of the primary region
-
Same steps as above, except instead of minimal components, we want to copy and paste all of the primary region into the new desired region. We will not reprovision anything from
gbl*
. -
Mirror the SSM parameters by exporting them from the primary region and importing them into the new region
stage=sandbox
CURRENT_REGION=us-west-2
NEW_REGION=us-east-2
# get services
services=$(AWS_PROFILE=$NAMESPACE-gbl-$stage-admin AWS_REGION=$CURRENT_REGION aws ssm describe-parameters --query 'Parameters[].Name' | grep / | cut -d'/' -f2 | sort | uniq | tr '\n' ' ')
# export
AWS_PROFILE=$NAMESPACE-gbl-$stage-admin AWS_REGION=$CURRENT_REGION chamber export -o chamber-$stage.json $services
# import
for service in $services; do
AWS_PROFILE=$NAMESPACE-gbl-$stage-admin AWS_REGION=$NEW_REGION chamber import $service chamber-$stage.json;
done
-
Ensure all hostnames use the correct regional endpoints (either by Hosted Zone or by record)
-
Optionally, it’s not recommended, but if the tfstate bucket needs to be migrated
-
Make sure everything in Spacelift is confirmed/discarded/failed so nothing is left in an unconfirmed state.
-
Schedule a date with the customer so no applies go through
-
Set desired count on the spacelift worker pool to 0 with a max and min count of 0
-
Manually copy from old tfstate bucket to new tfstate bucket
-
PR to change all the
backend.tf.json
files over to the new bucket and set new bucket in the global vars -
Check locally to see that new bucket is used and stacks show no changes
-
Merge PR
-
revert spacelift worker pool
-
Ensure everything is working in Spacelift
If an old region needs to be destroyed
The following can be destroyed in Spacelift using a run task with terraform destroy -auto-approve
The following should be destroyed locally with atmos