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

organizations/policy: Fix erroneous content diffs #22260

Closed
wants to merge 2 commits into from

Conversation

YakDriver
Copy link
Member

@YakDriver YakDriver commented Dec 16, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #21968

Output from acceptance testing:

$ make testacc TESTS=TestAccXXX PKG=ec2

...

@github-actions github-actions bot added service/organizations Issues and PRs that pertain to the organizations service. size/S Managed by automation to categorize the size of a PR. labels Dec 16, 2021
@ewbankkit
Copy link
Contributor

ewbankkit commented Dec 16, 2021

% make testacc TESTARGS='-run=TestAccOrganizations_serial/Policy' PKG=organizations
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/organizations/... -v -count 1 -parallel 20 -run=TestAccOrganizations_serial/Policy -timeout 180m
=== RUN   TestAccOrganizations_serial
=== RUN   TestAccOrganizations_serial/Policy
=== RUN   TestAccOrganizations_serial/Policy/Type_AI_OPT_OUT
    policy_test.go:206: Step 1/2 error: Error running apply: exit status 1
        
        Error: while checking equivalency of existing policy ({ "services": { "rekognition": { "opt_out_policy": { "@@assign": "optOut" } }, "lex": { "opt_out_policy": { "@@assign": "optIn" } } } }) and new policy ({"services":{"lex":{"opt_out_policy":{"@@assign":"optIn"}},"rekognition":{"opt_out_policy":{"@@assign":"optOut"}}}}), encountered: Error parsing policy: Unknown error parsing statement
        
          with aws_organizations_policy.test,
          on terraform_plugin_test.tf line 4, in resource "aws_organizations_policy" "test":
           4: resource "aws_organizations_policy" "test" {

I don't think Organization policies are IAM policies.
https://aws.amazon.com/premiumsupport/knowledge-center/iam-policy-service-control-policy/

@YakDriver YakDriver closed this Dec 16, 2021
@YakDriver YakDriver deleted the b-organizations-policy-diffs branch December 16, 2021 22:20
@ewbankkit
Copy link
Contributor

% make testacc TESTARGS='-run=TestAccOrganizations_serial/Policy' PKG=organizations
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/organizations/... -v -count 1 -parallel 20 -run=TestAccOrganizations_serial/Policy -timeout 180m
=== RUN   TestAccOrganizations_serial
=== RUN   TestAccOrganizations_serial/Policy
=== RUN   TestAccOrganizations_serial/Policy/Type_AI_OPT_OUT
    policy_test.go:206: Step 1/2 error: Error running apply: exit status 1
        
        Error: while checking equivalency of existing policy ({ "services": { "rekognition": { "opt_out_policy": { "@@assign": "optOut" } }, "lex": { "opt_out_policy": { "@@assign": "optIn" } } } }) and new policy ({"services":{"lex":{"opt_out_policy":{"@@assign":"optIn"}},"rekognition":{"opt_out_policy":{"@@assign":"optOut"}}}}), encountered: Error parsing policy: Unknown error parsing statement
        
          with aws_organizations_policy.test,
          on terraform_plugin_test.tf line 4, in resource "aws_organizations_policy" "test":
           4: resource "aws_organizations_policy" "test" {
        
=== RUN   TestAccOrganizations_serial/Policy/Type_Backup
    policy_test.go:303: Step 1/2 error: Error running apply: exit status 1
        
        Error: while checking equivalency of existing policy ({
           "plans":{
              "PII_Backup_Plan":{
                 "regions":{
                    "@@assign":[
                       "us-east-1",
                       "us-west-2"
                    ]
                 },
                 "rules":{
                    "Hourly":{
                       "schedule_expression":{
                          "@@assign":"cron(0 5/1 ? * * *)"
                       },
                       "start_backup_window_minutes":{
                          "@@assign":"480"
                       },
                       "complete_backup_window_minutes":{
                          "@@assign":"10080"
                       },
                       "lifecycle":{
                          "move_to_cold_storage_after_days":{
                             "@@assign":"180"
                          },
                          "delete_after_days":{
                             "@@assign":"270"
                          }
                       },
                       "target_backup_vault_name":{
                          "@@assign":"FortKnox"
                       },
                       "copy_actions":{
                          "arn:aws:backup:us-east-1:$account:backup-vault:secondary_vault":{
                             "target_backup_vault_arn":{
                                "@@assign":"arn:aws:backup:us-east-1:$account:backup-vault:secondary_vault"
                             },
                             "lifecycle":{
                                "delete_after_days":{
                                   "@@assign":"100"
                                },
                                "move_to_cold_storage_after_days":{
                                   "@@assign":"10"
                                }
                             }
                          }
                       }
                    }
                 },
                 "selections":{
                    "tags":{
                       "datatype":{
                          "iam_role_arn":{
                             "@@assign":"arn:aws:iam::$account:role/MyIamRole"
                          },
                          "tag_key":{
                             "@@assign":"dataType"
                          },
                          "tag_value":{
                             "@@assign":[
                                "PII",
                                "RED"
                             ]
                          }
                       }
                    }
                 }
              }
           }
        }) and new policy ({"plans":{"PII_Backup_Plan":{"regions":{"@@assign":["us-east-1","us-west-2"]},"rules":{"Hourly":{"complete_backup_window_minutes":{"@@assign":"10080"},"copy_actions":{"arn:aws:backup:us-east-1:$account:backup-vault:secondary_vault":{"lifecycle":{"delete_after_days":{"@@assign":"100"},"move_to_cold_storage_after_days":{"@@assign":"10"}},"target_backup_vault_arn":{"@@assign":"arn:aws:backup:us-east-1:$account:backup-vault:secondary_vault"}}},"lifecycle":{"delete_after_days":{"@@assign":"270"},"move_to_cold_storage_after_days":{"@@assign":"180"}},"schedule_expression":{"@@assign":"cron(0 5/1 ? * * *)"},"start_backup_window_minutes":{"@@assign":"480"},"target_backup_vault_name":{"@@assign":"FortKnox"}}},"selections":{"tags":{"datatype":{"iam_role_arn":{"@@assign":"arn:aws:iam::$account:role/MyIamRole"},"tag_key":{"@@assign":"dataType"},"tag_value":{"@@assign":["PII","RED"]}}}}}}}), encountered: Error parsing policy: Unknown error parsing statement
        
          with aws_organizations_policy.test,
          on terraform_plugin_test.tf line 4, in resource "aws_organizations_policy" "test":
           4: resource "aws_organizations_policy" "test" {
        
=== RUN   TestAccOrganizations_serial/Policy/Type_SCP
=== RUN   TestAccOrganizations_serial/Policy/concurrent
=== RUN   TestAccOrganizations_serial/Policy/Tags
=== RUN   TestAccOrganizations_serial/Policy/disappears
=== RUN   TestAccOrganizations_serial/Policy/ImportAwsManagedPolicy
=== RUN   TestAccOrganizations_serial/Policy/basic
    policy_test.go:26: Step 1/3 error: Check failed: Check 3/6 error: aws_organizations_policy.test: Attribute 'content' expected "{\"Version\": \"2012-10-17\", \"Statement\": { \"Effect\": \"Allow\", \"Action\": \"*\", \"Resource\": \"*\"}}", got "{\"Statement\":{\"Action\":\"*\",\"Effect\":\"Allow\",\"Resource\":\"*\"},\"Version\":\"2012-10-17\"}"
=== RUN   TestAccOrganizations_serial/Policy/Description
=== RUN   TestAccOrganizations_serial/Policy/Type_Tag
    policy_test.go:366: Step 1/2 error: Error running apply: exit status 1
        
        Error: while checking equivalency of existing policy ({ "tags": { "Product": { "tag_key": { "@@assign": "Product" }, "enforced_for": { "@@assign": [ "ec2:instance" ] } } } }) and new policy ({"tags":{"Product":{"enforced_for":{"@@assign":["ec2:instance"]},"tag_key":{"@@assign":"Product"}}}}), encountered: Error parsing policy: Unknown error parsing statement
        
          with aws_organizations_policy.test,
          on terraform_plugin_test.tf line 4, in resource "aws_organizations_policy" "test":
           4: resource "aws_organizations_policy" "test" {
        
=== RUN   TestAccOrganizations_serial/PolicyAttachment
=== RUN   TestAccOrganizations_serial/PolicyAttachment/Root
=== RUN   TestAccOrganizations_serial/PolicyAttachment/Account
    policy_attachment_test.go:29: Step 2/3 error: Error running apply: exit status 1
        
        Error: while checking equivalency of existing policy ({ "tags": { "Product": { "tag_key": { "@@assign": "Product" }, "enforced_for": { "@@assign": [ "ec2:instance" ] } } } }) and new policy ({"tags":{"Product":{"enforced_for":{"@@assign":["ec2:instance"]},"tag_key":{"@@assign":"Product"}}}}), encountered: Error parsing policy: Unknown error parsing statement
        
          with aws_organizations_policy.test,
          on terraform_plugin_test.tf line 6, in resource "aws_organizations_policy" "test":
           6: resource "aws_organizations_policy" "test" {
        
=== RUN   TestAccOrganizations_serial/PolicyAttachment/OrganizationalUnit
--- FAIL: TestAccOrganizations_serial (260.75s)
    --- FAIL: TestAccOrganizations_serial/Policy (194.92s)
        --- FAIL: TestAccOrganizations_serial/Policy/Type_AI_OPT_OUT (9.11s)
        --- FAIL: TestAccOrganizations_serial/Policy/Type_Backup (9.20s)
        --- PASS: TestAccOrganizations_serial/Policy/Type_SCP (24.23s)
        --- PASS: TestAccOrganizations_serial/Policy/concurrent (29.18s)
        --- PASS: TestAccOrganizations_serial/Policy/Tags (48.11s)
        --- PASS: TestAccOrganizations_serial/Policy/disappears (14.18s)
        --- PASS: TestAccOrganizations_serial/Policy/ImportAwsManagedPolicy (16.15s)
        --- FAIL: TestAccOrganizations_serial/Policy/basic (9.13s)
        --- PASS: TestAccOrganizations_serial/Policy/Description (27.34s)
        --- FAIL: TestAccOrganizations_serial/Policy/Type_Tag (8.30s)
    --- FAIL: TestAccOrganizations_serial/PolicyAttachment (65.83s)
        --- PASS: TestAccOrganizations_serial/PolicyAttachment/Root (20.29s)
        --- FAIL: TestAccOrganizations_serial/PolicyAttachment/Account (24.96s)
        --- PASS: TestAccOrganizations_serial/PolicyAttachment/OrganizationalUnit (20.59s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/organizations	264.208s
FAIL
make: *** [testacc] Error 1

@github-actions
Copy link

github-actions bot commented Jun 2, 2022

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 issues.
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 Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/organizations Issues and PRs that pertain to the organizations service. size/S Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants