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

azurerm_kubernetes_flux_configuration Removing post_build results in an API error 400 #28570

Closed
1 task done
willh-airia opened this issue Jan 22, 2025 · 1 comment · Fixed by #28590
Closed
1 task done

Comments

@willh-airia
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.8.5

AzureRM Provider Version

4.16.0

Affected Resource(s)/Data Source(s)

azurerm_kubernetes_flux_configuration

Terraform Configuration Files

# First apply this:

resource "azurerm_kubernetes_flux_configuration" "this" {
  name       = "flux-config"
  cluster_id = azurerm_kubernetes_cluster.this.id
  namespace  = "flux-system"
  scope      = "cluster"

  git_repository {
    url              = "path/to/git"
    reference_type   = "branch"
    reference_value  = "main"
    https_user       = "theuser"
    https_key_base64 = "thekey"
  }

  kustomizations {
    name                       = "kustomization-1"
    path                       = "./the/path"
    sync_interval_in_seconds   = 60
    garbage_collection_enabled = true
    post_build {
      substitute = {
        test = "test"
      }
    }
  }
}

# Then try to apply this:
resource "azurerm_kubernetes_flux_configuration" "this" {
  name       = "flux-config"
  cluster_id = azurerm_kubernetes_cluster.this.id
  namespace  = "flux-system"
  scope      = "cluster"

  git_repository {
    url              = "path/to/git"
    reference_type   = "branch"
    reference_value  = "main"
    https_user       = "theuser"
    https_key_base64 = "thekey"
  }

  kustomizations {
    name                       = "kustomization-1"
    path                       = "./the/path"
    sync_interval_in_seconds   = 60
    garbage_collection_enabled = true
    # post_build {
    #   substitute = {
    #     test = "test"
    #   }
    # }
  }
}

Debug Output/Panic Output

2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: [DEBUG] AzureRM Response for https://management.azure.com/subscriptions/##########################/resourceGroups/########/providers/Microsoft.ContainerService/managedClusters/############/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/flux-config?api-version=2023-05-01: 
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: HTTP/2.0 400 Bad Request
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: Content-Length: 374
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: Cache-Control: no-cache
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: Content-Type: application/json; charset=utf-8
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: Date: Wed, 22 Jan 2025 01:27:04 GMT
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: Expires: -1
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: Pragma: no-cache
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: Strict-Transport-Security: max-age=31536000; includeSubDomains
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: X-Cache: CONFIG_NOCACHE
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: X-Content-Type-Options: nosniff
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: X-Ms-Correlation-Request-Id: c27c547c-1ed1-77b3-6fe0-61f085b31f74
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: X-Ms-Ratelimit-Remaining-Subscription-Global-Writes: 2999
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: X-Ms-Ratelimit-Remaining-Subscription-Writes: 199
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: X-Ms-Request-Id: 498bd1b4-cbb4-4d20-824f-4b82f86f5175
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: X-Ms-Routing-Request-Id: EASTUS2:20250122T012704Z:498bd1b4-cbb4-4d20-824f-4b82f86f5175
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: X-Msedge-Ref: Ref A: 18AB174DEE75428AAE60747500470A7F Ref B: BL2AA2011003054 Ref C: 2025-01-22T01:27:04Z
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5
2025-01-22T01:27:04.854Z [DEBUG] provider.terraform-provider-azurerm_v4.16.0_x5: {"error":{"code":"InvalidInputParameters","message":"Validation failed for one or more input parameters. Please fix the errors detailed below and try again.","details":[{"code":"InvalidInputParameter","message":"properties.kustomizations: Invalid property. Setting value must be a valid Kubernetes name matching a valid DNS name.","additionalInfo":[]}],"additionalInfo":[]}}

Expected Behaviour

postBuild should be removed from the Kustomization in kubernetes

Actual Behaviour

API Error 400 and no changes made to the Kustomization in Kubernetes

Steps to Reproduce

  1. Add post_build block with substitutions in azurerm_kubernetes_flux_configuration under kustomizations
  2. terraform apply
  3. Remove post_build block
  4. terraform apply

Important Factoids

No response

References

No response

@ms-henglu
Copy link
Contributor

Hi @willh-airia ,

Thank you for taking time to report this issue.

I opened this PR to fix it: #28590

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants