Skip to content

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

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

Merged
merged 1 commit into from
Apr 1, 2025

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

@albertodonato albertodonato force-pushed the tfmeta-block-references branch 2 times, most recently 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.

@albertodonato albertodonato force-pushed the tfmeta-block-references branch from f9acf20 to 969de80 Compare March 18, 2025 15:53
@albertodonato albertodonato force-pushed the tfmeta-block-references branch 2 times, most recently from 091e475 to 97f18a8 Compare March 26, 2025 15:02
@albertodonato albertodonato force-pushed the tfmeta-block-references branch from 431f524 to 726a3cf Compare April 1, 2025 07:30
@sontek sontek merged commit fc64f6f into cloud-custodian:main Apr 1, 2025
11 of 12 checks passed
@albertodonato albertodonato deleted the tfmeta-block-references branch April 1, 2025 13:55
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.

4 participants