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

Checks: Add support for scoped resources. #32732

Merged
merged 1 commit into from Mar 10, 2023

Conversation

liamcervante
Copy link
Member

@liamcervante liamcervante commented Feb 22, 2023

This PR adds support for scoped resources into the Terraform configuration language.

  • It creates a new Container interface within the configs package.
  • It embeds an optional container with the configs.Resource structure.
  • It adds a new address as an argument to the static analysis flow, source.
  • The static analysis will now validate that the container is accessible from the given source.

As of this PR, this new functionality is not used. As such all source references are set to nil, indicating they have only the default level of access and cannot access anything within a container.

In the longer term, only items that know they might need to access containerised resources will need to set the source argument which at the moment will only be the new Check blocks.

As nothing is using this functionality it was challenging to write tests within the existing frameworks. Unit tests for scoped resources are added later in the chain (liamcervante/checks/graph) when we have config and implementation that actually use the new functionality.


This PR is part of chain of PRs introducing the new Checks feature into Terraform for v1.5. The chain of PRs is as follows:

Branch Description Pull Request
liamcervante/checks/scoped Add support for scoped resources. #32732
liamcervante/checks/addr Add Terraform addresses for new Check blocks. #32733
liamcervante/checks/configs Add config parsing new Check blocks. #32734
liamcervante/checks/graph WIP: Add nodes and transforms for processing new Check blocks. #32735

I have created the chain to make reviewing the smaller contained part of the process easier. IF you want to view all the changes together in a single PR, navigate to the last PR in the chain and compare it to the main branch and you will see all changes from all prior PRs in a single place.

Copy link
Member

@jbardin jbardin left a comment

Choose a reason for hiding this comment

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

The changes LGTM! Though I don't think I see any tests checking what happens when something is referenced from the incorrect scope.

@liamcervante
Copy link
Member Author

The changes LGTM! Though I don't think I see any tests checking what happens when something is referenced from the incorrect scope.

Yeah, the way the existing tests are all configured is that they use real configuration to load and execute against, and we don't have anything right now that actually uses the scope to validate whether it's working or not working. The WIP graph PR further down the chain actually hooks everything up and includes tests for scoped/unscoped access etc.

@liamcervante liamcervante merged commit af05cbb into main Mar 10, 2023
@liamcervante liamcervante deleted the liamcervante/checks/scoped branch March 10, 2023 10:11
@github-actions
Copy link

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

genx7up pushed a commit to aweps/terraform that referenced this pull request Mar 17, 2023
genx7up pushed a commit to aweps/terraform that referenced this pull request Mar 17, 2023
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants