env0 / env0/env0-migration-tool

Bug - Cannot migrate workspace from terraform cloud to env0

Open
#17 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HCL
Stars
1
Forks
3
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.