Replies: 2 comments 1 reply
-
@YR-ZR0 have you already taken a look at our Terragrunt docs specific to overall keeping your code DRY? https://terragrunt.gruntwork.io/docs/features/keep-your-terraform-code-dry/ |
Beta Was this translation helpful? Give feedback.
-
Hi @gitsstewart thanks for getting back to me, I've currently got the following in an attempt to keep things DRY and hand off as much to terragrunt as possible. generate "vpc_cni_irsa_role" {
path = "vpc_cni.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
data "aws_partition" "current" {}
locals {
partition = data.aws_partition.current
}
module "vpc_cni_irsa_role" {
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
role_name = "vpc-cni"
attach_vpc_cni_policy = true
vpc_cni_enable_ipv4 = true
oidc_providers = {
main = {
provider_arn = "${dependency.eks.outputs.oidc_provider_arn}"
namespace_service_accounts = ["kube-system:aws-node"]
}
}
}
EOF
} The main issue i have here is that the "role_name" parameter is unique to each call of the module if you are creating many roles. And from my understanding we can't use a for_each to loop a module. Hope the code snippet helps in understanding the issue |
Beta Was this translation helpful? Give feedback.
-
Hi All,
I'm currently trying to use terragrunt with the following module:
https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-role-for-service-accounts-eks
The part I am looking for guidance on is DRY'ing up repeated module calls. Mostly in reference to the file here:
https://github.com/terraform-aws-modules/terraform-aws-iam/blob/master/examples/iam-role-for-service-accounts-eks/main.tf
What is the best way to deal with a module where structure is repeated to create unique resources ?
Thanks
Tracked in ticket #110166
Beta Was this translation helpful? Give feedback.
All reactions