Skip to content

fix: include removed blocks in parsed output - #293

Open
RaphaelFakhri wants to merge 1 commit into
cloud-custodian:mainfrom
RaphaelFakhri:fix/removed-blocks
Open

RaphaelFakhri wants to merge 1 commit into
cloud-custodian:mainfrom
RaphaelFakhri:fix/removed-blocks

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Terraform 1.7 added the removed block. tfparse skips it: the block is missing from the parsed output, and the converter logs unknown block type type=removed. Policies can't see which resources a configuration removes from state, or whether lifecycle { destroy = false } is set.

This change adds removed to the block types the converter emits, next to moved. The block appears under the removed key. from is a reference marker, and lifecycle is a nested object:

"removed": [{
  "from": {"__attribute__": "aws_instance.a", "__name__": "a"},
  "lifecycle": {"destroy": false, ...},
  ...
}]

Testing

  • New test test_removed_blocks with fixture tests/terraform/removed. It fails on main with KeyError: 'removed' and passes with this change.
  • The full test suite passes. black --check and flake8 are clean.

Closes #234

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

Successfully merging this pull request may close these issues.

tfparse incompatible with "removed" block syntax

1 participant