Skip to content

Deployment Phases

All commands run from the source demo repository root. Complete Pre-flight checks before each apply.

Phase 1 All 6 stacks: VPC only Phase 2a network: PHZ + auth + EC2 Phase 2b network-apse6: association Phase 3 4 workload stacks

The network account’s cross-account-auth module creates a VPCAssociationAuthorization
CreateVPCAssociationAuthorization — network account permits a specific VPC (id + region) in another account to associate with the PHZ.
for each workload VPC. That requires the target VPC to already exist with a real vpc_id. Workload VPCs must exist before network can authorize them in Phase 2a.

Every stack in Phase 1 deploys VPC only:

StackFlags
networkenable_phz=false, enable_cross_account_auth=false, enable_test_ec2=false
network-apse6, all workload stacksenable_zone_association=false, enable_test_ec2=false

Apply workload stacks first (any order), then network-apse6, then network. Example — dev-apse2:

Terminal window
export AWS_PROFILE=r53demo-dev
aws sts get-caller-identity
terraform -chdir=terraform/accounts/dev-apse2 init
terraform -chdir=terraform/accounts/dev-apse2 validate
terraform -chdir=terraform/accounts/dev-apse2 apply \
-var="enable_zone_association=false" \
-var="enable_test_ec2=false"
terraform -chdir=terraform/accounts/dev-apse2 output vpc_id

Repeat for: dev-apse6, sandbox-apse2, sandbox-apse6, network-apse6, and network (with network-specific flags above).

Expected Phase 1 signal: vpc_id populated; test_ec2_instance_id empty; zone_id empty on network.

Save all four workload VPC IDs for Phase 2a in terraform/accounts/network/terraform.tfvars:

dev_apse2_vpc_id = "vpc-xxxxxxxx"
dev_apse6_vpc_id = "vpc-xxxxxxxx"
sandbox_apse2_vpc_id = "vpc-xxxxxxxx"
sandbox_apse6_vpc_id = "vpc-xxxxxxxx"

Authorization specificity

Authorization_Specificity
Each authorization binds to exact `vpc_id` and `vpc_region` — recreated VPCs need re-authorization in Phase 2a.

applies: if a workload VPC is destroyed and recreated later (new vpc_id), update network/terraform.tfvars and re-apply Phase 2a before Phase 3.


Phase 2a — Network PHZ and authorizations

Section titled “Phase 2a — Network PHZ and authorizations”

Route 53 requires the Platform_Zone
Shared private hosted zone `platform.demo.local` in the Network_Account — the only place `api` and `db` records are defined.
to exist and (for cross-account VPCs) a matching VPC_Association_Authorization
CreateVPCAssociationAuthorization — network account permits a specific VPC (id + region) in another account to associate with the PHZ.
per exact vpc_id and vpc_region. See Association Scenarios.

Phase 2a creates:

  • The PHZ
    Private Hosted Zone — resolves DNS only from associated VPCs. This demo uses one authoritative PHZ in the network account.
    and A records (api, db)
  • Same-account secondary VPC association (no authorization)
  • Four cross-account authorizations
  • Two Test EC2
    One minimal EC2 per stack (seven total) for in-VPC DNS checks via SSM Session Manager and `dig`.
    instances in ap-southeast-2
Terminal window
export AWS_PROFILE=r53demo-network
aws sts get-caller-identity
terraform -chdir=terraform/accounts/network init
terraform -chdir=terraform/accounts/network validate
terraform -chdir=terraform/accounts/network apply \
-var-file=terraform/accounts/network/terraform.tfvars
terraform -chdir=terraform/accounts/network output zone_id

Expected Phase 2a signal: zone_id populated (copy from terraform output zone_id); test_ec2_instance_id_primary and _secondary populated.

Set zone_id in terraform.tfvars for network-apse6 and all four workload stacks:

zone_id = "Z0xxxxxxxxxxxx"

Same-account cross-region
VPCs in ap-southeast-6 associate with a PHZ in ap-southeast-2 — Route 53 resolves shared records across regions from one zone.
association does not require VPCAssociationAuthorization — only zone_id.

Terminal window
export AWS_PROFILE=r53demo-network
aws sts get-caller-identity
terraform -chdir=terraform/accounts/network-apse6 init
terraform -chdir=terraform/accounts/network-apse6 validate
terraform -chdir=terraform/accounts/network-apse6 apply \
-var-file=terraform/accounts/network-apse6/terraform.tfvars
terraform -chdir=terraform/accounts/network-apse6 output

Expected signal: test_ec2_instance_id populated; association active for ap-southeast-6 VPC.


Phase 3 — Workload associations and Test EC2

Section titled “Phase 3 — Workload associations and Test EC2”

Cross-account associations require Phase 2a authorizations. AssociateVPCWithHostedZone
AssociateVPCWithHostedZone — workload account links its VPC to an authorized private hosted zone so the VPC resolver can query shared records.
without a matching authorization returns AccessDenied.

FlagValue
enable_zone_associationtrue
enable_test_ec2true

Run Phase 3 pre-flight before applying.

Example — dev-apse2:

Terminal window
export AWS_PROFILE=r53demo-dev
aws sts get-caller-identity
terraform -chdir=terraform/accounts/dev-apse2 init
terraform -chdir=terraform/accounts/dev-apse2 validate
terraform -chdir=terraform/accounts/dev-apse2 apply \
-var-file=terraform/accounts/dev-apse2/terraform.tfvars
terraform -chdir=terraform/accounts/dev-apse2 output

Repeat for dev-apse6, sandbox-apse2, and sandbox-apse6 with the matching profile (r53demo-dev or r53demo-sandbox).

After Phase 3, seven Test EC2
One minimal EC2 per stack (seven total) for in-VPC DNS checks via SSM Session Manager and `dig`.
instances exist across all association scenarios
One of four demo paths: cross-account same-region, cross-account cross-region, same-account cross-region, or same-account same-region.
. Proceed to Verification.

Verification — seven DNS tests with expected dig output.