Skip to content

Commit

Permalink
Merge pull request #3 from mineiros-io/sameh-storage-bucket
Browse files Browse the repository at this point in the history
feat: adding iam to the module
  • Loading branch information
mariux committed Oct 14, 2021
2 parents 614d68b + 9a74997 commit 39d8139
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions iam.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
locals {
iam_map = var.policy_bindings == null ? { for iam in var.iam : iam.role => iam } : tomap({})

policy_bindings = var.policy_bindings != null ? {
iam_policy = {
policy_bindings = var.policy_bindings
}
} : tomap({})
}

module "iam" {
source = "github.com/mineiros-io/terraform-google-storage-bucket-iam.git?ref=v0.0.1"

for_each = var.policy_bindings != null ? local.policy_bindings : local.iam_map

module_enabled = var.module_enabled
module_depends_on = var.module_depends_on

bucket = google_storage_bucket.bucket[0].name
role = try(each.value.role, null)
members = try(each.value.members, null)
authoritative = try(each.value.authoritative, true)
policy_bindings = try(each.value.policy_bindings, null)
}
14 changes: 14 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,20 @@ variable "object_admins" {
default = []
}

## IAM

variable "iam" {
description = "(Optional) A list of IAM access."
type = any
default = []
}

variable "policy_bindings" {
description = "(Optional) A list of IAM policy bindings."
type = any
default = null
}

# ------------------------------------------------------------------------------
# MODULE CONFIGURATION PARAMETERS
# These variables are used to configure the module.
Expand Down

0 comments on commit 39d8139

Please sign in to comment.