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

aws_sns_topic_subscription resource produced new value for was present but now absent #11737

Closed
jochen42 opened this issue Jan 23, 2020 · 20 comments · Fixed by #18475
Closed
Assignees
Labels
bug Addresses a defect in current functionality. service/sns Issues and PRs that pertain to the sns service.
Milestone

Comments

@jochen42
Copy link

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 Version

$ terraform -v
Terraform v0.12.20

  • provider.aws v2.45.0

Affected Resource(s)

  • aws_sns_topic_subscription

Terraform Configuration Files

resource "aws_sns_topic_subscription" "oncall-topic-subscription" {
  endpoint               = "https://alert.examlpe.com/somehook"
  protocol               = "HTTPS"
  topic_arn              = aws_sns_topic.oncall-topic.arn
  endpoint_auto_confirms = true
}

Debug Output

Panic Output

Expected Behavior

It's happening after upgrade from Terraform 0.11 to 0.12. Since the topic_subscription is already in state, aws and there aren't any changes, the existing subscription should keep unchanged.

Actual Behavior

Terraform fails with the following message

>> #1530018634 Error:
>> #1530018634 Error: Error: Provider produced inconsistent result after apply
>> #1530018634 Error:
>> #1530018634 Error: When applying changes to aws_sns_topic_subscription.oncall-topic-subscription,
>> #1530018634 Error: provider "registry.terraform.io/-/aws" produced an unexpected new value for
>> #1530018634 Error: was present, but now absent.
>> #1530018634 Error:
>> #1530018634 Error: This is a bug in the provider, which should be reported in the provider's own
>> #1530018634 Error: issue tracker.
>> #1530018634 Error:
>> #1530018634 Error: ============================================
>> #1530018634 Error: Base path: terraform/k28s/20_infrastructure:
>> #1530018634 Error: ERROR: Terraform apply failed
>> #1530018634 Error: ============================================
2020/01/23 15:21:48 exit status 1

Steps to Reproduce

  1. terraform apply

Important Factoids

References

@ghost ghost added the service/sns Issues and PRs that pertain to the sns service. label Jan 23, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 23, 2020
@jochen42
Copy link
Author

#10473, #10930

@bshilliam
Copy link

Hit the same issue. In my case it looked like it was not hitting this retry logic below when it got "pending confirmation" back initially from AWS. So it would end up failing with the same error message as above.

if strings.Contains(protocol, "http") && subscriptionHasPendingConfirmation(output.SubscriptionArn) { ...

And the reason it was skipping this was because I had protocol = "HTTPS" in my aws_sns_topic_subscription definition.

I don't know how it worked with all caps in versions < 0.12. But after changing to protocol = "https" the creation and update works fine in Terraform.

I'm thinking there should be a validation of lowercase values for protocol.

@amarouane-ABDELHAK
Copy link

@bshilliam I am having the same problem. Where did you add subscriptionHasPendingConfirmation in output.tf file?

@bshilliam
Copy link

@amarouane-ABDELHAK, only change needed was to change from protocol = "HTTPS" to protocol = "https" in my tf file.

@amarouane-ABDELHAK
Copy link

Thank you. I have protocol sqs and it is already in lowercase. so this functionsubscriptionHasPendingConfirmation is a terraform internal function?

@bshilliam
Copy link

Yea @amarouane-ABDELHAK that was in the internal logic where I found my scenario wasn't triggering properly because of the uppercase HTTP.

@MattMcKeithen
Copy link

MattMcKeithen commented Apr 6, 2020

I've also encountered a similiar issue: #12692

@ghost
Copy link

ghost commented Apr 21, 2020

Encountered just now:

Error: Provider produced inconsistent result after apply

When applying changes to module.cloudwatch-log-metric-filters.module.server-log-filter-metric-blah.aws_cloudwatch_log_metric_filter.custom,
provider "registry.terraform.io/-/aws" produced an unexpected new value for
was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own issue tracker.

@dtns2
Copy link

dtns2 commented May 1, 2020

Also encountered same issue when re-attaching IAM policies to an IAM role:

Error: Provider produced inconsistent result after apply

When applying changes to
module.iam_role_default.aws_iam_role_policy_attachment.iam_role_policy_attach[3],
provider "registry.terraform.io/-/aws" produced an unexpected new value for
was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

@cedriclecoz
Copy link

+1 for the attaching policy to IAM role.

@willcampbell433
Copy link

willcampbell433 commented May 20, 2020

Encountering same issue when attaching policies to IAM role:

Error: Provider produced inconsistent result after apply

When applying changes to aws_iam_role_policy_attachment.db_ops_policy_attach,
provider "aws" produced an unexpected new value for was present, but now
absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

@ychenbioinfo
Copy link

ychenbioinfo commented Jun 12, 2020

Same issue when attaching policies

Error: Provider produced inconsistent result after apply

When applying changes to
aws_iam_role_policy_attachment.attach-ecs-instance-role[2], provider
"registry.terraform.io/-/aws" produced an unexpected new value for was
present, but now absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

@magnetik
Copy link

magnetik commented Jul 7, 2020

Same issue with provider 2.69.0

@dsg9321
Copy link

dsg9321 commented Jul 14, 2020

Faced similar issue

Error: Provider produced inconsistent result after apply

When applying changes to aws_s3_bucket_object.principal_policy, provider
"registry.terraform.io/-/aws" produced an unexpected new value for was
present, but now absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

Terraform version : 0.12.28

@kabelak
Copy link

kabelak commented Aug 18, 2020

Same issue.
Terraform: 0.12.20
AWS: 2.70.0

Error: Provider produced inconsistent result after apply
 
When applying changes to
aws_cloudwatch_metric_alarm.webserver_httpd_service[2], provider
"registry.terraform.io/-/aws" produced an unexpected new value for was
present, but now absent.
 
This is a bug in the provider, which should be reported in the provider's own
issue tracker.

@gclough
Copy link

gclough commented Sep 11, 2020

Same issue, with the latest AWS provider:

 - Downloading plugin for provider "aws" (hashicorp/aws) 3.6.0...
$ terraform --version
Terraform v0.12.28

ERROR:

 Error: Provider produced inconsistent result after apply
 When applying changes to
 module.postgres-db.aws_cloudwatch_event_rule.auto_minor_version_upgrade[0],
 provider "registry.terraform.io/-/aws" produced an unexpected new value for
 was present, but now absent.
 This is a bug in the provider, which should be reported in the provider's own
 issue tracker.

@sannithibalaji
Copy link

faced a similar issue, but when I gave the protocol in a small case (https) it worked fine.

@ignas-sakalauskas-cko
Copy link

Just run into the same issue when trying to create cross-account SQS subscription.

bflad added a commit that referenced this issue Mar 30, 2021
…l consistency, enforce lowercase protocol argument validation

Reference: #10225
Reference: #11737
Reference: #12692
Reference: #16695
Reference: #16796

The `protocol` validation update is to catch where the API accepts uppercase values such as `HTTPS`, but prevents proper handling when the API canonicalizes it to lowercase. The API documentation and existing Terraform documentation solely use lowercase.

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSSNSTopicSubscription_autoConfirmingEndpoint (95.60s)
--- PASS: TestAccAWSSNSTopicSubscription_autoConfirmingSecuredEndpoint (137.43s)
--- PASS: TestAccAWSSNSTopicSubscription_basic (66.20s)
--- PASS: TestAccAWSSNSTopicSubscription_deliveryPolicy (69.55s)
--- PASS: TestAccAWSSNSTopicSubscription_disappears (74.02s)
--- PASS: TestAccAWSSNSTopicSubscription_disappears_topic (75.13s)
--- PASS: TestAccAWSSNSTopicSubscription_email (16.78s)
--- PASS: TestAccAWSSNSTopicSubscription_filterPolicy (71.62s)
--- PASS: TestAccAWSSNSTopicSubscription_firehose (140.29s)
--- PASS: TestAccAWSSNSTopicSubscription_rawMessageDelivery (69.77s)
--- PASS: TestAccAWSSNSTopicSubscription_redrivePolicy (64.88s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- PASS: TestAccAWSSNSTopicSubscription_basic (70.13s)
--- PASS: TestAccAWSSNSTopicSubscription_deliveryPolicy (106.45s)
--- PASS: TestAccAWSSNSTopicSubscription_disappears (82.09s)
--- PASS: TestAccAWSSNSTopicSubscription_disappears_topic (68.14s)
--- PASS: TestAccAWSSNSTopicSubscription_email (20.04s)
--- PASS: TestAccAWSSNSTopicSubscription_filterPolicy (106.32s)
--- PASS: TestAccAWSSNSTopicSubscription_rawMessageDelivery (95.36s)
--- PASS: TestAccAWSSNSTopicSubscription_redrivePolicy (110.75s)
--- SKIP: TestAccAWSSNSTopicSubscription_autoConfirmingEndpoint (1.41s)
--- SKIP: TestAccAWSSNSTopicSubscription_autoConfirmingSecuredEndpoint (1.41s)
--- SKIP: TestAccAWSSNSTopicSubscription_firehose (53.36s)
```
@bflad bflad self-assigned this Mar 30, 2021
bflad added a commit that referenced this issue Mar 30, 2021
…l consistency, enforce lowercase protocol argument validation (#18475)

* resource/aws_sns_topic_subscription: Handle read-after-create eventual consistency, enforce lowercase protocol argument validation

Reference: #10225
Reference: #11737
Reference: #12692
Reference: #16695
Reference: #16796

The `protocol` validation update is to catch where the API accepts uppercase values such as `HTTPS`, but prevents proper handling when the API canonicalizes it to lowercase. The API documentation and existing Terraform documentation solely use lowercase.

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSSNSTopicSubscription_autoConfirmingEndpoint (95.60s)
--- PASS: TestAccAWSSNSTopicSubscription_autoConfirmingSecuredEndpoint (137.43s)
--- PASS: TestAccAWSSNSTopicSubscription_basic (66.20s)
--- PASS: TestAccAWSSNSTopicSubscription_deliveryPolicy (69.55s)
--- PASS: TestAccAWSSNSTopicSubscription_disappears (74.02s)
--- PASS: TestAccAWSSNSTopicSubscription_disappears_topic (75.13s)
--- PASS: TestAccAWSSNSTopicSubscription_email (16.78s)
--- PASS: TestAccAWSSNSTopicSubscription_filterPolicy (71.62s)
--- PASS: TestAccAWSSNSTopicSubscription_firehose (140.29s)
--- PASS: TestAccAWSSNSTopicSubscription_rawMessageDelivery (69.77s)
--- PASS: TestAccAWSSNSTopicSubscription_redrivePolicy (64.88s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- PASS: TestAccAWSSNSTopicSubscription_basic (70.13s)
--- PASS: TestAccAWSSNSTopicSubscription_deliveryPolicy (106.45s)
--- PASS: TestAccAWSSNSTopicSubscription_disappears (82.09s)
--- PASS: TestAccAWSSNSTopicSubscription_disappears_topic (68.14s)
--- PASS: TestAccAWSSNSTopicSubscription_email (20.04s)
--- PASS: TestAccAWSSNSTopicSubscription_filterPolicy (106.32s)
--- PASS: TestAccAWSSNSTopicSubscription_rawMessageDelivery (95.36s)
--- PASS: TestAccAWSSNSTopicSubscription_redrivePolicy (110.75s)
--- SKIP: TestAccAWSSNSTopicSubscription_autoConfirmingEndpoint (1.41s)
--- SKIP: TestAccAWSSNSTopicSubscription_autoConfirmingSecuredEndpoint (1.41s)
--- SKIP: TestAccAWSSNSTopicSubscription_firehose (53.36s)
```

* Update CHANGELOG for #18475
@github-actions github-actions bot added this to the v3.35.0 milestone Mar 30, 2021
@ghost
Copy link

ghost commented Apr 1, 2021

This has been released in version 3.35.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 Apr 30, 2021

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 Apr 30, 2021
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. service/sns Issues and PRs that pertain to the sns service.
Projects
None yet