AWS IAM Account

This page shows how to write Terraform for IAM Account and write them securely.

aws_organizations_account (Terraform)

The Account in IAM can be configured in Terraform with the resource name aws_organizations_account. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L20
resource "aws_organizations_account" "developer_account" {
  name  = "developer-account"
  email = "developer-account@its.org"

  # Parent Organizational Unit ID
  # Defaults to the Organization default Root ID
main.tf#L20
resource "aws_organizations_account" "shared-services" {
  name = "shared-services"
  email = var.shared_services_account_email
}

#terragrunt import aws_organizations_account.development xxxxx
main.tf#L15
resource "aws_organizations_account" "shared-services" {
  name = "shared-services"
  email = var.shared_services_account_email
}

#terragrunt import aws_organizations_account.development xxxxx
organization.tf#L11
resource "aws_organizations_account" "cd" {
  name  = "thilina-thesis-cd"
  email = "dummyuser+cd@gmail.com"
}

resource "aws_organizations_account" "logging" {
accounts.tf#L1
resource "aws_organizations_account" "logging" {
  name      = var.log_name
  email     = var.log_email
  role_name = var.role_name
  parent_id = var.managed_parent
}

Parameters

Explanation in Terraform Registry

Provides a resource to create a member account in the current organization.

Note: Account management must be done from the organization's master account. !> WARNING: Deleting this Terraform resource will only remove an AWS account from an organization. Terraform will not close the account. The member account must be prepared to be a standalone account beforehand. See the AWS Organizations documentation for more information.

CloudFormation Example

CloudFormation code does not have the related resource.

Frequently asked questions

What is AWS IAM Account?

AWS IAM Account is a resource for IAM of Amazon Web Service. Settings can be wrote in Terraform.

Where can I find the example code for the AWS IAM Account?

For Terraform, the alessanderviana/its-poc, petersiemen/aws-multiple-account-ci-cd and petersiemen/cross-account-multi-region-ci-cd-pipeline-on-aws source code examples are useful. See the Terraform Example section for further details.

security-icon

Scan your IaC problem in 3 minutes for free

You can keep your IaC security for free. No credit card required.