From 0df860c4aee0ac9461e3e4fbb1328b0ea4e9dacd Mon Sep 17 00:00:00 2001 From: Veetaha Date: Fri, 20 Sep 2024 17:17:13 +0000 Subject: [PATCH 1/2] Remove debugging remnants --- elastio-terraform-deployment/README.md | 2 +- elastio-terraform-deployment/module/main.tf | 30 +++++++++++++++++ .../module/variables.tf | 33 ++++++++++++++++++- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/elastio-terraform-deployment/README.md b/elastio-terraform-deployment/README.md index cf19787..8d3b6d9 100644 --- a/elastio-terraform-deployment/README.md +++ b/elastio-terraform-deployment/README.md @@ -64,6 +64,6 @@ module "elastio" { # This input is optional. Here you can specify the version of the NAT provisioning stack. # If you don't need it, just omit this input variable. - elastio_nat_provision_stack = "v4" + elastio_nat_provision_stack = "v5" } ``` diff --git a/elastio-terraform-deployment/module/main.tf b/elastio-terraform-deployment/module/main.tf index 7d6d2af..c43277b 100644 --- a/elastio-terraform-deployment/module/main.tf +++ b/elastio-terraform-deployment/module/main.tf @@ -36,6 +36,7 @@ locals { iamResourceNamesSuffix = var.iam_resource_names_suffix iamResourceNamesStatic = var.iam_resource_names_static disableCustomerManagedIamPolicies = var.disable_customer_managed_iam_policies + disableServiceLinkedRolesCreation = var.service_linked_roles == "tf" supportRoleExpirationDate = var.support_role_expiration_date tenantRoleArn = "arn:aws:iam::176355207749:role/vkryvenko.development.elastio.us" } @@ -73,9 +74,38 @@ locals { key => tostring(value) if value != null } + + service_linked_roles_services = [ + "ecs.amazonaws.com", + "batch.amazonaws.com", + "spot.amazonaws.com", + "spotfleet.amazonaws.com", + "ecs.application-autoscaling.amazonaws.com", + "autoscaling.amazonaws.com", + ] +} + +resource "terraform_data" "service_linked_roles" { + for_each = var.service_linked_roles == "tf" ? local.service_linked_roles_services : toset([]) + + input = each.value + triggers_replace = each.value + + provisioner "local-exec" { + command = < Date: Fri, 20 Sep 2024 17:22:11 +0000 Subject: [PATCH 2/2] More comments --- elastio-terraform-deployment/module/main.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/elastio-terraform-deployment/module/main.tf b/elastio-terraform-deployment/module/main.tf index c43277b..330bc97 100644 --- a/elastio-terraform-deployment/module/main.tf +++ b/elastio-terraform-deployment/module/main.tf @@ -85,6 +85,10 @@ locals { ] } +# We have to use the `terraform_data` resource for the service-linked roles +# because their creation needs to be idempotent and terraform shouldn't claim +# ownership of them. These roles may already exist in the account, and they +# may be used by other resources not managed by Elastio. resource "terraform_data" "service_linked_roles" { for_each = var.service_linked_roles == "tf" ? local.service_linked_roles_services : toset([])