Skip to main content
Control Tower 0.4.3

Control Tower Multi-Account Factory

View SourceRelease Notes

This is a Terraform module that will trigger the creation of multiple new AWS accounts by using Control Tower. Under the hood, this module uses the control-tower-account-factory module.

Sample Usage

main.tf

# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S CONTROL-TOWER-MULTI-ACCOUNT-FACTORY MODULE
# ------------------------------------------------------------------------------------------------------

module "control_tower_multi_account_factory" {

source = "git::git@github.com:gruntwork-io/terraform-aws-control-tower.git//modules/landingzone/control-tower-multi-account-factory?ref=v0.4.3"

# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------

# The absolute path to the folder to look for new account request files. Each
# file should be named account-<NAME>.yml, where NAME is the name of an
# account to create. Within the YAML file, you must define the following
# fields: account_email (Account email, must be globally unique across all AWS
# Accounts), sso_user_first_name (The first name of the user who will be
# granted admin access to this new account through AWS SSO),
# sso_user_last_name (The last name of the user who will be granted admin
# access to this new account through AWS SSO), sso_user_email (The email
# address of the user who will be granted admin access to this new account
# through AWS SSO), organizational_unit_name (The name of the organizational
# unit or OU in which this account should be created—must be one of the OUs
# enrolled in Control Tower).
account_requests_folder = <string>

# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------

# If specified, this is assumed to be the absolute file path of a YAML file
# where the details of the new accounts created by this module will be written
# (if the file already exists, the module will merge its data into the file).
# The expected format of this YAML file is that the keys are the account names
# and the values are objects with the following keys: id (the account ID),
# email (the root user email address for the account).
accounts_yaml_path = null

# The amount of time allowed for the create operation to take before being
# considered to have failed.
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicecatalog_provisioned_product#timeouts
create_operation_timeout = "60m"

# The amount of time allowed for the delete operation to take before being
# considered to have failed.
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicecatalog_provisioned_product#timeouts
delete_operation_timeout = "60m"

# If set to true, this module will use a Bash script to try to find the
# Control Tower provisioning artifact ID automatically. Due to a Terraform bug
# (https://github.com/hashicorp/terraform-provider-aws/issues/24362), the
# aws_servicecatalog_provisioned_product resource doesn't always find the AWS
# Service Catalog provisioning artifact ID correctly, so using this Bash
# script is our temporary workaround. This way, you don't have to set
# provisioning_artifact_id manually—and update it every time it changes! Note
# that this script requires the AWS CLI to be installed and on the PATH.
find_provisioning_artifact_id_using_script = true

# The ID of the AWS Control Tower Account Factory provisioning artifact in AWS
# Service Catalog to use. If find_provisioning_artifact_id_using_script is set
# to true, we will look up the ID automatically, and you don't need to set
# this parameter. However, if find_provisioning_artifact_id_using_script is
# false, you should set this parameter, as, due to a Terraform bug
# (https://github.com/hashicorp/terraform-provider-aws/issues/24362), the
# aws_servicecatalog_provisioned_product resource fails to look this up
# automatically. You can find the ID manually by going to the Product List in
# the AWS Service Catalog console
# (https://console.aws.amazon.com/servicecatalog/home#admin-products),
# clicking the 'AWS Control Tower Account Factory' product, and grabbing the
# ID of the latest product version from the Product Versions table at the
# bottom.
provisioning_artifact_id = null

# The amount of time allowed for the read operation to take before being
# considered to have failed.
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicecatalog_provisioned_product#timeouts
read_operation_timeout = "20m"

# The amount of time allowed for the update operation to take before being
# considered to have failed.
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicecatalog_provisioned_product#timeouts
update_operation_timeout = "60m"

}


Reference

Required

The absolute path to the folder to look for new account request files. Each file should be named account-<NAME>.yml, where NAME is the name of an account to create. Within the YAML file, you must define the following fields: account_email (Account email, must be globally unique across all AWS Accounts), sso_user_first_name (The first name of the user who will be granted admin access to this new account through AWS SSO), sso_user_last_name (The last name of the user who will be granted admin access to this new account through AWS SSO), sso_user_email (The email address of the user who will be granted admin access to this new account through AWS SSO), organizational_unit_name (The name of the organizational unit or OU in which this account should be created—must be one of the OUs enrolled in Control Tower).

Optional

accounts_yaml_pathstringoptional

If specified, this is assumed to be the absolute file path of a YAML file where the details of the new accounts created by this module will be written (if the file already exists, the module will merge its data into the file). The expected format of this YAML file is that the keys are the account names and the values are objects with the following keys: id (the account ID), email (the root user email address for the account).

null

The amount of time allowed for the create operation to take before being considered to have failed. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicecatalog_provisioned_product#timeouts

"60m"

The amount of time allowed for the delete operation to take before being considered to have failed. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicecatalog_provisioned_product#timeouts

"60m"

If set to true, this module will use a Bash script to try to find the Control Tower provisioning artifact ID automatically. Due to a Terraform bug (https://github.com/hashicorp/terraform-provider-aws/issues/24362), the aws_servicecatalog_provisioned_product resource doesn't always find the AWS Service Catalog provisioning artifact ID correctly, so using this Bash script is our temporary workaround. This way, you don't have to set provisioning_artifact_id manually—and update it every time it changes! Note that this script requires the AWS CLI to be installed and on the PATH.

true

The ID of the AWS Control Tower Account Factory provisioning artifact in AWS Service Catalog to use. If find_provisioning_artifact_id_using_script is set to true, we will look up the ID automatically, and you don't need to set this parameter. However, if find_provisioning_artifact_id_using_script is false, you should set this parameter, as, due to a Terraform bug (https://github.com/hashicorp/terraform-provider-aws/issues/24362), the aws_servicecatalog_provisioned_product resource fails to look this up automatically. You can find the ID manually by going to the Product List in the AWS Service Catalog console (https://console.aws.amazon.com/servicecatalog/home#admin-products), clicking the 'AWS Control Tower Account Factory' product, and grabbing the ID of the latest product version from the Product Versions table at the bottom.

null

The amount of time allowed for the read operation to take before being considered to have failed. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicecatalog_provisioned_product#timeouts

"20m"

The amount of time allowed for the update operation to take before being considered to have failed. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicecatalog_provisioned_product#timeouts

"60m"