-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws_environment_accounts.tf
46 lines (38 loc) · 1.35 KB
/
aws_environment_accounts.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Set up the organization
resource "aws_organizations_organization" "org" {
aws_service_access_principals = [
"cloudtrail.amazonaws.com",
"config.amazonaws.com",
"sso.amazonaws.com",
]
feature_set = "ALL"
}
# Create a new OU for environment accounts
resource "aws_organizations_organizational_unit" "environments" {
name = "environments"
parent_id = aws_organizations_organization.org.roots[0].id
}
# Create a new AWS account called "dev"
resource "aws_organizations_account" "dev" {
name = "dev"
email = lookup(var.account_emails, "dev")
role_name = var.iam_account_role_name
parent_id = aws_organizations_organizational_unit.environments.id
depends_on = [aws_organizations_organization.org]
}
# Create a new AWS account called "test"
resource "aws_organizations_account" "test" {
name = "test"
email = lookup(var.account_emails, "test")
role_name = var.iam_account_role_name
parent_id = aws_organizations_organizational_unit.environments.id
depends_on = [aws_organizations_organization.org]
}
# Create a new AWS account called "prod"
resource "aws_organizations_account" "prod" {
name = "prod"
email = lookup(var.account_emails, "prod")
role_name = var.iam_account_role_name
parent_id = aws_organizations_organizational_unit.environments.id
depends_on = [aws_organizations_organization.org]
}