YAML & infrastructure as code
Describe the infrastructure in files: a change is a pull request, reviewed, planned, checked and applied.
The CityScript
This is all there is to it. Change it in the editor and the city redraws.
%% Y · YAML & infrastructure as code
%% Nobody clicks in the cloud console. A merge plans the change, a policy checks it, a person approves it, then it applies.
city 48x32
district code "Code" 3,3..14,12
district cloud "Cloud account" 19,3..45,20
building repo tower in code "Infra repo"
floor repo.f "Terraform"
room repo.modules storage "Modules"
room repo.envs config "Environments"
building state warehouse in code "State"
floor state.f "Remote state"
room state.bucket storage "State file"
room state.lock config "State lock"
building network depot in cloud "Network"
floor network.f "VPC"
room network.vpc config "VPC and subnets"
room network.dns config "DNS zones" port=53
building cluster factory in cloud "Kubernetes"
floor cluster.f "Cluster"
room cluster.control service "Control plane" port=6443
room cluster.nodes worker "Node groups"
building data factory in cloud "Data"
floor data.f "Managed services"
room data.rds database "Postgres" port=5432
room data.cache cache "Redis" port=6379
boundary code-zone "Code" members=repo,state
boundary vpc "VPC" members=network,cluster,data
boundary cloud-account "Cloud account" members=vpc
pipeline plan "Plan on pull request" repo -> [fmt] -> [validate] -> [plan] -> [policy-check] -> state
step repo "A change to the infrastructure is proposed"
step state "The plan says what would change, and the policy checks it"
run fmt "terraform fmt -check -recursive"
run validate "terraform init -backend=false"
run validate "terraform validate"
run plan "terraform plan -out=tfplan"
run policy-check "terraform show -json tfplan > tfplan.json"
run policy-check "conftest test tfplan.json"
pipeline apply "Apply on merge" repo -> [plan] -> [approve] -> [apply] -> cloud
step repo "The change is approved and merged"
step cloud "The change is applied to the real cloud"
run plan "terraform plan -out=tfplan"
run apply "terraform apply tfplan"
link repo.envs -> state.lock "lock state"
link repo.modules -> network.vpc "apply" variant=security
link repo.modules -> cluster.control "apply" variant=security
link repo.modules -> data.rds "apply" variant=security