Skip to content

Commit 5473023

Browse files
authored
[aws/accounts] do not use ssm module (#70)
* drop ssm module * Use submodule
1 parent 9de852c commit 5473023

File tree

12 files changed

+180
-396
lines changed

12 files changed

+180
-396
lines changed

aws/accounts/audit.tf

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,21 @@
1-
resource "aws_organizations_account" "audit" {
2-
count = "${contains(var.accounts_enabled, "audit") == true ? 1 : 0}"
3-
name = "audit"
4-
email = "${format(var.account_email, "audit")}"
5-
iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
6-
role_name = "${var.account_role_name}"
7-
}
8-
9-
locals {
10-
audit_account_arn = "${join("", aws_organizations_account.audit.*.arn)}"
11-
audit_account_id = "${join("", aws_organizations_account.audit.*.id)}"
12-
audit_organization_account_access_role = "arn:aws:iam::${join("", aws_organizations_account.audit.*.id)}:role/OrganizationAccountAccessRole"
13-
}
14-
15-
module "audit_parameters" {
16-
source = "git::https://github.com/cloudposse/terraform-aws-ssm-parameter-store?ref=tags/0.1.5"
17-
enabled = "${contains(var.accounts_enabled, "audit") == true ? "true" : "false"}"
18-
19-
parameter_write = [
20-
{
21-
name = "/${var.namespace}/audit/account_id"
22-
value = "${local.audit_account_id}"
23-
type = "String"
24-
overwrite = "true"
25-
description = "AWS Account ID"
26-
},
27-
{
28-
name = "/${var.namespace}/audit/account_arn"
29-
value = "${local.audit_account_arn}"
30-
type = "String"
31-
overwrite = "true"
32-
description = "AWS Account ARN"
33-
},
34-
{
35-
name = "/${var.namespace}/audit/organization_account_access_role"
36-
value = "${local.audit_organization_account_access_role}"
37-
type = "String"
38-
overwrite = "true"
39-
description = "AWS Organization Account Access Role"
40-
},
41-
]
1+
module "audit" {
2+
source = "stage"
3+
namespace = "${var.namespace}"
4+
stage = "audit"
5+
accounts_enabled = "${var.accounts_enabled}"
6+
account_email = "${var.account_email}"
7+
account_iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
8+
account_role_name = "${var.account_role_name}"
429
}
4310

4411
output "audit_account_arn" {
45-
value = "${local.audit_account_arn}"
12+
value = "${module.audit.account_arn}"
4613
}
4714

4815
output "audit_account_id" {
49-
value = "${local.audit_account_id}"
16+
value = "${module.audit.account_id}"
5017
}
5118

5219
output "audit_organization_account_access_role" {
53-
value = "${local.audit_organization_account_access_role}"
20+
value = "${module.audit.organization_account_access_role}"
5421
}

aws/accounts/corp.tf

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,21 @@
1-
resource "aws_organizations_account" "corp" {
2-
count = "${contains(var.accounts_enabled, "corp") == true ? 1 : 0}"
3-
name = "corp"
4-
email = "${format(var.account_email, "corp")}"
5-
iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
6-
role_name = "${var.account_role_name}"
7-
}
8-
9-
locals {
10-
corp_account_arn = "${join("", aws_organizations_account.corp.*.arn)}"
11-
corp_account_id = "${join("", aws_organizations_account.corp.*.id)}"
12-
corp_organization_account_access_role = "arn:aws:iam::${join("", aws_organizations_account.corp.*.id)}:role/OrganizationAccountAccessRole"
13-
}
14-
15-
module "corp_parameters" {
16-
source = "git::https://github.com/cloudposse/terraform-aws-ssm-parameter-store?ref=tags/0.1.5"
17-
enabled = "${contains(var.accounts_enabled, "corp") == true ? "true" : "false"}"
18-
19-
parameter_write = [
20-
{
21-
name = "/${var.namespace}/corp/account_id"
22-
value = "${local.corp_account_id}"
23-
type = "String"
24-
overwrite = "true"
25-
description = "AWS Account ID"
26-
},
27-
{
28-
name = "/${var.namespace}/corp/account_arn"
29-
value = "${local.corp_account_arn}"
30-
type = "String"
31-
overwrite = "true"
32-
description = "AWS Account ARN"
33-
},
34-
{
35-
name = "/${var.namespace}/corp/organization_account_access_role"
36-
value = "${local.corp_organization_account_access_role}"
37-
type = "String"
38-
overwrite = "true"
39-
description = "AWS Organization Account Access Role"
40-
},
41-
]
1+
module "corp" {
2+
source = "stage"
3+
namespace = "${var.namespace}"
4+
stage = "corp"
5+
accounts_enabled = "${var.accounts_enabled}"
6+
account_email = "${var.account_email}"
7+
account_iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
8+
account_role_name = "${var.account_role_name}"
429
}
4310

4411
output "corp_account_arn" {
45-
value = "${local.corp_account_arn}"
12+
value = "${module.corp.account_arn}"
4613
}
4714

4815
output "corp_account_id" {
49-
value = "${local.corp_account_id}"
16+
value = "${module.corp.account_id}"
5017
}
5118

5219
output "corp_organization_account_access_role" {
53-
value = "${local.corp_organization_account_access_role}"
20+
value = "${module.corp.organization_account_access_role}"
5421
}

aws/accounts/data.tf

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,21 @@
1-
resource "aws_organizations_account" "data" {
2-
count = "${contains(var.accounts_enabled, "data") == true ? 1 : 0}"
3-
name = "data"
4-
email = "${format(var.account_email, "data")}"
5-
iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
6-
role_name = "${var.account_role_name}"
7-
}
8-
9-
locals {
10-
data_account_arn = "${join("", aws_organizations_account.data.*.arn)}"
11-
data_account_id = "${join("", aws_organizations_account.data.*.id)}"
12-
data_organization_account_access_role = "arn:aws:iam::${join("", aws_organizations_account.data.*.id)}:role/OrganizationAccountAccessRole"
13-
}
14-
15-
module "data_parameters" {
16-
source = "git::https://github.com/cloudposse/terraform-aws-ssm-parameter-store?ref=tags/0.1.5"
17-
enabled = "${contains(var.accounts_enabled, "data") == true ? "true" : "false"}"
18-
19-
parameter_write = [
20-
{
21-
name = "/${var.namespace}/data/account_id"
22-
value = "${local.data_account_id}"
23-
type = "String"
24-
overwrite = "true"
25-
description = "AWS Account ID"
26-
},
27-
{
28-
name = "/${var.namespace}/data/account_arn"
29-
value = "${local.data_account_arn}"
30-
type = "String"
31-
overwrite = "true"
32-
description = "AWS Account ARN"
33-
},
34-
{
35-
name = "/${var.namespace}/data/organization_account_access_role"
36-
value = "${local.data_organization_account_access_role}"
37-
type = "String"
38-
overwrite = "true"
39-
description = "AWS Organization Account Access Role"
40-
},
41-
]
1+
module "data" {
2+
source = "stage"
3+
namespace = "${var.namespace}"
4+
stage = "data"
5+
accounts_enabled = "${var.accounts_enabled}"
6+
account_email = "${var.account_email}"
7+
account_iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
8+
account_role_name = "${var.account_role_name}"
429
}
4310

4411
output "data_account_arn" {
45-
value = "${local.data_account_arn}"
12+
value = "${module.data.account_arn}"
4613
}
4714

4815
output "data_account_id" {
49-
value = "${local.data_account_id}"
16+
value = "${module.data.account_id}"
5017
}
5118

5219
output "data_organization_account_access_role" {
53-
value = "${local.data_organization_account_access_role}"
20+
value = "${module.data.organization_account_access_role}"
5421
}

aws/accounts/dev.tf

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,21 @@
1-
resource "aws_organizations_account" "dev" {
2-
count = "${contains(var.accounts_enabled, "dev") == true ? 1 : 0}"
3-
name = "dev"
4-
email = "${format(var.account_email, "dev")}"
5-
iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
6-
role_name = "${var.account_role_name}"
7-
}
8-
9-
locals {
10-
dev_account_arn = "${join("", aws_organizations_account.dev.*.arn)}"
11-
dev_account_id = "${join("", aws_organizations_account.dev.*.id)}"
12-
dev_organization_account_access_role = "arn:aws:iam::${join("", aws_organizations_account.dev.*.id)}:role/OrganizationAccountAccessRole"
13-
}
14-
15-
module "dev_parameters" {
16-
source = "git::https://github.com/cloudposse/terraform-aws-ssm-parameter-store?ref=tags/0.1.5"
17-
enabled = "${contains(var.accounts_enabled, "dev") == true ? "true" : "false"}"
18-
19-
parameter_write = [
20-
{
21-
name = "/${var.namespace}/dev/account_id"
22-
value = "${local.dev_account_id}"
23-
type = "String"
24-
overwrite = "true"
25-
description = "AWS Account ID"
26-
},
27-
{
28-
name = "/${var.namespace}/dev/account_arn"
29-
value = "${local.dev_account_arn}"
30-
type = "String"
31-
overwrite = "true"
32-
description = "AWS Account ARN"
33-
},
34-
{
35-
name = "/${var.namespace}/dev/organization_account_access_role"
36-
value = "${local.dev_organization_account_access_role}"
37-
type = "String"
38-
overwrite = "true"
39-
description = "AWS Organization Account Access Role"
40-
},
41-
]
1+
module "dev" {
2+
source = "stage"
3+
namespace = "${var.namespace}"
4+
stage = "dev"
5+
accounts_enabled = "${var.accounts_enabled}"
6+
account_email = "${var.account_email}"
7+
account_iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
8+
account_role_name = "${var.account_role_name}"
429
}
4310

4411
output "dev_account_arn" {
45-
value = "${local.dev_account_arn}"
12+
value = "${module.dev.account_arn}"
4613
}
4714

4815
output "dev_account_id" {
49-
value = "${local.dev_account_id}"
16+
value = "${module.dev.account_id}"
5017
}
5118

5219
output "dev_organization_account_access_role" {
53-
value = "${local.dev_organization_account_access_role}"
20+
value = "${module.dev.organization_account_access_role}"
5421
}

aws/accounts/identity.tf

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,21 @@
1-
resource "aws_organizations_account" "identity" {
2-
count = "${contains(var.accounts_enabled, "identity") == true ? 1 : 0}"
3-
name = "identity"
4-
email = "${format(var.account_email, "identity")}"
5-
iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
6-
role_name = "${var.account_role_name}"
7-
}
8-
9-
locals {
10-
identity_account_arn = "${join("", aws_organizations_account.identity.*.arn)}"
11-
identity_account_id = "${join("", aws_organizations_account.identity.*.id)}"
12-
identity_organization_account_access_role = "arn:aws:iam::${join("", aws_organizations_account.identity.*.id)}:role/OrganizationAccountAccessRole"
13-
}
14-
15-
module "identity_parameters" {
16-
source = "git::https://github.com/cloudposse/terraform-aws-ssm-parameter-store?ref=tags/0.1.5"
17-
enabled = "${contains(var.accounts_enabled, "identity") == true ? "true" : "false"}"
18-
19-
parameter_write = [
20-
{
21-
name = "/${var.namespace}/identity/account_id"
22-
value = "${local.identity_account_id}"
23-
type = "String"
24-
overwrite = "true"
25-
description = "AWS Account ID"
26-
},
27-
{
28-
name = "/${var.namespace}/identity/account_arn"
29-
value = "${local.identity_account_arn}"
30-
type = "String"
31-
overwrite = "true"
32-
description = "AWS Account ARN"
33-
},
34-
{
35-
name = "/${var.namespace}/identity/organization_account_access_role"
36-
value = "${local.identity_organization_account_access_role}"
37-
type = "String"
38-
overwrite = "true"
39-
description = "AWS Organization Account Access Role"
40-
},
41-
]
1+
module "identity" {
2+
source = "stage"
3+
namespace = "${var.namespace}"
4+
stage = "identity"
5+
accounts_enabled = "${var.accounts_enabled}"
6+
account_email = "${var.account_email}"
7+
account_iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
8+
account_role_name = "${var.account_role_name}"
429
}
4310

4411
output "identity_account_arn" {
45-
value = "${local.identity_account_arn}"
12+
value = "${module.identity.account_arn}"
4613
}
4714

4815
output "identity_account_id" {
49-
value = "${local.identity_account_id}"
16+
value = "${module.identity.account_id}"
5017
}
5118

5219
output "identity_organization_account_access_role" {
53-
value = "${local.identity_organization_account_access_role}"
20+
value = "${module.identity.organization_account_access_role}"
5421
}

aws/accounts/prod.tf

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,21 @@
1-
resource "aws_organizations_account" "prod" {
2-
count = "${contains(var.accounts_enabled, "prod") == true ? 1 : 0}"
3-
name = "prod"
4-
email = "${format(var.account_email, "prod")}"
5-
iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
6-
role_name = "${var.account_role_name}"
7-
}
8-
9-
locals {
10-
prod_account_arn = "${join("", aws_organizations_account.prod.*.arn)}"
11-
prod_account_id = "${join("", aws_organizations_account.prod.*.id)}"
12-
prod_organization_account_access_role = "arn:aws:iam::${join("", aws_organizations_account.prod.*.id)}:role/OrganizationAccountAccessRole"
13-
}
14-
15-
module "prod_parameters" {
16-
source = "git::https://github.com/cloudposse/terraform-aws-ssm-parameter-store?ref=tags/0.1.5"
17-
enabled = "${contains(var.accounts_enabled, "prod") == true ? "true" : "false"}"
18-
19-
parameter_write = [
20-
{
21-
name = "/${var.namespace}/prod/account_id"
22-
value = "${local.prod_account_id}"
23-
type = "String"
24-
overwrite = "true"
25-
description = "AWS Account ID"
26-
},
27-
{
28-
name = "/${var.namespace}/prod/account_arn"
29-
value = "${local.prod_account_arn}"
30-
type = "String"
31-
overwrite = "true"
32-
description = "AWS Account ARN"
33-
},
34-
{
35-
name = "/${var.namespace}/prod/organization_account_access_role"
36-
value = "${local.prod_organization_account_access_role}"
37-
type = "String"
38-
overwrite = "true"
39-
description = "AWS Organization Account Access Role"
40-
},
41-
]
1+
module "prod" {
2+
source = "stage"
3+
namespace = "${var.namespace}"
4+
stage = "prod"
5+
accounts_enabled = "${var.accounts_enabled}"
6+
account_email = "${var.account_email}"
7+
account_iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
8+
account_role_name = "${var.account_role_name}"
429
}
4310

4411
output "prod_account_arn" {
45-
value = "${local.prod_account_arn}"
12+
value = "${module.prod.account_arn}"
4613
}
4714

4815
output "prod_account_id" {
49-
value = "${local.prod_account_id}"
16+
value = "${module.prod.account_id}"
5017
}
5118

5219
output "prod_organization_account_access_role" {
53-
value = "${local.prod_organization_account_access_role}"
20+
value = "${module.prod.organization_account_access_role}"
5421
}

0 commit comments

Comments
 (0)