TWITCH_CE_HOST_AWS = "447680546588"
TWITCH_CE_HOST_DEV = "038504843107"
EPOCH = $(shell date +"%s")

setup:
	pip install boto3 --upgrade --user 
	pip install awscli --upgrade --user

create_staging_db:
	python scripts/validate_aws.py ${TWITCH_CE_HOST_DEV}
	aws cloudformation create-stack --template-body file://cloudformation/infrastructure/dynamodb.yaml --cli-input-json file://cloudformation/cli/create_db_staging.json

create_prod_db:
	python scripts/validate_aws.py ${TWITCH_CE_HOST_AWS}
	aws cloudformation create-stack --template-body file://cloudformation/infrastructure/dynamodb.yaml --cli-input-json file://cloudformation/cli/create_db_production.json

update_staging_db:
	python scripts/validate_aws.py ${TWITCH_CE_HOST_DEV}
	aws cloudformation update-stack --template-body file://cloudformation/infrastructure/dynamodb.yaml --cli-input-json file://cloudformation/cli/update_db_staging.json

update_prod_db:
	python scripts/validate_aws.py ${TWITCH_CE_HOST_AWS}
	aws cloudformation create-change-set --template-body file://cloudformation/infrastructure/dynamodb.yaml --cli-input-json file://cloudformation/cli/update_db_production.json --change-set-name latest-${EPOCH}
	@echo "Apply updates at https://us-west-2.console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks?tab=changesets"

create_pagerduty:
	python scripts/validate_aws.py ${TWITCH_CE_HOST_AWS}
	aws cloudformation create-stack --template-body file://cloudformation/infrastructure/pagerduty.yaml --cli-input-json file://cloudformation/cli/create_pagerduty.json

update_pagerduty:
	python scripts/validate_aws.py ${TWITCH_CE_HOST_AWS}
	aws cloudformation create-change-set --template-body file://cloudformation/infrastructure/pagerduty.yaml --cli-input-json file://cloudformation/cli/update_pagerduty.json --change-set-name latest-${EPOCH}
	@echo "Apply updates at https://us-west-2.console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks?tab=changesets"

validate-template:
	aws cloudformation validate-template --template-body file://cloudformation/infrastructure/dynamodb.yaml
	aws cloudformation validate-template --template-body file://cloudformation/infrastructure/pagerduty.yaml
