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

Add hotfix for Terraform "count" issue #1

Merged
merged 3 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
locals {
assume_policy = var.assume_policy != null ? var.assume_policy : data.aws_iam_policy_document.default.json
create_policy = var.force_create_policy != null ? (var.force_create_policy ? 1 : 0): (var.role_policy != "" ? 1 : 0)
}

provider "aws" {}
Expand All @@ -23,7 +24,7 @@ resource "aws_iam_role" "default" {
}

resource "aws_iam_role_policy" "default" {
count = var.role_policy != "" ? 1 : 0
count = local.create_policy
name = "${var.name}${var.postfix ? "Policy" : ""}"
role = aws_iam_role.default.id
policy = var.role_policy
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ variable "assume_policy" {
description = "The assume policy to attach to the role"
}

variable "force_create_policy" {
type = bool
default = null
description = "Overrule whether the role policy has to be created."
}

variable "principal_type" {
type = string
default = ""
Expand Down