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

resource/aws_cloudwatch_event_permission: arn: invalid prefix Error #16318

Closed
bflad opened this issue Nov 19, 2020 · 2 comments · Fixed by #16319
Closed

resource/aws_cloudwatch_event_permission: arn: invalid prefix Error #16318

bflad opened this issue Nov 19, 2020 · 2 comments · Fixed by #16319
Assignees
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. upstream Addresses functionality related to the cloud provider.
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Nov 19, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue 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 issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform CLI v0.12.29

Terraform AWS Provider main branch

Affected Resource(s)

  • aws_cloudwatch_event_permission

Terraform Configuration Files

resource "aws_cloudwatch_event_permission" "test" {
  principal    = "111111111111"
  statement_id = "tf-acc-test-8464970479615465340"
}

Debug Output

-----------------------------------------------------
2020/11/19 11:05:57 [DEBUG] [aws-sdk-go] DEBUG: Response events/DescribeEventBus Details:
...
2020/11/19 11:05:57 [DEBUG] [aws-sdk-go] {"Arn":"arn:aws:events:us-west-2:--OMITTED--:event-bus/tf-acc-test-bus-4411535373795943779","Name":"tf-acc-test-bus-4411535373795943779","Policy":"{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"tf-acc-test-8464970479615465340\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"111111111111\"},\"Action\":\"events:PutEvents\",\"Resource\":\"arn:aws:events:us-west-2:--OMITTED--:event-bus/tf-acc-test-bus-4411535373795943779\"}]}"}
2020/11/19 11:05:57 [DEBUG] Finding statement (tf-acc-test-8464970479615465340) in CloudWatch Events permission policy: {
  Version: "2012-10-17",
  ID: "",
  Statements: [{
      Sid: "tf-acc-test-8464970479615465340",
      Effect: "Allow",
      Action: "events:PutEvents",
      Principal: map[AWS:111111111111],
      Resource: "arn:aws:events:us-west-2:--OMITTED--:event-bus/tf-acc-test-bus-4411535373795943779"
    }]
}
2020/11/19 11:05:57 [WARN] Got error running Terraform: 2020/11/19 11:05:55 [DEBUG] Using modified User-Agent: Terraform/0.12.29 HashiCorp-terraform-exec/0.10.0

Error: error reading CloudWatch Events permission (tf-acc-test-bus-4411535373795943779/tf-acc-test-8464970479615465340): arn: invalid prefix

Expected Behavior

Terraform resources reads policy without error.

Actual Behavior

Starting earlier this week, the EventBridge API is returning the policy principal with just an account ID, rather than the root account ARN as has done for the last 3 years. This generates an error in our read logic for the resource, since it is assuming that it will receive an ARN:

Error: error reading CloudWatch Events permission (tf-acc-test-bus-4411535373795943779/tf-acc-test-8464970479615465340): arn: invalid prefix

In addition to supporting both field values in the read logic, the error message there should be clarified to denote what principal value is trying to parse as an ARN.

Steps to Reproduce

  1. TF_ACC=1 go test -parallel=20 -run='TestAccAWSCloudWatchEventPermission_' -timeout=4h -v

References

@bflad bflad added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. upstream Addresses functionality related to the cloud provider. labels Nov 19, 2020
@ghost ghost added service/cloudwatchevents service/cloudwatch Issues and PRs that pertain to the cloudwatch service. labels Nov 19, 2020
@bflad bflad self-assigned this Nov 19, 2020
bflad added a commit that referenced this issue Nov 19, 2020
… API returning account ID or root account ARN

Reference: #16318

Changes:

```
* resource/aws_cloudwatch_event_permission: Prevent `arn: invalid prefix` error during read due to API changes
```

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSCloudWatchEventPermission_Action (13.37s)
--- PASS: TestAccAWSCloudWatchEventPermission_EventBusName (14.15s)
--- PASS: TestAccAWSCloudWatchEventPermission_Multiple (19.11s)
--- PASS: TestAccAWSCloudWatchEventPermission_Condition (20.19s)
--- PASS: TestAccAWSCloudWatchEventPermission_basic (27.21s)
--- PASS: TestAccAWSCloudWatchEventPermission_Disappears (128.53s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- PASS: TestAccAWSCloudWatchEventPermission_EventBusName (18.98s)
--- PASS: TestAccAWSCloudWatchEventPermission_Action (19.05s)
--- PASS: TestAccAWSCloudWatchEventPermission_Multiple (26.89s)
--- PASS: TestAccAWSCloudWatchEventPermission_Condition (27.32s)
--- PASS: TestAccAWSCloudWatchEventPermission_basic (37.01s)
--- PASS: TestAccAWSCloudWatchEventPermission_Disappears (131.57s)
```
bflad added a commit that referenced this issue Nov 24, 2020
… API returning account ID or root account ARN (#16319)

Reference: #16318

Changes:

```
* resource/aws_cloudwatch_event_permission: Prevent `arn: invalid prefix` error during read due to API changes
```

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSCloudWatchEventPermission_Action (13.37s)
--- PASS: TestAccAWSCloudWatchEventPermission_EventBusName (14.15s)
--- PASS: TestAccAWSCloudWatchEventPermission_Multiple (19.11s)
--- PASS: TestAccAWSCloudWatchEventPermission_Condition (20.19s)
--- PASS: TestAccAWSCloudWatchEventPermission_basic (27.21s)
--- PASS: TestAccAWSCloudWatchEventPermission_Disappears (128.53s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- PASS: TestAccAWSCloudWatchEventPermission_EventBusName (18.98s)
--- PASS: TestAccAWSCloudWatchEventPermission_Action (19.05s)
--- PASS: TestAccAWSCloudWatchEventPermission_Multiple (26.89s)
--- PASS: TestAccAWSCloudWatchEventPermission_Condition (27.32s)
--- PASS: TestAccAWSCloudWatchEventPermission_basic (37.01s)
--- PASS: TestAccAWSCloudWatchEventPermission_Disappears (131.57s)
```
@github-actions github-actions bot added this to the v3.18.0 milestone Nov 24, 2020
@ghost
Copy link

ghost commented Nov 25, 2020

This has been released in version 3.18.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Dec 25, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. upstream Addresses functionality related to the cloud provider.
Projects
None yet
1 participant