Skip to content

Commit 4b2d1ad

Browse files
uditmehta27dominicbarnes
authored andcommitted
make the suffix optional
1 parent 86b2fa7 commit 4b2d1ad

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ resource "aws_s3_bucket" "segment_datalake_s3" {
9393
module "iam" {
9494
source = "[email protected]:segmentio/terraform-aws-data-lake//modules/iam?ref=v0.2.0"
9595
96-
iam_suffix = "prod"
96+
suffix = "prod"
9797
s3_bucket = "${aws_s3_bucket.segment_datalake_s3.name}"
9898
external_ids = "${values(local.segment_sources)}"
9999
}

modules/iam/main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Creates the IAM role used by Segment.
22
# https://www.terraform.io/docs/providers/aws/r/iam_role.html
33
resource "aws_iam_role" "segment_data_lake_iam_role" {
4-
name = "SegmentDataLakeRole-${var.iam_suffix}"
4+
name = "SegmentDataLakeRole${var.suffix}"
55
description = "IAM Role used by Segment"
66
assume_role_policy = "${data.aws_iam_policy_document.segment_data_lake_assume_role_policy_document.json}"
77
tags = "${local.tags}"
@@ -41,7 +41,7 @@ data "aws_caller_identity" "current" {}
4141
data "aws_region" "current" {}
4242

4343
resource "aws_iam_policy" "segment_data_lake_policy" {
44-
name = "SegmentDataLakePolicy-${var.iam_suffix}"
44+
name = "SegmentDataLakePolicy${var.suffix}"
4545
path = "/"
4646
description = "Gives access to resources in your Data Lake"
4747

@@ -165,7 +165,7 @@ resource "aws_iam_role_policy_attachment" "segment_data_lake_role_policy_attachm
165165

166166
# IAM role for EMR Service
167167
resource "aws_iam_role" "segment_emr_service_role" {
168-
name = "SegmentEMRServiceRole-${var.iam_suffix}"
168+
name = "SegmentEMRServiceRole${var.suffix}"
169169

170170
assume_role_policy = <<EOF
171171
{
@@ -185,7 +185,7 @@ EOF
185185
}
186186

187187
resource "aws_iam_role_policy" "segment_emr_service_policy" {
188-
name = "SegmentEMRServicePolicy-${var.iam_suffix}"
188+
name = "SegmentEMRServicePolicy${var.suffix}"
189189
role = "${aws_iam_role.segment_emr_service_role.id}"
190190

191191
policy = <<EOF
@@ -268,7 +268,7 @@ EOF
268268

269269
# IAM Role for EC2 Instance Profile
270270
resource "aws_iam_role" "segment_emr_instance_profile_role" {
271-
name = "SegmentEMRInstanceProfileRole-${var.iam_suffix}"
271+
name = "SegmentEMRInstanceProfileRole${var.suffix}"
272272

273273
assume_role_policy = <<EOF
274274
{
@@ -288,13 +288,13 @@ EOF
288288
}
289289

290290
resource "aws_iam_instance_profile" "segment_emr_instance_profile" {
291-
name = "SegmentEMRInstanceProfile-${var.iam_suffix}"
291+
name = "SegmentEMRInstanceProfile${var.suffix}"
292292
roles = ["${aws_iam_role.segment_emr_instance_profile_role.name}"]
293293
}
294294

295295

296296
resource "aws_iam_role_policy" "segment_emr_instance_profile_policy" {
297-
name = "SegmentEMRInstanceProfilePolicy-${var.iam_suffix}"
297+
name = "SegmentEMRInstanceProfilePolicy${var.suffix}"
298298
role = "${aws_iam_role.segment_emr_instance_profile_role.id}"
299299

300300
policy = <<EOF
@@ -371,7 +371,7 @@ EOF
371371

372372
# IAM Role for EMR Autoscaling role
373373
resource "aws_iam_role" "segment_emr_autoscaling_role" {
374-
name = "SegmentEMRAutoscalingRole-${var.iam_suffix}"
374+
name = "SegmentEMRAutoscalingRole${var.suffix}"
375375

376376
assume_role_policy = <<EOF
377377
{
@@ -393,7 +393,7 @@ EOF
393393
}
394394

395395
resource "aws_iam_role_policy" "segmnet_emr_autoscaling_policy" {
396-
name = "SegmentEMRAutoscalingPolicy-${var.iam_suffix}"
396+
name = "SegmentEMRAutoscalingPolicy${var.suffix}"
397397
role = "${aws_iam_role.segment_emr_autoscaling_role.id}"
398398

399399
policy = <<EOF

modules/iam/variables.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
variable "iam_suffix" {
2-
description = "The suffix of the IAM roles/policies created by this module. Allows creating multiple such modules in the same AWS account. Common practice is to set the env here ie dev/stage/prod"
1+
variable "suffix" {
2+
description = "Optional suffix to the IAM roles/policies created by this module. Allows creating multiple such modules in the same AWS account. Common practice is to set the env here ie dev/stage/prod"
33
type = "string"
4+
default = ""
45
}
56

67
variable "segment_aws_accounts" {

test/test_fixture/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module "glue" {
1818
module "iam" {
1919
source = "../../modules/iam"
2020

21-
iam_suffix = "dev"
21+
suffix = "dev"
2222
s3_bucket = "data_lake_tf_test_s3_bucket"
2323
external_ids = ["test_external_id_1", "test_external_id_2"]
2424
tags = "${local.tags}"

0 commit comments

Comments
 (0)