Demonstration of defn.dev
This is a Terraform configuration of AWS Organizations with four accounts: org master, ops, net, and dev.
Tools installed with Nix.
Terraform generated with CDKTF Golang.
Configurations managed with CUE.
Onboarding
Any defn.dev admin must be able to run the following:
# get a nix shell
make
# install language tools
make install
# verify aws access
make whoami
# terraform plan something
cd cfg/remote-state
terraform init
terraform plan
cd ../../stacks/org-demo
terraform init
terraform plan
cd ../acc-demo-org
terraform init
terraform plan
Setup
AWS Organization Master Account
- Create AWS account: PREFIX+NAME-org@domain.tld
- Add MFA https://us-east-1.console.aws.amazon.com/iam/home#/security_credentials
- Activate IAM Access https://us-east-1.console.aws.amazon.com/billing/home#/account
AWS IAM Identity Center
- Pick a region other than your main
- Choose AWS Organizations
- Pick access portal name
- Create PermissionSet AdminstratorAccess
- Create admin user
- Create ops Organization account
- Delegate to ops account
- Deploy
Customize AWS Config
- Edit .envrc, change region
- Edit cfg/.aws/config, change region, names, IDs, Administrator to AdministratorAccess temporarily
- Edit cfg/cfg.cue, change region, names, IDs
- Test access with
make whoami
, only org, ops accounts will work at this point
Initialize GitOps
- Get a shell:
direnv allow && nix develop
- Install stuff:
make install
cd cfg && make build
- Make remote-state
cd cfg/remote-state
rm -f backend.tf
vi remote-state.tf
tf init
tf plan
tf apply
tf init
tf plan
rm terraform.tfstate*
tf locks
- Generate locks:
cd cdktf.out/stacks/org-demo && tf init && tf locks
- Import aws organization:
terraform import aws_organizations_organization.organization o-gmfp7o9c7c
- Import aws organization master account:
terraform import aws_organizations_account.org 992382597334
- Import aws organization ops account:
terraform import aws_organizations_account.ops 339712953662
- Depoy the org config:
tf plan; tf apply
- Fill out rest of
cfg/.aws/config
and cfg/cfg.cue
, remove Access
role suffix
- Verify aws credentials:
aws-vault clear; make whoami
- For each
cdktf.out/stacks/acc-*/
, tf init && tf locks && tf plan && tf apply
- Clean up AdminstratorAccess PermissonSet