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: support JSON inputs for policy document when IAM policy/statements are not set as Terraform objects #28

Merged
merged 2 commits into from Jun 15, 2023

Conversation

gberenice
Copy link
Contributor

what

  • Consider JSON source policy documents in the recently added precondition block.

why

│ Error: Resource precondition failed
│ 
│   on .terraform/modules/iam_policy/main.tf line 90, in data "aws_iam_policy_document" "this":
│   90:       condition     = var.iam_policy_statements != null || var.iam_policy != null
│     ├────────────────
│     │ var.iam_policy is null
│     │ var.iam_policy_statements is null
│ 
│ Exactly 1 of var.iam_policy and var.iam_policy_statments may be used, preferably var.iam_policy.

references

  • N/A

@gberenice gberenice requested review from a team as code owners June 14, 2023 10:52
main.tf Outdated
Comment on lines 89 to 92
precondition {
condition = var.iam_policy_statements != null || var.iam_policy != null
error_message = "Exactly 1 of var.iam_policy and var.iam_policy_statments may be used, preferably var.iam_policy."
condition = var.iam_policy_statements != null || var.iam_policy != null || length(local.source_policy_documents) > 0
error_message = "Exactly 1 of var.iam_policy and var.iam_policy_statements may be used, preferably var.iam_policy. JSON source policy documents may be used in addition to either of these."
}
Copy link
Sponsor Contributor

@Nuru Nuru Jun 14, 2023

Choose a reason for hiding this comment

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

Just remove the second precondition entirely.

Suggested change
precondition {
condition = var.iam_policy_statements != null || var.iam_policy != null
error_message = "Exactly 1 of var.iam_policy and var.iam_policy_statments may be used, preferably var.iam_policy."
condition = var.iam_policy_statements != null || var.iam_policy != null || length(local.source_policy_documents) > 0
error_message = "Exactly 1 of var.iam_policy and var.iam_policy_statements may be used, preferably var.iam_policy. JSON source policy documents may be used in addition to either of these."
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed 👍

main.tf Show resolved Hide resolved
@Nuru Nuru added the patch A minor, backward compatible change label Jun 15, 2023
@Nuru
Copy link
Sponsor Contributor

Nuru commented Jun 15, 2023

/terratest

@Nuru Nuru merged commit 10f1d3b into cloudposse:main Jun 15, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch A minor, backward compatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants