Skip to content

Commit

Permalink
sys: assume dashes in iam_prefix (#34)
Browse files Browse the repository at this point in the history
* sys: assume dashes in iam_prefix

* fix typo
  • Loading branch information
hectorhuertas authored Feb 28, 2019
1 parent 89a07f9 commit d26e958
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cfssl.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IAM instance role
resource "aws_iam_role" "cfssl" {
name = "${var.iam_prefix}${var.cluster_name}-cfssl"
name = "${local.iam_prefix}${var.cluster_name}-cfssl"
path = "${var.iam_path}"
permissions_boundary = "${var.permissions_boundary}"

Expand All @@ -21,7 +21,7 @@ EOS
}

resource "aws_iam_instance_profile" "cfssl" {
name = "${var.iam_prefix}${var.cluster_name}-cfssl"
name = "${local.iam_prefix}${var.cluster_name}-cfssl"
role = "${aws_iam_role.cfssl.name}"
path = "${var.iam_path}"
}
Expand Down
4 changes: 2 additions & 2 deletions etcd.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IAM instance role
resource "aws_iam_role" "etcd" {
name = "${var.iam_prefix}${var.cluster_name}-etcd"
name = "${local.iam_prefix}${var.cluster_name}-etcd"
path = "${var.iam_path}"
permissions_boundary = "${var.permissions_boundary}"

Expand All @@ -21,7 +21,7 @@ EOS
}

resource "aws_iam_instance_profile" "etcd" {
name = "${var.iam_prefix}${var.cluster_name}-etcd"
name = "${local.iam_prefix}${var.cluster_name}-etcd"
role = "${aws_iam_role.etcd.name}"
path = "${var.iam_path}"
}
Expand Down
6 changes: 3 additions & 3 deletions masters.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IAM instance role
resource "aws_iam_role" "master" {
name = "${var.iam_prefix}${var.cluster_name}-master"
name = "${local.iam_prefix}${var.cluster_name}-master"
path = "${var.iam_path}"
permissions_boundary = "${var.permissions_boundary}"

Expand All @@ -19,13 +19,13 @@ EOS
}

resource "aws_iam_instance_profile" "master" {
name = "${var.iam_prefix}${var.cluster_name}-master"
name = "${local.iam_prefix}${var.cluster_name}-master"
role = "${aws_iam_role.master.name}"
path = "${var.iam_path}"
}

resource "aws_iam_role_policy" "master" {
name = "${var.iam_prefix}${var.cluster_name}_master"
name = "${local.iam_prefix}${var.cluster_name}-master"
role = "${aws_iam_role.master.id}"

policy = <<EOS
Expand Down
4 changes: 4 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,7 @@ variable "worker_target_group_arns" {
description = "A list of ALB Target Group ARNs to register the worker instances with."
type = "list"
}

locals {
iam_prefix = "${var.iam_prefix}${var.iam_prefix == "" ? "" : "-"}"
}
6 changes: 3 additions & 3 deletions workers.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IAM instance role
resource "aws_iam_role" "worker" {
name = "${var.iam_prefix}${var.cluster_name}-worker"
name = "${local.iam_prefix}${var.cluster_name}-worker"
path = "${var.iam_path}"
permissions_boundary = "${var.permissions_boundary}"

Expand All @@ -21,13 +21,13 @@ EOS
}

resource "aws_iam_instance_profile" "worker" {
name = "${var.iam_prefix}${var.cluster_name}-worker"
name = "${local.iam_prefix}${var.cluster_name}-worker"
role = "${aws_iam_role.worker.name}"
path = "${var.iam_path}"
}

resource "aws_iam_role_policy" "worker" {
name = "${var.iam_prefix}${var.cluster_name}-worker"
name = "${local.iam_prefix}${var.cluster_name}-worker"
role = "${aws_iam_role.worker.id}"

policy = <<EOS
Expand Down

0 comments on commit d26e958

Please sign in to comment.