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

google_artifact_registry_repository location appears to be required #10436

Comments

@aaron-lane
Copy link

aaron-lane commented Oct 28, 2021

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 +1 or me too comments, 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.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.0.5
on linux_amd64

  • provider registry.terraform.io/hashicorp/google v3.89.0
  • provider registry.terraform.io/hashicorp/google-beta v3.89.0
  • provider registry.terraform.io/hashicorp/null v3.1.0
  • provider registry.terraform.io/hashicorp/tls v3.1.0
  • provider registry.terraform.io/vancluever/acme v2.6.0

Affected Resource(s)

  • google_artifact_registry_repository

Terraform Configuration Files

resource "google_artifact_registry_repository" "main" {
  provider = google-beta

  format        = "DOCKER"
  repository_id = "main"

  description = "A repository of images."
  labels      = {
    env = "test"
  }
}

Output

Error: Error creating Repository: googleapi: Error 400: Request contains an invalid argument.
with google_artifact_registry_repository.main
on artifact-registry.tf line 1, in resource "google_artifact_registry_repository" "main":
resource "google_artifact_registry_repository" "main" {

Expected Behavior

The repository is created with the location inherited from the provider region, as the location argument is documented as optional.

Actual Behavior

The repository is not created because GCP rejects the request due to an invalid argument, as the location argument is required and not necessarily equivalent to any region.

Steps to Reproduce

This issue was reported in #10184. I confirmed that the workaround of adding the location argument solved the problem.

References

b/272798286

@aaron-lane aaron-lane added the bug label Oct 28, 2021
@michaelfeinbier
Copy link

I can confirm that addintg location seems to be required in order to make it work

@henkka
Copy link

henkka commented Oct 20, 2022

This seems to be bug caused from

url, err := replaceVars(d, config, "{{ArtifactRegistryBasePath}}projects/{{project}}/locations/{{location}}/repositories?repository_id={{repository_id}}")
as there's no functionality that defaults the location to provider region when location is not passed, and thus, the location ends up being empty string.

In such case the path used for the API call is

/v1/projects/project-name/locations//repositories?repository_id=repo-name

(notice //)

I'll see whether I manage to fix it and create pull request for it

@Carlos4ndresh
Copy link

Encountered the Same behaviour, adding the location did the trick

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.