Skip to content

Commit a76b963

Browse files
authored
Add projects from root stage. Add account project (#10)
* Add projects from `root` stage. Add `account` project * Rename to `accounts` * Add `account-dns` * Update `accounts` and `iam` projects
1 parent 955e3d0 commit a76b963

37 files changed

+437
-44
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ This is a collection of reusable root modules for CloudPosse AWS accounts.
1111
Use the `terraform-root-modules` Docker image as the base image in the application `Dockerfile`, and copy the modules from `/aws` folder into `/conf` folder
1212

1313
```dockerfile
14-
FROM cloudposse/terraform-root-modules:0.1.6 as terraform-root-modules
14+
FROM cloudposse/terraform-root-modules:0.2.2 as terraform-root-modules
1515

16-
FROM cloudposse/geodesic:0.9.16
16+
FROM cloudposse/geodesic:0.9.18
1717

1818
# Copy root modules into /conf folder
1919
COPY --from=terraform-root-modules /aws/ /conf/

aws/account-dns/main.tf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
terraform {
2+
required_version = ">= 0.11.2"
3+
4+
backend "s3" {}
5+
}
6+
7+
variable "aws_assume_role_arn" {
8+
type = "string"
9+
}
10+
11+
variable "domain_name" {
12+
type = "string"
13+
description = "Domain name"
14+
}
15+
16+
provider "aws" {
17+
assume_role {
18+
role_arn = "${var.aws_assume_role_arn}"
19+
}
20+
}
21+
22+
resource "aws_route53_zone" "dns_zone" {
23+
name = "${var.domain_name}"
24+
}
25+
26+
resource "aws_route53_record" "dns_zone_soa" {
27+
zone_id = "${aws_route53_zone.dns_zone.id}"
28+
name = "${aws_route53_zone.dns_zone.name}"
29+
type = "SOA"
30+
ttl = "60"
31+
32+
records = [
33+
"${aws_route53_zone.dns_zone.name_servers.0}. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400",
34+
]
35+
}
36+
37+
output "zone_id" {
38+
value = "${aws_route53_zone.dns_zone.zone_id}"
39+
}
40+
41+
output "name_servers" {
42+
value = "${aws_route53_zone.dns_zone.name_servers}"
43+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
audit_account_name="audit"
2+
audit_account_email="[email protected]"

aws/accounts/audit.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
variable "audit_account_name" {
2+
type = "string"
3+
description = "Audit account name"
4+
default = "audit"
5+
}
6+
7+
variable "audit_account_email" {
8+
type = "string"
9+
description = "Audit account email"
10+
}
11+
12+
resource "aws_organizations_account" "audit" {
13+
name = "${var.audit_account_name}"
14+
email = "${var.audit_account_email}"
15+
iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
16+
role_name = "${var.account_role_name}"
17+
}
18+
19+
output "audit_account_arn" {
20+
value = "${aws_organizations_account.audit.arn}"
21+
}

aws/accounts/dev.auto.tfvars.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dev_account_name="dev"
2+
dev_account_email="[email protected]"

aws/accounts/dev.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
variable "dev_account_name" {
2+
type = "string"
3+
description = "Dev account name"
4+
default = "dev"
5+
}
6+
7+
variable "dev_account_email" {
8+
type = "string"
9+
description = "Dev account email"
10+
}
11+
12+
resource "aws_organizations_account" "dev" {
13+
name = "${var.dev_account_name}"
14+
email = "${var.dev_account_email}"
15+
iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
16+
role_name = "${var.account_role_name}"
17+
}
18+
19+
output "dev_account_arn" {
20+
value = "${aws_organizations_account.dev.arn}"
21+
}

aws/accounts/main.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
terraform {
2+
required_version = ">= 0.11.2"
3+
4+
backend "s3" {}
5+
}
6+
7+
variable "aws_assume_role_arn" {
8+
type = "string"
9+
}
10+
11+
variable "account_role_name" {
12+
type = "string"
13+
description = "IAM role that Organization automatically preconfigures in the new member account"
14+
default = "OrganizationAccountAccessRole"
15+
}
16+
17+
variable "account_iam_user_access_to_billing" {
18+
type = "string"
19+
description = "If set to `ALLOW`, the new account enables IAM users to access account billing information if they have the required permissions. If set to `DENY`, then only the root user of the new account can access account billing information"
20+
default = "DENY"
21+
}
22+
23+
provider "aws" {
24+
assume_role {
25+
role_arn = "${var.aws_assume_role_arn}"
26+
}
27+
}

aws/accounts/prod.auto.tfvars.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
prod_account_name="prod"
2+
prod_account_email="[email protected]"

aws/accounts/prod.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
variable "prod_account_name" {
2+
type = "string"
3+
description = "Production account name"
4+
default = "prod"
5+
}
6+
7+
variable "prod_account_email" {
8+
type = "string"
9+
description = "Production account email"
10+
}
11+
12+
resource "aws_organizations_account" "prod" {
13+
name = "${var.prod_account_name}"
14+
email = "${var.prod_account_email}"
15+
iam_user_access_to_billing = "${var.account_iam_user_access_to_billing}"
16+
role_name = "${var.account_role_name}"
17+
}
18+
19+
output "prod_account_arn" {
20+
value = "${aws_organizations_account.prod.arn}"
21+
}

0 commit comments

Comments
 (0)