Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect map element type: attribute "ingress": attributes "target_port" and "traffic_weight" are required #26

Open
1 task done
DzianisMatveyeu opened this issue Oct 5, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@DzianisMatveyeu
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Greenfield/Brownfield provisioning

greenfield

Terraform Version

v1.3.4

Module Version

v0.2.0

AzureRM Provider Version

v3.75.0

Affected Resource(s)/Data Source(s)

azurerm_container_app.container_app

Terraform Configuration Files

module "container-apps" {
  source  = "Azure/container-apps/azure"
  version = "0.2.0"
  # insert the 5 required variables here
  container_apps                                           = var.container_apps
  container_app_environment_name                           = var.container_app_environment_name
  location                                                 = var.location
  log_analytics_workspace_name                             = var.log_analytics_workspace_name
  resource_group_name                                      = "testrsg"
  container_app_secrets                                    = var.container_app_secrets
}

tfvars variables values

container_app_environment_name = "dev1"
log_analytics_workspace_name   = "dev1"
resource_group_name            = "dev1"
location                       = "eastus2"
container_apps = {
  test = {
    name          = "nginx"
    revision_mode = "Multiple"
    template = {
      containers = [{
        name         = "nginx"
        image        = "nginx:latest"
        cpu          = ".25"
        memory       = "0.5Gi"
        max_replicas = 2
        min_replicas = 1
        liveness_probe = {
          port      = 80
          transport = "HTTP"
        }
        readiness_probe = {
          port      = 80
          transport = "HTTP"
        }
        startup_probe = {
          port      = 80
          transport = "HTTP"
        }
      }]
      ingress = {
        target_port    = 80  
        traffic_weight = {
          percentage = 50  
        }
      }
    }
  }
}

Debug Output/Panic Output

│ Error: Invalid value for input variable
│
│   on main.tf line 5, in module "container-apps":
│    5:   container_apps                                           = var.container_apps
│
│ The given value is not suitable for module.container-apps.var.container_apps declared at .terraform\modules\container-apps\variables.tf:7,1-26: incorrect map element type: attribute "ingress": attributes "target_port" and  
│ "traffic_weight" are required.
╵
╷
│ Error: Missing required argument
│
│   with module.container-apps.azurerm_container_app_environment.container_env,
│   on .terraform\modules\container-apps\main.tf line 25, in resource "azurerm_container_app_environment" "container_env":
│   25:   internal_load_balancer_enabled = var.container_app_environment_internal_load_balancer_enabled
│
│ "internal_load_balancer_enabled": all of `infrastructure_subnet_id,internal_load_balancer_enabled` must be specified

Expected Behaviour

I expected that it would be easy to run a container app with this module.
In docs only 5 required variables. Documentation is not clear.

Actual Behaviour

I had more than 5 required and errors

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@lonegunmanb
Copy link
Member

Hi @DzianisMatveyeu thanks for reporting this issue to us. I've checked the template object in this module's variable, the ingress object is not part of it, but in your tfvars it looks like you've declared ingress inside the template object, which might cause the error.

As for the following Missing required argument error, I've seen the same error in the e2e test, and I'm investigating it.

@zioproto
Copy link

zioproto commented Nov 7, 2023

@lonegunmanb could you please check if this is related to this provider issue ?

hashicorp/terraform-provider-azurerm#20435 (comment)

The problem here is in this code:

dynamic "traffic_weight" {
for_each = ingress.value.traffic_weight == null ? [] : [ingress.value.traffic_weight]
content {
percentage = traffic_weight.value.percentage
label = traffic_weight.value.label
latest_revision = traffic_weight.value.latest_revision
revision_suffix = traffic_weight.value.revision_suffix
}
}
}
}

It is probably enough to workaround the issue doing:

ingress = {
        target_port    = 80  
        traffic_weight = {
          percentage = 100  
          latestRevision = true
        }
      }

Without latestRevision with a valid value it will not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

3 participants