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

fix: include referenced resources in resource block's __tfmeta (fixes #99) #219

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

albertodonato
Copy link
Collaborator

  • add a references entry in a resource's __tfmeta if attributes reference other resources, which lists referenced blocks and they IDs. This allows c7n-left to build cross references, allowing traversal filters to work properly
  • report the actual values for attributes that reference other blocks rather then metadata. This allows value-based matches in policies for those attributes.

albertodonato added a commit to albertodonato/cloud-custodian that referenced this pull request Oct 15, 2024
Make use of the changes from
cloud-custodian/tfparse#219 to track all references to
other blocks declared for a block.
albertodonato added a commit to albertodonato/cloud-custodian that referenced this pull request Oct 15, 2024
Make use of the changes from
cloud-custodian/tfparse#219 to track all references to
other blocks declared for a block.
albertodonato added a commit to albertodonato/cloud-custodian that referenced this pull request Oct 15, 2024
Make use of the changes from
cloud-custodian/tfparse#219 to track all references to
other blocks declared for a block.
albertodonato added a commit to albertodonato/cloud-custodian that referenced this pull request Oct 15, 2024
Make use of the changes from
cloud-custodian/tfparse#219 to track all references to
other blocks declared for a block.
@kapilt
Copy link
Contributor

kapilt commented Nov 13, 2024

we'll need some release notes about the breaking change as well

Copy link
Contributor

@kapilt kapilt left a comment

Choose a reason for hiding this comment

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

lgtm, thanks

tests/test_tfparse.py Outdated Show resolved Hide resolved
@albertodonato albertodonato force-pushed the tfmeta-block-references branch from e567989 to ad368e3 Compare November 14, 2024 11:12
@albertodonato albertodonato force-pushed the tfmeta-block-references branch from ad368e3 to 5b38cf4 Compare November 14, 2024 13:20
albertodonato added a commit to albertodonato/cloud-custodian that referenced this pull request Nov 14, 2024
Make use of the changes from
cloud-custodian/tfparse#219 to track all references to
other blocks declared for a block.
@ajkerrigan
Copy link
Member

It looks like we won't be able to see references in a case like this:

resource "aws_instance" "example" {
  launch_template {
    id = aws_launch_template.example.id
  }
}

resource "aws_launch_template" "example" {
  name = "example"
  metadata_options {
    http_endpoint = "enabled"
    http_tokens = "required"
  }
}

Where the use case is using a traverse filter to see if an instance has IMDSv2 enforced via metadata_options.http_tokens == 'required' on its associated launch template.

For what it's worth, we don't catch this as a reference on main either. But I bring it up here because if the issue is that we're not seeing or tracking references that come from nested blocks inside resources, I don't know if that has any impact on how to approach this PR.

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.

3 participants