-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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(terraform): fix policy document retrieval #6276
Conversation
policyDoc, err := modules.GetBlockById(policyDocID) | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
policyDoc, err := modules.GetBlockById(policyDocID) | |
if err == nil { | |
if policyDoc, err := modules.GetBlockById(policyDocID); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 9058054
document, err := ConvertTerraformDocument(modules, policyDoc) | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
document, err := ConvertTerraformDocument(modules, policyDoc) | |
if err == nil { | |
if document, err := ConvertTerraformDocument(modules, policyDoc); err == nil { |
parsed, err := iamgo.Parse([]byte(unescapeVars(policyDocID))) | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
parsed, err := iamgo.Parse([]byte(unescapeVars(policyDocID))) | |
if err == nil { | |
if parsed, err := iamgo.Parse([]byte(unescapeVars(policyDocID))); err == nil { |
if !attr.IsIterable() { | ||
return documents | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test case for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 9058054
Description
If a policy, such as
aws_iam_policy
oraws_iam_policy_document
, uses a for-each loop to reference policy document resources, those resources are not detected. In the case where a policy references document resources in a condition, only the first resource was selected. It is necessary to search for policy document resources by identifiers (id) rather than by references to fix this.Related issues
Checklist