Skip to content

fix(import): build import IDs in the provider's documented format - #414

Merged
viodid merged 5 commits into
mainfrom
fix/import-addresses-accuracy
Oct 26, 2026
Merged

viodid merged 5 commits into
mainfrom
fix/import-addresses-accuracy

Conversation

@viodid

@viodid viodid commented Oct 26, 2026

Copy link
Copy Markdown
Member

Summary

Makes the import round's address mapping more accurate.

  • Import IDs in the documented format. The import mapping agent (import_addresses.jinja) no longer only fixes the casing of the listed cloud ID. For each resource type it calls web_search to find the import ID format in the provider docs (using the provider version from .terraform.lock.hcl / required_providers), then builds the ID from values in the listed ID, for example a bucket name, vpc-…, <cluster>/<service> or an OCID. On a retry it is given the previous import ID and the engine's error.
  • listed_id on every attempt. iac_import.json now requires listed_id on each entry, and it is stored on TerraformImportAttempt (left out of equality) so a rejected import can be rebuilt from the original listed ID.
  • Removed the unused status tool field from the import_addresses tool.
  • IaC plan targets limit raised from 256 to 4096 in the OpenAPI contract (iac.v1.yaml) and services/iac/src/models.py.
  • Docs: reference/api/iac.adoc (targets limit) and guides/import-infrastructure.adoc (how import IDs are built, and the example).

Checklist

Additional context

Tests for the import address service, validation service and import handler are updated for the new listed_id field.

…se web_search - listed_id always present

Signed-off-by: David Yunta <davidy@inditex.com>
Signed-off-by: David Yunta <davidy@inditex.com>
Signed-off-by: David Yunta <davidy@inditex.com>
Signed-off-by: David Yunta <davidy@inditex.com>
@viodid
viodid requested a review from a team as a code owner October 26, 2026 14:51
Copilot AI balanced review requested due to automatic review settings October 26, 2026 14:51
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

Copy link
Copy Markdown
Contributor

❗ This Pull Request will not trigger a docs release

A Pull Request with no docs/release label will not trigger a docs site release — label it docs/release if you want this merge to release the docs site.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Docs Release Preview

Merging this Pull Request will release the docs site as docs/stable.

⚠️ Tag already exists

docs/stable already exists and will be force-overwritten on merge.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved import identities can reach execution, provider lookup can select the wrong documentation, and accepted target lists can exceed subprocess argument limits.

3 open issues
What changed in this PR

This PR improves Terraform import mapping by building provider-specific import IDs from listed cloud resource IDs and preserving the original IDs for retries.

Changes:

  • Adds provider-documentation lookup instructions and carries listed_id through import attempts.
  • Removes the unused import-mapping status field and updates related tests and documentation.
  • Raises the plan target limit from 256 to 4096 across the service, contract, and API reference.
File Description
services/​iac/​src/​models.py Raises the plan target limit.
docs/​src/​modules/​main/​pages/​reference/​api/​iac.adoc Documents the increased target limit.
docs/​src/​modules/​main/​pages/​guides/​import-infrastructure.adoc Explains import ID construction and retries.
core/​tests/​domains/​services/​test_terraform_validation_service.py Adds listed IDs to validation fixtures.
core/​tests/​domains/​services/​test_terraform_import_address_service.py Checks preservation of original listed IDs.
core/​tests/​application/​use_cases/​test_terraform_import_handler.py Updates fixtures and report expectations.
core/​src/​infrastructure/​tools/​tool_registry_static.py Removes the unused mapping status field.
core/​src/​infrastructure/​tools/​iac_import.json Requires listed IDs and describes provider-specific import formats.
core/​src/​infrastructure/​templates/​base_layouts/​core/​import_addresses.jinja Adds format lookup and retry-context instructions.
core/​src/​domains/​services/​terraform_import_address_service.py Retains listed IDs in mapped attempts.
core/​src/​domains/​dto.py Adds listed_id without affecting equality.
core/​src/​application/​services/​terraform_import_service.py Preserves listed IDs in import outcomes.
contracts/​openapi/​iac.v1.yaml Aligns the contract with the increased target limit.

Review effort: Balanced

Comment thread services/iac/src/models.py Resolved
Updated the import process for resource blocks, including provider resolution and import ID format retrieval.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Docs Release Preview

Merging this Pull Request will release the docs site as docs/stable.

⚠️ Tag already exists

docs/stable already exists and will be force-overwritten on merge.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
50.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sonarqubecloud

Copy link
Copy Markdown

@viodid
viodid merged commit 769eafd into main Oct 26, 2026
41 of 42 checks passed
@viodid
viodid deleted the fix/import-addresses-accuracy branch October 26, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants