Skip to content

Commit 166b2d4

Browse files
authored
[aws/users,aws/account-settings] new modules (#45)
* add iam settings and scaffolding for user account creation * add signin url local * Add email template * Fix formatting * use data provider output for account alias * remove redundant group
1 parent ad771d9 commit 166b2d4

File tree

7 files changed

+146
-0
lines changed

7 files changed

+146
-0
lines changed

aws/account-settings/main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
terraform {
2+
required_version = ">= 0.11.2"
3+
4+
backend "s3" {}
5+
}
6+
7+
provider "aws" {
8+
assume_role {
9+
role_arn = "${var.aws_assume_role_arn}"
10+
}
11+
}
12+
13+
module "account_settings" {
14+
source = "git::https://github.com/cloudposse/terraform-aws-iam-account-settings.git?ref=tags/0.1.0"
15+
namespace = "${var.namespace}"
16+
stage = "${var.stage}"
17+
name = "${var.name}"
18+
enabled = "${var.enabled}"
19+
}

aws/account-settings/outputs.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "account_alias" {
2+
value = "${module.account_settings.account_alias}"
3+
}
4+
5+
output "signin_url" {
6+
value = "${module.account_settings.signin_url}"
7+
}

aws/account-settings/variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
variable "aws_assume_role_arn" {
2+
type = "string"
3+
}
4+
5+
variable "namespace" {
6+
type = "string"
7+
description = "Namespace (e.g. `cp` or `cloudposse`)"
8+
}
9+
10+
variable "stage" {
11+
type = "string"
12+
description = "Stage (e.g. `prod`, `dev`, `staging`)"
13+
}
14+
15+
variable "name" {
16+
type = "string"
17+
description = "Application or solution name (e.g. `app`)"
18+
default = "account"
19+
}
20+
21+
variable "enabled" {
22+
description = "Whether or not to create the IAM account alias"
23+
default = "true"
24+
}

aws/root-iam/root.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ module "organization_access_group_root" {
1919
admin_user_names = ["${var.root_account_admin_user_names}"]
2020
readonly_user_names = ["${var.root_account_readonly_user_names}"]
2121
}
22+
23+
output "admin_group" {
24+
value = "${module.organization_access_group_root.group_admin_name}"
25+
}
26+
27+
output "readonly_group" {
28+
value = "${module.organization_access_group_root.group_readonly_name}"
29+
}

aws/users/main.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
terraform {
2+
required_version = ">= 0.11.2"
3+
4+
backend "s3" {}
5+
}
6+
7+
provider "aws" {
8+
assume_role {
9+
role_arn = "${var.aws_assume_role_arn}"
10+
}
11+
}
12+
13+
data "terraform_remote_state" "account_settings" {
14+
backend = "s3"
15+
16+
config {
17+
bucket = "${var.namespace}-${var.stage}-terraform-state"
18+
key = "account-settings/terraform.tfstate"
19+
}
20+
}
21+
22+
data "terraform_remote_state" "root_iam" {
23+
backend = "s3"
24+
25+
config {
26+
bucket = "${var.namespace}-${var.stage}-terraform-state"
27+
key = "root-iam/terraform.tfstate"
28+
}
29+
}
30+
31+
locals {
32+
account_alias = "${data.terraform_remote_state.account_settings.account_alias}"
33+
signin_url = "${data.terraform_remote_state.account_settings.signin_url}"
34+
admin_groups = ["${data.terraform_remote_state.root_iam.admin_group}"]
35+
readonly_groups = ["${data.terraform_remote_state.root_iam.readonly_group}"]
36+
}
37+
38+
output "account_alias" {
39+
value = "${local.account_alias}"
40+
}

aws/users/variables.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
variable "aws_assume_role_arn" {}
2+
3+
variable "namespace" {
4+
type = "string"
5+
description = "Namespace (e.g. `cp` or `cloudposse`)"
6+
}
7+
8+
variable "stage" {
9+
type = "string"
10+
description = "Stage (e.g. `prod`, `dev`, `staging`)"
11+
}
12+
13+
variable "name" {
14+
type = "string"
15+
description = "Application or solution name (e.g. `app`)"
16+
default = "terraform"
17+
}
18+
19+
variable "smtp_username" {
20+
description = "Username to authenticate with the SMTP server"
21+
type = "string"
22+
}
23+
24+
variable "smtp_password" {
25+
description = "Password to authenticate with the SMTP server"
26+
type = "string"
27+
}
28+
29+
variable "smtp_host" {
30+
description = "SMTP Host"
31+
default = "smtp.mailgun.org"
32+
}
33+
34+
variable "smtp_port" {
35+
description = "SMTP Port"
36+
default = "587"
37+
}

aws/users/welcome.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Welcome! Here are your AWS login credentials. They've been encrypted using your Keybase public key for safety.
2+
3+
Sign-in URL: ${signin_url}
4+
5+
Username: ${username}
6+
7+
To retrieve your password, run the following command:
8+
9+
```
10+
${password_decrypt_command}
11+
```

0 commit comments

Comments
 (0)