Skip to main content
Terraform is an optional alternative to the CloudFormation-based console setup. Each option below creates the same resources as the CloudFormation template, which remains the canonical definition. See AWS IAM resources for what each resource does.

Prerequisites

  • Terraform 1.1 or later, or any OpenTofu release
  • AWS provider 5.67.0 or later. The StackSet option depends on the aws_cloudformation_stack_instances resource added in that version
  • AWS credentials with permission to create IAM roles and policies in the target account
  • The External ID from the Draftt setup dialog (Integrations > AWS)
All options use the AWS provider. Declare it once in your configuration:

Setup methods

Creates the IAM role, trust policy, and permissions directly as Terraform resources. This gives you full control over the role, including tags, a permissions boundary, or a custom path.
1

Download the read-only policy

Save the published policy next to your Terraform files so permission changes are reviewed in your own pull requests:
2

Declare the trust policy

Only the draftt-fetcher role in Draftt’s AWS account can assume the role, and only with your External ID:
3

Create the role

Draftt requests 30-minute sessions, which fit within the default one-hour maximum session duration:
4

Attach the AWS managed policies

5

Attach DrafttReadOnlyPolicy

The policy is attached inline, matching the CloudFormation template. Decoding and re-encoding the file validates it at plan time and normalises whitespace:
6

Declare inputs and outputs

7

Plan and apply

Provide the External ID through a variable file or environment variable rather than on the command line:
The plan shows one role, one inline policy, and two policy attachments.
8

Enter the Role ARN in Draftt

Copy the draftt_role_arn output into the Role ARN field in the Draftt setup dialog and click Create.
Deploys Draftt’s published CloudFormation template as a Terraform-managed stack. Terraform tracks the stack, and CloudFormation creates the role and policies exactly as the console setup does. Use this to keep the template canonical without maintaining a copy of the read-only policy.
1

Create the stack

2

Declare inputs and outputs

3

Plan and apply

The plan shows a single CloudFormation stack. The role and policies appear in the CloudFormation console under the stack’s resources.
4

Enter the Role ARN in Draftt

Copy the draftt_role_arn output into the Role ARN field in the Draftt setup dialog and click Create.
The template echoes the External ID in the ExternalID stack output, so it is visible to anyone with cloudformation:DescribeStacks in the account. The stack outputs are also stored in Terraform state.
Apply in the organization management account. Creates the organization-level role and a service-managed StackSet that deploys the per-account role to every member account. Requires CloudFormation StackSets trusted access in AWS Organizations.
Delegated StackSets administrator accounts are not supported. Draftt reads the StackSet status without the delegated-administrator call mode, so a StackSet owned by a delegated administrator is not visible to Draftt.
1

Declare the trust policy

The organization-level role uses the same trust policy and External ID as the per-account role:
2

Create the organization-level role

3

Attach the AWS managed policies

Draftt uses these to list member accounts and read the StackSet rollout status:
4

Create the StackSet

5

Deploy the stack instances

IAM is global, so a single region is enough. Target the organization root to cover every account, or specific organizational units:
6

Declare inputs and outputs

7

Plan and apply

Confirm every target account shows SUCCEEDED under the StackSet’s stack instances before continuing. Draftt waits up to 30 minutes for the rollout and only connects accounts that succeeded.
8

Enter the ARNs in Draftt

Copy the draftt_organization_role_arn output into the organization Role ARN field, and the draftt_stack_set_arn output into the StackSet ARN field in the Draftt setup dialog.
Destroying aws_cloudformation_stack_instances removes the Draftt role from every member account at once. To stop onboarding new accounts without touching existing ones, set auto_deployment.enabled to false instead.

Notes

Because the External ID is marked sensitive, Terraform hides the whole rendered trust policy in plan output. To review the trust policy after apply, run aws iam get-role --role-name DrafttAccess-Role. The External ID is still stored in Terraform state, so protect your state file as you would any other secret.
Do not import a role or policy created by a CloudFormation stack into the Single Account option. CloudFormation keeps ownership of those resources, and deleting the stack later deletes the role even though Terraform tracks it.