Skip to content

Commit 9134bdc

Browse files
Merge pull request #3 from gozer/issue/2/iam_deploy
Add iam_deploy option, defaults to true
2 parents 1816d35 + 2d50978 commit 9134bdc

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Here's the gist of using it directly from github.
138138
| bucket | Backup and Restore bucket. | `string` | n/a | yes |
139139
| cluster\_name | Cluster name. | `string` | n/a | yes |
140140
| description | Namespace description | `string` | `"velero-back-up-and-restore"` | no |
141+
| iam\_deploy | whther or not to deploy iam role | `bool` | `true` | no |
141142
| iam\_role\_name | Name of the Velero IAM role | `string` | `""` | no |
142143
| name | namespace name | `string` | `"velero"` | no |
143144
| namespace\_deploy | whther or not to deploy namespace | `bool` | `false` | no |

iam.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ data aws_iam_policy_document policy {
6262
}
6363

6464
resource aws_iam_role this {
65+
count = var.iam_deploy ? 1 : 0
6566
name = var.iam_role_name == "" ? format("%s-%s", var.cluster_name, var.name) : var.iam_role_name
67+
6668
assume_role_policy = data.aws_iam_policy_document.assume_role.json
6769
tags = merge(var.tags,
6870
{ Attached = var.name },
@@ -72,7 +74,8 @@ resource aws_iam_role this {
7274
}
7375

7476
resource aws_iam_role_policy this {
77+
count = var.iam_deploy ? 1 : 0
7578
name = format("%s-%s", var.cluster_name, var.name)
76-
role = aws_iam_role.this.id
79+
role = element(aws_iam_role.this.*.id, 0)
7780
policy = data.aws_iam_policy_document.policy.json
7881
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ variable "app_deploy" {
1515
type = bool
1616
}
1717

18+
variable "iam_deploy" {
19+
default = true
20+
description = "whther or not to deploy iam role"
21+
type = bool
22+
}
23+
1824
variable "name" {
1925
default = "velero"
2026
description = "namespace name"

0 commit comments

Comments
 (0)