Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for multi account. #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions master-account/accounts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,18 @@
// | |- testing
// | |- development
// | |- forensics



// TODO loop over local.subaccounts
// Docs: https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_create.html
// To set password go to root sign up and enter email
resource "aws_organizations_account" "main" {
count = "${length(var.sub_accounts)}"
name = "${var.sub_accounts[count.index]}"
email = "${local.account_email_local_part}+${var.sub_accounts[count.index]}@${local.account_email_domain}"
iam_user_access_to_billing = "DENY"
count = "${length(var.sub_accounts)}"
name = "${var.sub_accounts[count.index]}"
email = "${local.account_email_local_part}+${var.sub_accounts[count.index]}@${local.account_email_domain}"

#iam_user_access_to_billing = "DENY"
}

# Org Units - TODO https://github.com/terraform-providers/terraform-provider-aws/pull/4207



// https://www.terraform.io/docs/providers/aws/r/organizations_policy_attachment.html
//resource "aws_organizations_policy_attachment" "environments" {
// policy_id = "${aws_organizations_policy.environments.id}"
Expand All @@ -44,3 +39,4 @@ resource "aws_organizations_account" "main" {
//}
//POLICY
//}

10 changes: 4 additions & 6 deletions master-account/main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

resource "aws_organizations_organization" "account" {
feature_set = "ALL"
}
# resource "aws_organizations_organization" "account" {
# feature_set = "ALL"
# }

resource "aws_iam_account_alias" "alias" {
count = "${var.account_alias == "" ? 0 : 1}"
count = "${var.account_alias == "" ? 0 : 1}"
account_alias = "${var.account_alias}"
}

11 changes: 6 additions & 5 deletions master-account/variables.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
variable "name" {}

variable "account_alias" {
type = "string"
type = "string"
default = ""
}

//
variable "roles" {
type = "list"
default = ["admin","developer"]
type = "list"
default = ["admin", "developer"]
}

// {username:[role,role]}
Expand All @@ -20,19 +21,19 @@ variable "roles" {
// type = "string"
//}


variable "account_email" {
description = "Organization account email"
}

variable "sub_accounts" {
type = "list"

default = [
"operations",
"production",
"staging",
"testing",
"development",
"forensics"
"forensics",
]
}
4 changes: 2 additions & 2 deletions user/send-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ENC_PASSWORD="$5" # PGP encrypted password
# PASSWORD=$(base64 --decode | keybase pgp decrypt)

# Create a temporary file to store the encrypted binary data.
password_file=$(mktemp "password.${USERNAME}.gpg")
password_file=$(mktemp "password.${USERNAME}.gpg.XXXXX")
kkirov marked this conversation as resolved.
Show resolved Hide resolved

# Decode the Base64 password and store it in password file.
echo "$ENC_PASSWORD" | base64 --decode > "$password_file"
Expand All @@ -40,7 +40,7 @@ PASSWORD=$(gpg -q --decrypt "$password_file")
rm "$password_file"

# Create a temporary file to store the HTML email body.
message_file=$(mktemp "message.${USERNAME}.html")
message_file=$(mktemp "message.${USERNAME}.html.XXXXX")

# Replace username and passwords with correct values.
cat "$DIR/send-email.html.tpl" > ${message_file}
Expand Down