From 3aa1e7425885900d6471fa7240270098eb1399fe Mon Sep 17 00:00:00 2001 From: Tim Hartmann Date: Wed, 6 Sep 2017 16:00:05 -0400 Subject: [PATCH] Replaced IAM names with name_prefix (#18) * Replaced IAM names with name_prefix This replaces all the IAM Name values, with `name_prefix` thus ensuring unique names. I'm not sure I *don't* think this is awful. But - meh - it'll allow this module to be used more easily across regions. * This should now include the correct offsets This should now inlcude the correct charecter offsets for a 26 charecter prefix, based on the IAM resource limits found here https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-limits.html * This compiles correctly Not sure why, as 32+26 = 58 not 64... maybe I'm reading the doc wrong? --- iam.tf | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/iam.tf b/iam.tf index 7bbbed9..fbc816e 100644 --- a/iam.tf +++ b/iam.tf @@ -1,12 +1,12 @@ resource "aws_iam_instance_profile" "ecs_profile" { - name = "tf-created-AmazonECSContainerProfile-${var.name}" - role = "${aws_iam_role.ecs-role.name}" - path = "${var.iam_path}" + name_prefix = "${replace(format("%.102s", replace("tf-ECSProfile-${var.name}-", "_", "-")), "/\\s/", "-")}" + role = "${aws_iam_role.ecs-role.name}" + path = "${var.iam_path}" } resource "aws_iam_role" "ecs-role" { - name = "tf-AmazonECSInstanceRole-${var.name}" - path = "${var.iam_path}" + name_prefix = "${replace(format("%.32s", replace("tf-ECSInRole-${var.name}-", "_", "-")), "/\\s/", "-")}" + path = "${var.iam_path}" assume_role_policy = <