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

[AVM Module Issue]: problem with provider pinning for azure/azapi #65

Closed
1 task done
JensKruseAvanade opened this issue Dec 5, 2024 · 12 comments
Closed
1 task done
Assignees
Labels
Language: Terraform 🌐 This is related to the Terraform IaC language Type: Bug 🐛 Something isn't working

Comments

@JensKruseAvanade
Copy link

Check for previous/existing GitHub issues

  • I have checked for previous/existing GitHub issues

Issue Type?

Bug

(Optional) Module Version

2.1

(Optional) Correlation Id

No response

Description

Terraform init

│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider azure/azapi:
│ no available releases match the given constraints >= 1.14.0, ~> 1.14, ~>
│ 2.0, < 3.0.0

My assumption is, that there is a typo in the provider requirements for "Azure/azapi" (instead of "azure/azapi" (see terraform-azurerm-avm-ptn-policyassignment/terraform.tf, line 5).

@JensKruseAvanade JensKruseAvanade added Language: Terraform 🌐 This is related to the Terraform IaC language Needs: Triage 🔍 Maintainers need to triage still labels Dec 5, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Type: Bug 🐛 Something isn't working label Dec 5, 2024
@bjornhofer bjornhofer self-assigned this Dec 6, 2024
@JensKruseAvanade
Copy link
Author

@bjornhofer Sorry to bother you: any update on this? How can I support?

@bjornhofer
Copy link
Contributor

@JensKruseAvanade Hi, no problem I'm currently a bit in a rush with other things - but I plan to solve it at latest on the upcoming Friday.

@bjornhofer
Copy link
Contributor

Hello @JensKruseAvanade

I could not reproduce your issue in my test environment. (see: https://ibb.co/YBXwqRr

Can you provide me more details (Terraform version, operating system, ...)

Thanks in advance

Björn

@JensKruseAvanade
Copy link
Author

Hi @bjornhofer
Thanks for your answer.
This is my github action environment:

jobs:
  terraform:
    name: "Terraform"
    runs-on: ubuntu-latest
[...]
      # Install the preferred version of Terraform CLI
      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v1
        with:
          terraform_version: 1.9

HTH,
Jens

@JensKruseAvanade
Copy link
Author

Just ran a terraform providers with the pipeline.

Providers required by other AVM modules (showing here just 'azure/azapi':

...
├── module.storage_account
...
│   ├── provider[registry.terraform.io/azure/azapi] >= 1.14.0, < 3.0.0
...
├── module.log_analytics_workspace
│   ├── provider[registry.terraform.io/azure/azapi] ~> 2.0
...

With that, no problems occur, so I agree that this issue is not about the spelling of the providers. Could it be something about versioning requirements? Found this one here ... https://stackoverflow.com/questions/76272116/terraform-resolve-no-available-releases-match-the-given-constraints-error

@bjornhofer
Copy link
Contributor

Hi @JensKruseAvanade,

can you provide me a list of all the used modules in this example - maybe I can recreate it and testdrive it to verify this very good idea and create a workaround.

Do you init all this modules with one main?

@steph409 steph409 removed the Needs: Triage 🔍 Maintainers need to triage still label Dec 13, 2024
@steph409
Copy link
Contributor

Hi @JensKruseAvanade,

the problem is that you have two version requirements (one coming from the module, and one coming from somewhere in your code), so it doesn't find a version. Right now, the module is soft-pinned on azapi version 1.14 here. Somewhere in your code, you are requiring azapi to be version to be ~> 2.0, < 3.0.0. This can either be if you specify it directly or you are calling modules that do. Can you try to deploy this separately, or to soften the version constraint?

@bjornhofer - it would be great if our code would also work with azapi version 2, but we should test it before removing the constraint.

@bjornhofer
Copy link
Contributor

Hello @JensKruseAvanade so far all changes are merged to main. Please let me know if it fixed your issue, so I can close the issue.

@JensKruseAvanade
Copy link
Author

JensKruseAvanade commented Dec 19, 2024

@bjornhofer
We still have the pinning problem ...

├── module.assign_policy_at_resource_group
│   ├── provider[registry.terraform.io/azure/azapi] ~> 1.14

@JensKruseAvanade JensKruseAvanade changed the title [AVM Module Issue]: misspelling in provider "Azure/azapi" [AVM Module Issue]: problem with provider pinning for azure/azapi Dec 19, 2024
@bjornhofer
Copy link
Contributor

@JensKruseAvanade sorry, I've missed the step of releasing the new version (my first time with AVM modules).
It has been released now - please update your provider ( terraform init --upgrade ) to the latest version and it should now work.

@JensKruseAvanade
Copy link
Author

JensKruseAvanade commented Dec 20, 2024

@bjornhofer
I can see now other problems, probably provider related?

Error: Invalid configuration

  with module.assign_policy_at_resource_group.azapi_resource.policy_assignment,
  on .terraform/modules/assign_policy_at_resource_group/main_policy_assignment.tf line 5, in resource "azapi_resource" "policy_assignment":
   5: resource "azapi_resource" "policy_assignment" ***

embedded schema validation failed: the argument "body" is invalid:
`name` is invalid, string does not match pattern
^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$
 You can try to update `azapi` provider to the latest version or disable the validation using the feature flag `schema_validation_enabled = false` within the resource block

@JensKruseAvanade
Copy link
Author

Solved this issue: there had been special characters in the name of the policy assignment. After removing them, all went fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language: Terraform 🌐 This is related to the Terraform IaC language Type: Bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants