Skip to main content

Module: organization-access-group

Terraform module to create an IAM Group and Policy to grant permissions to delegated IAM users in the Organization's master account to access a member account

https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_access.html

Introduction

By default, when you create a member account as part of your Organization, AWS automatically creates OrganizationAccountAccessRole in the member account.

The role grants admin permissions to access the member account to delegated IAM users in the master account.

In the master account you need to create a Policy to grant permissions to IAM users to assume OrganizationAccountAccessRole in the member account.

This module does the following:

  1. Creates an IAM Group
  2. Adds the provided IAM users to the Group
  3. Creates a Policy to grant permissions to the IAM users in the master account to assume OrganizationAccountAccessRole in the member account
  4. Attaches the Policy to the Group

Users who are members of the Group will be able to assume the role and administer the member account by going here:

(change XXXXXXXXXXXX to the ID of the member account)

https://signin.aws.amazon.com/switchrole
?account=XXXXXXXXXXXX
&roleName=OrganizationAccountAccessRole
&displayName=Dev

NOTE: Member accounts that you invite to join your Organization (that are not part of your Organization) do not automatically get OrganizationAccountAccessRole created. You can use terraform-aws-organization-access-role module to create OrganizationAccountAccessRole role in an invited member account.


Usage

module "organization_access_group" {
source = "git::https://github.com/cloudposse/terraform-aws-organization-access-group.git?ref=master"
namespace = "cp"
stage = "dev"
name = "cluster"
user_names = ["User1","User2"]
role_arns = {
"cp@dev" = "arn:aws:iam::XXXXXXXXX:role/OrganizationAccountAccessRole"
}
require_mfa = "true"
}

Requirements

No requirements.

Providers

NameVersion
awsn/a
nulln/a

Modules

NameSourceVersion
labelgit::https://github.com/cloudposse/terraform-null-label.gittags/0.3.3

Resources

NameType
aws_iam_group.defaultresource
aws_iam_group_policy.with_mfaresource
aws_iam_group_policy.without_mfaresource
aws_iam_user_group_membership.defaultresource
null_resource.roleresource
aws_iam_policy_document.with_mfadata source
aws_iam_policy_document.without_mfadata source

Inputs

NameDescriptionTypeDefaultRequired
attributesAdditional attributes (e.g. 1)list(string)[]no
delimiterDelimiter to be used between namespace, stage, name, and attributesstring"-"no
enabledWhether to create these resourcesstring"true"no
nameName (e.g. app or cluster)stringn/ayes
namespaceNamespace (e.g. cp or cloudposse)stringn/ayes
require_mfaRequire the users to have MFA enabledstring"false"no
role_arnsA map of alias -> IAM Role ARNs the users in the Group can assumemap(string){}no
stageStage (e.g. prod, dev, staging, infra)stringn/ayes
switchrole_url_templateURL template for the IAM console to switch to the rolesstring"https://signin.aws.amazon.com/switchrole?account=%s&roleName=%s&displayName=%s"no
tagsAdditional tags (e.g. map(BusinessUnit,XYZ)map(string){}no
user_namesA list of IAM User names to associate with the Grouplist(string)n/ayes

Outputs

NameDescription
group_arnThe ARN assigned by AWS for the Group
group_idThe Group's ID
group_nameThe Group's name
group_unique_idGroup's unique ID assigned by AWS
policy_idThe policy ID
policy_nameThe name of the policy
switchrole_urlsList of URL to the IAM console to switch to the roles