Start by requesting or provisioning three separate AWS accounts (DEV, STAGE, and PROD) through the enterprise Landing Zone's account vending mechanism, and immediately map IAM Identity Center permission sets to them. In an existing enterprise setup, account isolation and identity governance always precede any infrastructure deployment. Configure Identity and Access Management (IAM) first—specifically by provisioning a dedicated Development AWS account through your Landing Zone and setting up federated access via AWS IAM Identity Center. You should never deploy workload resources like EC2 instances or S3 buckets directly inside your core Landing Zone management account. In a standard Landing Zone architecture (typically managed via AWS Control Tower), the environment is designed around strict multi-account isolation. ======================================== Recommended Order of Operations ======================================== 1. Provision a Dedicated Dev Account. Use the Account Factory in AWS Control Tower (or Landing Zone vending pipeline) to create a separate AWS account specifically for development under a Workloads or Sandbox Organizational Unit (OU). 2. Configure IAM Access & Permissions. Set up user access using AWS IAM Identity Center (formerly AWS SSO) instead of creating standalone IAM users with static access keys. Assign developers least-privilege Permission Sets to access the new Dev account, and create the necessary IAM execution roles for your services. 3. Establish Baseline Networking & Guardrails. Verify that your Landing Zone guardrails (Service Control Policies) and baseline networking—such as your VPC, subnets, and routing—are in place within the Dev account. 4. Deploy Workload Resources (S3, EC2, etc.). Once access and networking are secured inside the isolated Dev account, create your Amazon S3 buckets and launch Amazon EC2 instances, attaching the IAM roles you created in Step 2. ======================================== Why IAM and Account Isolation Come First ======================================== • Security & Blast Radius. Keeping dev resources out of the management account ensures that experimental changes, misconfigurations, or compromised credentials cannot affect billing, centralized logging, or production accounts. • Dependency Management. Services like EC2 often require an IAM Instance Profile at launch to interact securely with S3 buckets or other AWS services without hardcoding credentials. • Governance. Applying IAM policies and Organizational Unit guardrails upfront prevents developers from accidentally spinning up non-compliant or overly expensive resources. It is recommended using Terraform over CloudFormation, paired with a layered module architecture and GitHub Actions OIDC authentication. When enterprise Landing Zone does not auto-provision VPCs, one must explicitly separate Network Foundation from Application Workloads in code so VPCs are built before EC2 instances, while keeping state blast-radius isolated across DEV, STAGE, and PROD. ======================================== 1. Why Terraform is the Better Choice Here ======================================== • Multi-Account Ergonomics: Managing cross-account deployments (DEV, STAGE, PROD) and shared networking (e.g., peering or Transit Gateway attachments) is significantly cleaner in Terraform using provider aliases or environment-specific backend configs than managing CloudFormation StackSets across accounts. • State & Drift Detection: Terraform gives you explicit terraform plan previews directly inside GitHub Pull Requests before touching STAGE or PROD. ======================================== 2. Recommended Repo & Folder Structure ======================================== Separate your core infrastructure (VPC, IAM roles) from your application workloads (EC2, S3) so a routine app deployment never risks modifying network routing. infra-repo/ ├── modules/ # Reusable, environment-agnostic modules │ ├── vpc/ # VPC, public/private subnets, NAT Gateways │ └── app-stack/ # S3 buckets, EC2, Security Groups, Instance Profiles └── environments/ ├── dev/ │ ├── 01-networking/ # Layer 1: Deploy first (VPC + GitHub OIDC) │ │ ├── main.tf │ │ └── backend.tf # Points to dev-tf-state S3 bucket │ └── 02-workloads/ # Layer 2: Deploy second (EC2 + S3) │ ├── main.tf # Reads VPC IDs via terraform_remote_state │ └── backend.tf ├── stage/ │ ├── 01-networking/ │ └── 02-workloads/ └── prod/ ├── 01-networking/ └── 02-workloads/ ======================================== 3. Step-by-Step Bootstrap Sequence ======================================== Because you have a chicken-and-egg problem (Terraform needs an S3 state bucket and an IAM role to run, before Terraform can create anything), execute this one-time bootstrap per account (DEV, STAGE, PROD): 1. Request the 3 Accounts: Get your DEV, STAGE, and PROD account IDs from your enterprise Landing Zone team and confirm IP CIDR blocks with your network team so your VPCs don't overlap with corporate networks (e.g., 10.10.0.0/16 for DEV, 10.20.0.0/16 for STAGE, 10.30.0.0/16 for PROD). 2. Create Terraform State Backends: In each account, create an encrypted, versioned S3 bucket (e.g., company-tfstate-dev) to store Terraform state files. (Note: Modern Terraform supports native S3 state locking via use_lockfile = true, removing the need for a DynamoDB lock table). 3. Configure GitHub Actions OIDC: In each AWS account, create an IAM OIDC Identity Provider for https://githubusercontent.com and an IAM Role (e.g., GitHubActionsDeployRole) scoped to your repository and GitHub Environment. Sample IAM Trust Policy for GitHub Actions OIDC Replace , , , and (dev, stage, or prod): json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam:::oidc-provider/://githubusercontent.com" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "://githubusercontent.com:aud": "://amazonaws.com", "://githubusercontent.com:sub": "repo:/:environment:" } } } ] } 4. GitHub Actions Deployment Pipeline Flow 1. Configure GitHub Environments: In your GitHub repo settings, create three Environments: dev, stage, and prod. • Add a Required Reviewer protection rule on prod (and optionally stage) so GitHub pauses the workflow and blocks OIDC role assumption until a lead approves. • Store each account's AWS_ROLE_ARN as an Environment Secret/Variable. 2. Execute Layer 1 (01-networking): Run your pipeline to provision the VPCs, private/public subnets, NAT gateways, and VPC endpoints across DEV → STAGE → PROD. 3. Execute Layer 2 (02-workloads): Deploy your application S3 buckets, EC2 IAM instance profiles, security groups, and EC2 instances into the newly created private subnets.