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

Convert boolean and numeric values to strings for value comparison #7

Merged
merged 1 commit into from
Dec 6, 2021

Conversation

ewbankkit
Copy link

@ewbankkit ewbankkit commented Dec 6, 2021

Supersedes jen20#12.

Relates hashicorp/terraform-provider-aws#21225.
Relates hashicorp/terraform-provider-aws#19245
Relates hashicorp/terraform-provider-aws#21968

The AWS IAM policy language states that Quotation marks are optional for numeric and Boolean values, so for example

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "statement1",
      "Effect": "Allow",
      "Action": [
        "s3:PutObject"
      ],
      "Resource": [
        "arn:aws:s3:::examplebucket/*"
      ],
      "Condition": {
        "Bool": {
          "aws:MultiFactorAuthPresent": "true"
        }
      }
    }
  ]
 }

and

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "statement1",
      "Effect": "Allow",
      "Action": [
        "s3:PutObject"
      ],
      "Resource": [
        "arn:aws:s3:::examplebucket/*"
      ],
      "Condition": {
        "Bool": {
          "aws:MultiFactorAuthPresent": true
        }
      }
    }
  ]
 }

should evaluate as equivalent.

% go test -v ./
=== RUN   TestParseAwsArnString
--- PASS: TestParseAwsArnString (0.00s)
=== RUN   TestPolicyEquivalence
--- PASS: TestPolicyEquivalence (0.00s)
PASS
ok  	github.com/jen20/awspolicyequivalence	0.616s

Copy link
Member

@YakDriver YakDriver left a comment

Choose a reason for hiding this comment

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

Looks fantastic! 🎉

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.

2 participants