Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Conversation

@rv-jgentile
Copy link

Ref. [Assist] Sage's redrive policy is removed and re-added on TF apply

Welcome to my Ted Talk.

Why

  • Currently topic subscriptions requiring a redrive policy are created alongside the app terraform, because redrive policy is not implemented in this module (or the module it was forked from - I checked).
  • This module still creates the subscriptions, however, which causes it to remove the redrive policy from the resource that actually created it.

Confused? Me too, here's some terraform:

  • Pay close attention: These are the same resource (note the id/arn), and they live in the state file in two different locations.

Exhibit A

$ terraform state show 'module.velocify.module.event-sns.aws_sns_topic_subscription.subscription[0]'
# module.velocify.module.event-sns.aws_sns_topic_subscription.subscription[0]:
resource "aws_sns_topic_subscription" "subscription" {
    arn                             = "arn:aws:sns:us-east-1:446051487243:qa-interest-event:9fefb62f-a378-42e4-a44d-b750675ac167"
    confirmation_timeout_in_minutes = 1
    confirmation_was_authenticated  = true
    endpoint                        = "arn:aws:lambda:us-east-1:446051487243:function:qa-velocify"
    endpoint_auto_confirms          = false
    id                              = "arn:aws:sns:us-east-1:446051487243:qa-interest-event:9fefb62f-a378-42e4-a44d-b750675ac167"
    owner_id                        = "446051487243"
    pending_confirmation            = false
    protocol                        = "lambda"
    raw_message_delivery            = false
    topic_arn                       = "arn:aws:sns:us-east-1:446051487243:qa-interest-event"
}

Exhibit B

$ terraform state show aws_sns_topic_subscription.invoke_with_sns
# aws_sns_topic_subscription.invoke_with_sns:
resource "aws_sns_topic_subscription" "invoke_with_sns" {
    arn                             = "arn:aws:sns:us-east-1:446051487243:qa-interest-event:9fefb62f-a378-42e4-a44d-b750675ac167"
    confirmation_timeout_in_minutes = 1
    confirmation_was_authenticated  = true
    endpoint                        = "arn:aws:lambda:us-east-1:446051487243:function:qa-velocify"
    endpoint_auto_confirms          = false
    id                              = "arn:aws:sns:us-east-1:446051487243:qa-interest-event:9fefb62f-a378-42e4-a44d-b750675ac167"
    owner_id                        = "446051487243"
    pending_confirmation            = false
    protocol                        = "lambda"
    raw_message_delivery            = false
    redrive_policy                  = jsonencode(
        {
            deadLetterTargetArn = "arn:aws:sqs:us-east-1:446051487243:qa-dead-letter"
        }
    )
    topic_arn                       = "arn:aws:sns:us-east-1:446051487243:qa-interest-event"
}

What does this PR do?

  • This adds redrive_policy to a list of ignored changes in the sns submodule. The submodule will still function the same because redrive_policy has never actually been passed into it, so it's never actually been there, so it's always been implicitly ignored anyway.
  • This allows application infra to declare ad-hoc subscriptions with a redrive policy and prevents this submodule from destroying that policy. Basically it doesn't know that it's there.

@rv-jgentile rv-jgentile requested a review from a team June 24, 2021 19:48
@rv-jgentile rv-jgentile merged commit 71de683 into master Jun 24, 2021
@rv-jgentile rv-jgentile deleted the f/FP-914_ignore_redrive branch June 24, 2021 19:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants