簡體   English   中英

aws sns 自動確認訂閱

[英]aws sns auto confirm subscription

我有這個 terraform 來自動確認 sns 主題訂閱警報,但它不會自動確認,而是在向我的收件箱發送電子郵件時一直顯示待確認。 有什么可以阻止這種情況發生的嗎?


resource "aws_sns_topic" "aws_logins" {
  name = "aws-console-logins"
}

resource "aws_sns_topic_policy" "default" {
  arn    = aws_sns_topic.aws_logins.arn
  policy = data.aws_iam_policy_document.sns_topic_policy.json
}

data "aws_iam_policy_document" "sns_topic_policy" {
  statement {
    effect  = "Allow"
    actions = ["SNS:Publish"]

    principals {
      type        = "AWS"
      identifiers = ["*"]
    }

    resources = [aws_sns_topic.aws_logins.arn]
  }
}

# Creates a subscription and subscript to the sns topic
resource "aws_sns_topic_subscription" "guard_duty_findings" {
  topic_arn                       = aws_sns_topic.aws_logins.arn
  endpoint_auto_confirms          = true
  protocol                        = "email"
  endpoint                        = "......@gmail.com"
}

我嘗試添加超時但超時僅適用於 http 和 https 協議

遺憾的是,您無法自動確認 email SNS 訂閱。

endpoint_auto_confirms的定義是: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_subscription#endpoint_auto_confirms

endpoint_auto_confirms -(可選)端點是否能夠自動確認訂閱(例如,PagerDuty)。 默認為假。

這僅定義端點是否能夠自動確認。

事實上,等待確認在 email 協議的代碼中明確設置為 false: https://github.com/hashicorp/terraform-provider-aws/blob/503b118c9a0f91384010f0503e117d125c3ae9ab/internal/service/sns/topic_subscription.go

waitForConfirmation := true

if !d.Get("endpoint_auto_confirms").(bool) && strings.Contains(d.Get("protocol").(string), "http") {
    waitForConfirmation = false
}

if strings.Contains(d.Get("protocol").(string), "email") {
    waitForConfirmation = false
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM