The script performs the following:
- Downloads the states from s3
- Copies
nlb
from state_a to state_b - Copies
nlb_domain
from state_a to state_b - Copies
nlb_service
from state_a to state_b - Copies
nlb_certificate
from state_a to state_b - Copies
nlb_certificate_validation (route53_record)
from state_a to state_b - Copies
nlb_certificate_validation (acm_certificate_validation)
from state_a to state_b - Copies
nlb_broker_listeners
from state_a to state_b keeping target_groups of state_b - Copies
nlb_service_listeners
from state_a to state_b keeping target_groups of state_b - Uploads the state of cluster_b to s3
If you set the --prometheus
parameter, is performs the following actions additionally:
- Copies
nlb
(from prometheus module) from state_a to state_b - Copies
internal_record_set
(from prometheus module) from state_a to state_b - Copies
nlb_service
(from prometheus module) from state_a to state_b - Copies
nlb_listeners
(from prometheus module) from state_a to state_b keeping target_groups of state_b
*You can customize the behaviour in the main function
cd tf-state-change
python3 -m venv venv
. ./venv/bin/activate
pip install -r requirements.txt
First, get the aws credentials via aws-saml-auth or awsmyid tools so that they are stored in the ~/.aws/credentials
aws-saml-auth
or
awsmyid --login
Usage:
(venv) ab@ANDREIs-MacBook-Pro tf-state-change % python main.py -h
usage: main.py [-h] --states STATES STATES --env ENV [--dry-run] [--prometheus] ─╯
optional arguments:
-h, --help show this help message and exit
--states STATES STATES
List of state files to work with
--env ENV nonprod or prod
--dry-run Run without uploading state back to S3. The changes will be saved to a new "modified" directory
--prometheus Set this parameter if prometheus ingress enabled in target clusters
Example:
python main.py --states us-east-1-plygnd-ab-main.tfstate us-east-1-plygnd-ab2-main.tfstate --env nonprod --dry-run
python main.py --states us-east-1-plygnd-ab-main.tfstate us-east-1-plygnd-ab2-main.tfstate --env nonprod
python main.py --states us-east-1-plygnd-ab-main.tfstate us-east-1-plygnd-ab2-main.tfstate --env nonprod --prometheus --dry-run
python main.py --states us-east-1-plygnd-ab-main.tfstate us-east-1-plygnd-ab2-main.tfstate --env nonprod --prometheus
- backup delete resources