Terraform Account Factory for AWS Control Tower

Account Factory for Terraform changes how organizations provision and govern AWS accounts at scale by combining Terraform's infrastructure-as-code workflow with the governance guardrails of AWS Control Tower. The pattern replaces manual console clicks and fragmented scripts with a declarative, version-controlled pipeline that creates accounts, places them in the organization, applies baseline security, and executes customizations in a repeatable way. The result is a consistent, auditable, and auditable account lifecycle that aligns with enterprise security procedures and compliance guidelines.

Overview of Account Factory for Terraform

Account Factory for Terraform sets up a Terraform pipeline to help you provision and customize accounts in AWS Control Tower. AFT provides you with the advantage of Terraform-based account provisioning while allowing you to govern your accounts with AWS Control Tower.

With AFT you create an account request Terraform file to get the input that triggers the AFT workflow for account provisioning. After the account provisioning stage is complete, AFT automatically runs a series of steps before the account customizations stage begins.

AFT supports HCP Terraform, Terraform Enterprise, and Terraform Community Edition. With AFT you can initiate account creation using an input file and a simple git push command and customize new or existing accounts. Account creation includes all of the AWS Control Tower governance benefits and account customizations that help you meet your organization's standard security procedures and compliance guidelines.

AFT supports account customization request tracing. Every time you submit an account customization request, AFT generates a unique tracing token that passes through an AFT customizations AWS Step Functions state machine, which logs the token as part of its execution. You can then use Amazon CloudWatch Logs insights queries to search timestamp ranges and retrieve the request token.

AWS maintains this module. AFT defines a pipeline for automated and consistent creation of AWS Control Tower accounts, giving you the benefits of Terraform's workflow and Control Tower's governance features.

GitOps Model and Provisioning Pipeline

The repository contains the Terraform configuration and deployment scripts for AWS Account Factory for Terraform, which automates the provisioning and management of AWS accounts within an AWS Control Tower environment.

AWS Account Factory for Terraform follows a GitOps model to automate the processes of account provisioning and account updating in an AWS Control Tower environment.

In a GitOps model, the desired state of the account factory is described in version control. A change to an account request file results in a pipeline execution that reconciles the real world with the declared state. This approach ensures consistency, repeatability, and auditable changes to your AWS landscape.

Instead of tedious manual processes, you define the account specifications, and Account Factory handles the heavy lifting, automating the creation, configuration, and even the initial setup of essential services within each new account.

Account Creation Workflow

Account Factory for Terraform is a robust solution that streamlines the creation and management of multiple AWS accounts. It utilizes Terraform's infrastructure-as-code capabilities, allowing you to define your account creation process in a declarative, version-controlled manner.

Managing multiple AWS accounts can quickly become a complex and time-consuming task. Manually creating and configuring each account is inefficient, prone to errors, and scales poorly.

Account Factory will handle many of the intricacies of AWS account creation, including the often tedious process of verifying email addresses.

Once an account request is submitted, the pipeline executes provisioning, then automatically runs a series of steps before the account customizations stage begins. Account creation includes all of the AWS Control Tower governance benefits and account customizations that help you meet your organization's standard security procedures and compliance guidelines.

Customization and Lifecycle Management

Beyond basic account creation, Account Factory for Terraform offers advanced capabilities to further enhance your infrastructure management.

Manage and update leverages Terraform's state management to track and update your AWS accounts. You can use terraform plan to see changes before applying them and terraform destroy to safely remove accounts when no longer needed.

Account customization request tracing provides visibility into each customization. Every time you submit an account customization request, AFT generates a unique tracing token that passes through an AFT customizations AWS Step Functions state machine, which logs the token as part of its execution. You can then use Amazon CloudWatch Logs insights queries to search timestamp ranges and retrieve the request token.

You can initiate account creation using an input file and a simple git push command and customize new or existing accounts.

Organizational Unit Management and Service Control Policies

Organize your AWS accounts into hierarchical OUs within your AWS Organizations structure for better governance and access control. Account Factory can automate the placement of newly created accounts into specific OUs based on predefined rules or tags.

Implement centralized security controls using SCPs, enforcing consistent security policies across all accounts. Account Factory can integrate with SCPs, ensuring that newly created accounts inherit the necessary security configurations.

Develop custom Terraform modules to provision essential services within the newly created accounts. This might include setting up VPCs, IAM roles, or other fundamental infrastructure components.

Prerequisites and Setup Considerations

Before you begin, ensure you have the following prerequisites:

  • An existing AWS account with appropriate permissions.
  • Terraform installed and configured.
  • AWS credentials configured for Terraform.
  • A basic understanding of Terraform concepts and syntax.

For this tutorial, you will need:

  • Terraform v0.15+ installed locally configured with credentials for the non-root user with AdministratorAccess
  • an AWS account, with credentials for a non-root user with the AdministratorAccess policy attached. Some steps can take up to 30 minutes, so make sure your credentials have a long enough duration

This tutorial assumes that you are familiar with the standard Terraform workflow. If you are new to Terraform, complete the Get Started tutorials first.

Step-by-Step Guide considerations include install the necessary providers. You'll need the AWS provider and potentially others depending on your requirements.

Key Features and Benefits

Key Features and Benefits of Account Factory for Terraform include:

  • Automation: Eliminate manual steps, saving time and reducing human error.
  • Consistency: Ensure all accounts are created with the same configurations and policies.
  • Scalability: Easily create and manage hundreds or thousands of accounts.
  • Version Control: Track changes to your account creation process using Git.
  • Idempotency: Repeated runs of the Terraform configuration will produce the same result without unintended side effects.
  • Security: Implement robust security policies and controls from the outset.

The following table summarizes core capabilities mapped to operational outcomes.

| Capability | Description | Operational Outcome |
| Account provisioning pipeline | Terraform driven pipeline that creates Control Tower governed accounts | Consistent governance from first boot |
| GitOps triggering | Input file change via git push initiates workflow | Version controlled, auditable requests |
| Customization stage | Automated steps after provisioning before customizations | Reliable handoff to bespoke configurations |
| Tracing token | Unique token logged in Step Functions and CloudWatch | Request tracking and troubleshooting |
| OU placement automation | Accounts placed into OUs based on rules or tags | Hierarchical governance and access control |
| SCP integration | New accounts inherit Service Control Policies | Centralized security enforcement |
| Custom modules | Terraform modules for VPC, IAM, services | Standardized baseline services per account |

Advanced Usage Patterns

Beyond basic account creation, Account Factory for Terraform offers advanced capabilities to further enhance your infrastructure management.

Organizational Unit Management allows you to organize AWS accounts into hierarchical OUs within your AWS Organizations structure for better governance and access control. Account Factory can automate the placement of newly created accounts into specific OUs based on predefined rules or tags.

Service Control Policies enable implementation of centralized security controls using SCPs, enforcing consistent security policies across all accounts. Account Factory can integrate with SCPs, ensuring that newly created accounts inherit the necessary security configurations.

Custom Configuration Modules let you develop custom Terraform modules to provision essential services within the newly created accounts. This might include setting up VPCs, IAM roles, or other fundamental infrastructure components.

Remember to prioritize security best practices throughout the process and leverage the advanced features of Account Factory to further optimize your AWS infrastructure management. Mastering Account Factory for Terraform is a key step towards robust and efficient cloud operations.

For further information, refer to the official Terraform documentation and the AWS documentation. You can also find helpful resources and community support on various online forums and developer communities.

Managing Account Lifecycle with Terraform

It utilizes Terraform's infrastructure-as-code capabilities, allowing you to define your account creation process in a declarative, version-controlled manner. This approach ensures consistency, repeatability, and auditable changes to your AWS landscape.

Instead of tedious manual processes, you define the account specifications, and Account Factory handles the heavy lifting, automating the creation, configuration, and even the initial setup of essential services within each new account.

The GitOps model means account requests are pull request driven. A simple git push command can initiate account creation. State management lets teams view planned changes, apply them safely, and remove accounts when no longer needed.

Conclusion

Account Factory for Terraform delivers a production ready path to scale AWS Control Tower account creation without sacrificing governance or developer velocity. By combining a Terraform pipeline with Control Tower guardrails, organizations obtain repeatable provisioning, automated customization, and full request traceability through Step Functions and CloudWatch Logs.

The GitOps workflow ensures every account request is version controlled, reviewed, and auditable. Organizational Unit placement and Service Control Policy integration provide consistent governance from day zero. Custom Terraform modules extend the factory to deliver baseline networking, identity, and security foundations automatically.

Operationally, teams gain automation that removes manual errors, consistency that enforces standards, and scalability that supports hundreds or thousands of accounts. Idempotency and state management give safe update and destroy paths for the entire account fleet.

Prioritizing security best practices throughout the process and leveraging the advanced features of Account Factory further optimizes AWS infrastructure management. Mastering Account Factory for Terraform is a key step towards robust and efficient cloud operations.

Sources

  1. AWS Control Tower User Guide
  2. DevOpsRoles Deploy AWS Accounts with Account Factory for Terraform
  3. GitHub aws-aft-solution
  4. HashiCorp Developer Terraform AWS Control Tower AFT

Related Posts