SNS tOPIC does not send message to my AWS Chatbot

0

My SNS tOPIC does not send message to my AWS Chatbot and DeliveryStatusLogging Does not work even after setting

Please i need assistant and sample code in Cloudformation YAML to rectify this

Below is my CFn Code

CodeCommitRepoNotificationRuleSNSTopic:
    Type: AWS::SNS::Topic
    DeletionPolicy: Delete
    Properties:
      DisplayName:
        Fn::Sub: ${RepositoryName}NotifcationRuleSNSTopic
      TopicName:
        Fn::Sub: ${RepositoryName}NotifcationRuleSNSTopic
      DeliveryStatusLogging:
      - Protocol: http/s
        SuccessFeedbackSampleRate: '45'
      - Protocol: lambda
        SuccessFeedbackSampleRate: '45'
1 Answer
2
Accepted Answer

Hello.

I have created a CloudFormation like the one below in the past.
This template uses EventBridge to retrieve AWS health dashboard events and send them from AWS Chatbot to Slack via Amazon SNS.

AWSTemplateFormatVersion: "2010-09-09"
Description: aws-health-check-chatbot

Parameters:
  SlackWorkspaceId:
    Type: String
    Default: ""
  SlackChannelId:
    Type: String
    Default: ""

Resources:
  # IAM role
  HealthCheckIAMloreChatbot:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - chatbot.amazonaws.com
            Action:
              - "sts:AssumeRole"
      Policies:
        - PolicyName: policies
          PolicyDocument:
            Version: "2012-10-17"
            Statement:
              - Effect: "Allow"
                Action:
                  - cloudwatch:Describe*
                  - cloudwatch:Get*
                  - cloudwatch:List*
                Resource: "*"

  # AWS Chatbot
  HealthCheckChatbotConfiguration:
    Type: AWS::Chatbot::SlackChannelConfiguration
    Properties:
      ConfigurationName: HealthCheckChatbotConfiguration
      GuardrailPolicies:
        - arn:aws:iam::aws:policy/AdministratorAccess
      IamRoleArn: !GetAtt HealthCheckIAMloreChatbot.Arn
      SlackChannelId: !Ref SlackChannelId
      SlackWorkspaceId: !Ref SlackWorkspaceId
      SnsTopicArns:
        - !Ref HealthCheckSNSTopic

  # EventBridge
  HealthCheckEventBridgeRule:
    Type: AWS::Events::Rule
    Properties:
      Name: HealthCheckEventBridgeRule
      EventPattern:
        source:
          - aws.health
        detail-type:
          - AWS Health Event
      Targets:
        - Arn: !Ref HealthCheckSNSTopic
          Id: sns-topic

  # SNS topic
  HealthCheckSNSTopic:
    Type: AWS::SNS::Topic
    Properties:
      TopicName: HealthCheckSNSTopic

  HealthCheckTopicPolicy:
    Type: AWS::SNS::TopicPolicy
    Properties:
      PolicyDocument:
        Statement:
          - Sid: AllowServices
            Effect: Allow
            Principal:
              Service:
                - events.amazonaws.com
            Action: "sns:Publish"
            Resource:
              - !Ref HealthCheckSNSTopic
      Topics:
        - !Ref HealthCheckSNSTopic
profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions