Skip to content

Commit

Permalink
v2.0.1: add contact, reference
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Aug 15, 2019
1 parent 2099b67 commit d338d77
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* v1.0.0 tag initial release

* v2.0.0 terraform 0.12 support
* v2.0.1 add contact, reference

31 changes: 28 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* for terraform 0.11 v1.x use tf-0.11
* for terraform 0.12 v2.x use tf-0.12 (until rolled into head) or specific version v2.x.y
* master
*
* ```code
* module "scanner" {
Expand All @@ -11,6 +12,8 @@
*
* group = "g-audit-group"
* users = [ "s-ois-scan" ]
* contact = "badra001"
* reference = "INC1234"
* email_addresses = [ "ois.compliance.scanning.group@census.gov" ]
* create_access_keys = true
* pgp_key = file(filename.b64)
Expand All @@ -21,6 +24,27 @@
locals {
# security-audit-policies = [ data.aws_iam_policy.aws-managed-security-audit.arn, aws_iam_policy.audit.arn ]
enable_access_keys = var.create_access_keys ? length(var.users) : 0
contact = lower(var.contact)
email_address = join(",",[for e in var.email_address: lower(e)])
tags_contact = {
exists = {
"boc:id:username" = local.contact
}
not_exists = { }
}
tags_contact = map("boc:id:username",local.contact)
tags_email = map("boc:id:mail",local.email_address)
tags_reference = {
exists = {
"boc:id:reference" = var.reference
}
not_exists = { }
}
tags = merge(
local.tags_contact[var.contact != "" ? "exists" : "not_exists"]
local.tags_email,
local.tags_reference[var.reference != "" ? "exists" : "not_exists"]
)
}

#---
Expand All @@ -39,9 +63,10 @@ data "aws_arn" "current" {
resource "aws_iam_user" "audit" {
count = length(var.users)
name = var.users[count.index]
tags = {
"EmailAddress" = var.email_addresses[count.index]
}
tags = local.tags
# tags = {
# "EmailAddress" = var.email_addresses[count.index]
# }
}

#---
Expand Down
15 changes: 13 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ variable "users" {
description = "Security Audit IAM user name(s)"

type = list(string)
default = ["s-inf-security-audit"]
default = [ "s-inf-security-audit" ]
}

variable "email_addresses" {
description = "Security Audit IAM Email Contact List(s)"

type = list(string)
default = ["ois.compliance.scanning.group@census.gov"]
default = [ "ois.compliance.scanning.group@census.gov" ]
}

variable "policy" {
Expand All @@ -34,3 +34,14 @@ variable "pgp_key" {
# default = ""
}

variable "contact" {
description = "Census username contact"
type = string
default = ""
}

variable "reference" {
description = "Remedy ticket reference number for the user"
type = string
default = ""
}

0 comments on commit d338d77

Please sign in to comment.