dynatrace-oss / cloud-snippets

Apache License 2.0
2 stars 15 forks source link

Removal of provider configurations from Terraform modules #17

Closed ThePierrasse closed 4 months ago

ThePierrasse commented 5 months ago

Is your feature request related to a problem? Please describe. Hi there,

we are looking to use the dynatrace_monitoring_role Terraform module you are maintaining under aws/role-based-access/terraform-templates/dynatrace_monitoring_role but we can't integrate it to our project the way we'd like because it includes a provider block.

We would like to use the count attribute with it but are running into the following error when trying to do so:

Error: Module is incompatible with count, for_each, and depends_on

The module at xxx is a legacy module which contains its own local provider configurations, and so calls to it may not use the count, for_each, or depends_on arguments.

If you also control the module "git::https://github.com/dynatrace-oss/cloud-snippets.git//aws/role-based-access/terraform-templates/dynatrace_monitoring_role", consider updating this module to instead expect provider configurations to be passed by its caller.

Describe the solution you'd like As indicated by the error message itself, to be properly reusable the module should ideally not include its own provider configurations. Instead, these should be provided by the caller.

So the solution we'd like to have, would be to remove the following block (lines 11 to 13) from the main.tf file:

provider "aws" {
  region = var.region
}

Describe alternatives you've considered Not using the provided Terraform module and instead creating our own. Would not be our preferred approach, we do not expect this module to be subject to change, but even then not reinventing the wheel remains best practice.

felipmiguel commented 4 months ago

The proposal seems reasonable. I can make the changes, but I need to verify if it requires any change in our docs.