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 doesn't support unconfirmed endpoints #7782

Closed
lxop opened this issue Mar 1, 2019 · 16 comments
Closed

aws_sns_topic_subscription doesn't support unconfirmed endpoints #7782

lxop opened this issue Mar 1, 2019 · 16 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/sns Issues and PRs that pertain to the sns service.

Comments

@lxop
Copy link
Contributor

lxop commented Mar 1, 2019

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 "me too" comments, 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 v0.11.11

  • provider.aws v1.60.0

Affected Resource(s)

  • aws_sns_topic_subscription

Expected Behavior

A subscription is created with an email endpoint (or non-auto-confirming HTTP endpoint). If the subscription is not confirmed, then the endpoint simply doesn't receive any messages.

Actual Behavior

The resource doesn't allow these subscriptions. The resource docs note that

These are unsupported because the endpoint needs to be authorized and does not generate an ARN until the target email address has been validated. This breaks the Terraform model and as a result are not currently supported.

However the SNS API includes a parameter ReturnSubscriptionArn which can be set to true to request that the ARN is returned even if the subscription isn't confirmed. As such, an ARN is generated before the target email address has been validated, and this should then fit into Terraform's model.

@bflad bflad added the service/sns Issues and PRs that pertain to the sns service. label Mar 1, 2019
@lorengordon
Copy link
Contributor

Yes, please! 😁

@lorengordon
Copy link
Contributor

FWIW, looks like this is a new-ish feature of the service, became available in the SDK in June 2018.

@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Mar 6, 2019
@lxop
Copy link
Contributor Author

lxop commented Mar 10, 2019

Starting to look at this

@lxop
Copy link
Contributor Author

lxop commented Mar 12, 2019

It's not looking pretty - creation appears to work fine, but it all falls over in the destruction department. It is not possible (by any means, API or console) to delete a subscription before it is confirmed. This seems like a fundamentally pointless restriction and I have asked AWS why it is the case, but it seems to have been this way for a long time so I'm not expecting any changes any time soon.

It would be possible to simply accept this restriction and report the error to the user during destruction, but this would then mean that an infrastructure deployment would be impossible to destroy if it includes an unconfirmed subscription. Making the failure non-fatal would mean that destroying a subscription does not necessarily destroy that subscription (if it were unconfirmed when the destroy command was performed, then the recipient subsequently confirmed the subscription, then it would be active but untracked by terraform).

So I'm not entirely sure what to do about this now. The HTTP/S subscription presumably suffers from this same problem if I specify auto-accepts on a subscription that doesn't actually auto-accept. I might have to look into how that is handled.

@bryanlalexander
Copy link
Contributor

bryanlalexander commented May 10, 2019

@lxop any additional updates on this? It seems these are automatically deleted after 72 hours if not yet confirmed. This edge-case may be acceptable or perhaps a hard-fail option to hard-fail if cleanup is not possible.

resource "aws_sns_topic_subscription" "topic-subscription" {
  topic_arn       = "${aws_sns_topic.topic.arn}"
  protocol        = "email"
  endpoint        = "${var.email_address}"
  require_cleanup = true
}

@alex-aire
Copy link

@bryanlalexander no update yet - I haven't had much time to work on it. I was/am considering this approach, but I'm not sure about how good it is to introduce a failure-mode to the destroy operation. It would need to also have a way to change the requirement after removing the resource block, otherwise a user could find themself stuck unable to destroy their infrastructure because the resource block that is failing doesn't exist anymore.
In saying that, I suppose the user could simply re-add a resource block with the appropriate name, and update the requirement there.

@bryanlalexander
Copy link
Contributor

@alex-aire I'm happy to invest the time, if we can come to an agreeable solution. @bflad do you have a preference for a path forward on this item?

@jonjohnston
Copy link

Any progress on this? I would love to have this included.

@crobo1337
Copy link

Not sure if I'm having the same issue, or a slightly different one with the same potential solution. I'm registering a subscription with the pagerduty HTTPS API, the subscription auto confirms, and I can confirm that in the console, but every subsequent build fails with "Error: Protocol http/https is only supported for endpoints which auto confirms!"

@sagagliardo
Copy link

I'm also having similar issues to @crobo1337 with similar messages, setting up pager duty subs.

@devonbleak
Copy link
Contributor

@crobo1337 @sagagliardo Re the PagerDuty issues, there are 2 different URLs in the docs: https://events.pagerduty.com/x-ere/{INTEGRATION_KEY} in the text and https://events.pagerduty.com/integration/{INTEGRATION_KEY}/enqueue in the screenshots. Only the second one (/integration/{INTEGRATION_KEY}/enqueue) would work for me. Hope that helps.

@scastria
Copy link

scastria commented Mar 4, 2021

What is the status of this? It is very annoying not to be able to subscribe via email within TF. The fix is trivial. How many people need to upvote to get this merged in?

@breathingdust
Copy link
Member

Hi all 👋 Just letting you know that this is issue is featured on this quarters roadmap. If a PR exists to close the issue a maintainer will review and either make changes directly, or work with the original author to get the contribution merged. If you have written a PR to resolve the issue please ensure the "Allow edits from maintainers" box is checked. Thanks for your patience and we are looking forward to getting this merged soon!

@scastria
Copy link

scastria commented Feb 4, 2022

I thought this was fixed a long time ago. I have been using it probably for a year now. Well, at least the email endpoint. Maybe there are more endpoint types that are still not supported.

@gdavison
Copy link
Contributor

gdavison commented Jul 6, 2022

Support was added in v3.30.0 of the AWS Provider, released 25 February 2021. One caveat is #25059, since some API calls still do not return an actual ARN while a subscription is pending.

@gdavison gdavison closed this as completed Jul 6, 2022
@github-actions
Copy link

github-actions bot commented Aug 6, 2022

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 have found a problem that seems similar to this, 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 Aug 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/sns Issues and PRs that pertain to the sns service.
Projects
None yet