Does anyone know if its possible to use aws_iam_policy_document data source to create a statement condition with multiple tests so you can create OR logic?
To answer your post @jgreat, I don’t think it is possible to create OR logic with conditions but it is possible for AND logic. The Terraform docs for aws_iam_policy_documentcondition blocks here states:
When using multiple condition blocks, they must all evaluate to true for the policy statement to apply.
Following the idea of multiple condition blocks, what is the syntax for creating multiple conditions for a single aws_iam_policy_documentstatement block, please? I have come across this StackOverflow answer that states:
I never found a solution to create multiple condition blocks for a aws_iam_policy_document in Terraform, if you do find a solution please do share it.
For only when I have multiple conditions, my work around is to use a JSON representation for the whole policy with policy = jsonencode(foo). Rather than using a aws_iam_policy_document data block.
To answer the original question of can you create OR logic with multiple conditionals?
No.
The documentation now states:
When using multiple condition blocks, they must all evaluate to true for the policy statement to apply. In other words, AWS evaluates the conditions as though with an “AND” boolean operation.
There you go a clear answer that I’m fairly certain was not in the docs when I checked it a while ago