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

Bug - Cannot migrate workspace from terraform cloud to env0 #17

Open
zi-amatzia opened this issue Feb 29, 2024 · 0 comments
Open

Bug - Cannot migrate workspace from terraform cloud to env0 #17

zi-amatzia opened this issue Feb 29, 2024 · 0 comments

Comments

@zi-amatzia
Copy link

zi-amatzia commented Feb 29, 2024

Hi
While running the migration tool i got the following error

╷
│ Error: Invalid object key
│
│   on parse_projects.tf line 8, in locals:
│    7:   project_ids_to_names = {
│    8:     for id in local.project_ids : id =>
│    9:     contains(keys(local.projects_response_as_map), id) ? local.projects_response_as_map[id] : id
│   10:   }
│
│ Key expression in 'for' expression must not produce a null value.

It seems its looking for a project id.
Our organization does not have any project configured in terraform cloud so project id returns a null response and fails the migration.
To resolve this we made 2 changes

  1. parse_projects.tf line 2 - 3
    we changed to projects_url_response_json = jsondecode(data.http.projects.response_body)["data"] projects_url_response = local.projects_url_response_json == null ? [{id="my-org",attributes={name="default"}}] : local.projects_url_response_json
  2. line 7 to project_ids = toset([for workspace in data.tfe_workspace.all : coalesce(workspace.project_id,"my-org")])
  3. parse_workspaces.tf line 19 project_name = local.project_ids_to_names[coalesce(data.tfe_workspace.all[name].project_id, "zoominfo")]

Also in env0-resources-generator -> terraform_templates -> environments.tftpl it always assumes in repository that you are using https://www.github.com.... but if you use an enterprise git you might have a different url

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

No branches or pull requests

1 participant