Sub topic 14
Extending the Landing Zone with AFT and CfCT
This chapter assumes you have a working landing zone, understand OUs and controls, and have provisioned at least one account with Account Factory. It also assumes basic familiarity with Terraform or CloudFormation. Account Factory gives you a standard account. Most teams then need to add things to every new account, such as a baseline IAM role, a VPC, or a security tool. Control Tower offers two AWS-supported ways to do this: Account Factory for Terraform (AFT) and Customizations for Control Tower (CfCT).
Why you need an extension layer
Control Tower creates and governs accounts, but it does not configure their contents beyond the baseline. Doing that by hand after each account is created does not scale and causes inconsistency. Both AFT and CfCT apply your own code automatically when an account is created or enrolled. They differ in how you request accounts and in what tooling you write.
| Question | AFT | CfCT |
|---|---|---|
| How are accounts requested? | Terraform code in a Git repository | Account Factory (console, API or Service Catalog) |
| Language for customizations | Terraform | CloudFormation templates and service control policies |
| Deployment model | Pipeline per account request | Pipeline driven by a manifest file |
| Primary unit of targeting | Individual account | Account or OU |
| Extra infrastructure | A dedicated AFT management account | Stack deployed in the management account |
How AFT works
AFT is a Terraform module that you deploy into a dedicated account, called the AFT management account. You create this account in advance, usually in an OU such as Infrastructure or Platform. AFT then builds the pipelines that handle account requests.
An account request is a Terraform file stored in a Git repository that AFT watches. When you commit a new request, the pipeline calls Account Factory to create the account, then runs your customizations in it.
AFT uses four repositories (or folders in one repository, depending on the Git provider):
- Account request: one Terraform module call per account.
- Account provisioning customizations: a Step Functions workflow that runs before the account customizations.
- Global customizations: Terraform that runs in every account.
- Account customizations: Terraform that runs only in accounts that name that customization.
A request looks like this:
module "sandbox_account_01" {
source = "./modules/aft-account-request"
control_tower_parameters = {
AccountEmail = "[email protected]"
AccountName = "sandbox-01"
ManagedOrganizationalUnit = "Sandbox"
SSOUserEmail = "[email protected]"
SSOUserFirstName = "Sandbox"
SSOUserLastName = "Admin"
}
account_tags = {
"environment" = "sandbox"
}
change_reason = "Initial sandbox account"
account_customizations_name = "sandbox"
}The account_customizations_name value selects a folder in the account customizations repository. Global customizations run first for every account, then the named account customizations run.
AFT deployment
You deploy AFT from the management account's perspective by running Terraform with credentials that can create resources in the AFT management account. A minimal root module looks like this:
module "aft" {
source = "aws-ia/control_tower_account_factory/aws"
ct_management_account_id = "111111111111"
log_archive_account_id = "222222222222"
audit_account_id = "333333333333"
aft_management_account_id = "444444444444"
ct_home_region = "us-east-1"
tf_backend_secondary_region = "us-west-2"
vcs_provider = "github"
account_request_repo_name = "example-org/aft-account-request"
account_provisioning_customizations_repo_name = "example-org/aft-account-provisioning-customizations"
global_customizations_repo_name = "example-org/aft-global-customizations"
account_customizations_repo_name = "example-org/aft-account-customizations"
}Check the module's documentation for the current required inputs, since they change between releases. A GitHub or other external provider also needs a connection that you approve once in the AWS console.
How CfCT works
CfCT is a CloudFormation solution that you deploy in the management account. It uses a source (an S3 bucket or a CodeCommit repository, depending on your setup) that holds a manifest.yaml file and the templates it references. A CodePipeline pipeline reads the manifest and deploys StackSets and service control policies.
CfCT also listens for Control Tower lifecycle events. When a new account is created or enrolled in an OU that the manifest targets, CfCT deploys the matching stacks to it automatically. This means you keep using Account Factory for requests and add your baseline on top.
A manifest looks like this:
region: us-east-1
version: 2021-03-15
resources:
- name: baseline-role
description: Cross-account read-only role for the security team
resource_file: templates/baseline-role.template
deployment_targets:
organizational_units:
- Workloads
deploy_method: stack_set
regions:
- us-east-1Here deployment_targets selects OUs by name, and deploy_method: stack_set tells CfCT to use CloudFormation StackSets. The template path is relative to the package root.
Packaging the source
The configuration package is a zip file with the manifest at the top and your templates in folders next to it. You upload it to the CfCT source bucket, and the upload starts the pipeline.
zip -r custom-control-tower-configuration.zip manifest.yaml templates/
aws s3 cp custom-control-tower-configuration.zip \
s3://<cfct-source-bucket>/custom-control-tower-configuration.zipThe bucket name and key depend on how you deployed the CfCT stack. Look at the stack's outputs and parameters to find the exact values.
Request and customization flow
The diagram shows how the two paths differ. In AFT a Git commit drives everything. In CfCT Account Factory drives account creation, and a lifecycle event triggers the customization.
Choosing between AFT and CfCT
Decide based on your team's skills and how you want to request accounts.
- Choose AFT if your team uses Terraform and wants account requests reviewed through pull requests. AFT fits a GitOps process and gives per-account control over customizations.
- Choose CfCT if you already write CloudFormation, if you want to keep using the Account Factory console or Service Catalog for requests, or if you need to deploy service control policies from the same package.
- Avoid running both against the same resources. Two tools that manage the same role or setting will overwrite each other and produce confusing failures.
You can run both when they manage different things, for example CfCT for SCPs and AFT for account baselines. Keep a written rule about which tool owns which resource.
Common errors and gotchas
- Missing prerequisites. AFT needs a separate management account that already exists and is enrolled. Create it before you run the Terraform module.
- Manifest names do not match. CfCT looks up OUs by name. A typo or a renamed OU makes the stack deploy to nothing, often without a loud error. Check the pipeline logs.
- Customizations running in a ungoverned Region. Deploying to a Region that Control Tower does not govern can fail or cause drift in regional controls. Match your
regionslist to your governed Regions. - Pipeline failures after the account exists. In AFT, the account may be created and enrolled even though customizations failed. Fix the code and re-run the customization pipeline. You do not need a new request.
- Changing request parameters carelessly. Editing the OU in an AFT request moves the account. Treat that edit as a change that needs review, since controls on the new OU begin to apply.
- Slow runs. Both tools use several AWS services in sequence, so a new account can take tens of minutes to finish. Plan for that in any automation that waits on it.
Cost and operations
AFT and CfCT run on ordinary AWS services such as CodePipeline, CodeBuild, Lambda, Step Functions, DynamoDB and S3. You pay for those services at their normal rates, in addition to the Control Tower charges. AFT adds a whole account and a larger set of resources, so it usually costs more to run than CfCT. Both need ongoing maintenance, because you must update the AFT module version or the CfCT stack when new releases appear.
Exercise
Your team writes only Terraform and wants every new account request to go through a pull request review. Which tool fits, and which account must exist before you deploy it?
Show answer
Use AFT. Account requests are Terraform files in a Git repository, so pull requests provide the review step. You must first create the dedicated AFT management account, which hosts the pipelines and supporting resources.
Exercise
A CfCT manifest targets the OU "Workload" but the OU is actually named "Workloads". What is the likely result, and how do you find the problem?
Show answer
Because CfCT matches OUs by name, the stacks are not deployed to the intended accounts, and the failure may not be obvious. Check the CfCT pipeline and StackSet logs, then correct the OU name in the manifest and upload the package again.