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

A repository cannot be created directly inside a project environment according to current recommendations #186

Open
richardmcsong opened this issue Dec 13, 2024 · 1 comment
Assignees
Labels
blocked bug Something isn't working

Comments

@richardmcsong
Copy link

richardmcsong commented Dec 13, 2024

Given a repository that needs to be created inside an environment inside that project:

resource "project" "tenant" {
  key = "foo"
}

resource "project_environment" "myenv" {
  name        = "myenv"
  project_key = project.tenant.key
}

resource "artifactory_federated_docker_v2_repository" "repo" {
  name = "docker"
  project_environments = [project_environment.myenv.name]
  [...]
}

resource "project_repository" "repo" {
  key = artifactory_federated_docker_v2_repository.repo.key
  project_key = project.tenant.key
}

The documentation recommends that the repository be associated to a project through the project_repository resource. However, the environment association only exists within initial federated repo definition. This leads to this error:

  │ Error: {
  │   "errors" : [ {
  │     "status" : 400,
  │     "message" : "Undefined environment 'myenv' in the project 'default'\n"
  │   } ]
  │ }

where the environment is not found within the global scope (only the project scope).

What is the recommendation to directly create the repo within a project environment (without multiple PRs)?

@richardmcsong richardmcsong added the bug Something isn't working label Dec 13, 2024
@alexhung
Copy link
Member

@richardmcsong Unfortunately the project_environments attribute is one current use case where you will need to perform terraform apply twice. Meaning, first apply without project_environments attribute defined. After project and repo are created and associated, then you can apply the project environments in second terraform apply.

This is a limitation of the REST API and we are aware of it.

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

No branches or pull requests

2 participants