【问题标题】:AWS Chatbot not publishing to SlackAWS Chatbot 未发布到 Slack
【发布时间】:2021-09-09 20:09:07
【问题描述】:

我正在尝试使用 CloudFormation 创建一个聊天框。通过在 Notifaction Topi 中创建消息对其进行测试时,不会将任何内容发布到 slack。

notifications.yml

AWSTemplateFormatVersion: 2010-09-09
Transform:
  - AWS::Serverless-2016-10-31

Parameters:
  Team:
    Type: String
  Environment:
    Type: String
  Domain:
    Type: String
  Channel:
    Type: String
  Workspace:
    Type: String

Resources:
  PipelineNotificationTopic:
    Type: AWS::SNS::Topic
    Properties:
      Tags:
        - Key: Domain
          Value: "CICD"
        - Key: Team
          Value: "Engineering"
      TopicName: "PipelineStatus"

  PipelineEventRule:
    Type: AWS::Events::Rule
    Properties:
      Description: "PipelineEventRule"
      EventPattern:
        source:
          - "aws.codepipeline"
        detail-type:
          - "CodePipeline Pipeline Execution State Change"
        detail:
          state:
            - STARTED
            - CANCELED
            - FAILED
            - SUCCEEDED
      State: "ENABLED"
      Targets:
        - Arn:
            Ref: PipelineNotificationTopic
          Id: "PipelineNotificationTopic"

  SlackBot:
    Type: AWS::Chatbot::SlackChannelConfiguration
    Properties:
      ConfigurationName: !Sub ${Team}-${Environment}-${Domain}
      IamRoleArn: !GetAtt Role.Arn
      SlackChannelId: !Ref Channel
      SlackWorkspaceId: !Ref Workspace
      SnsTopicArns: 
        - !Ref PipelineNotificationTopic

  Role:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              Service: chatbot.amazonaws.com
            Action: sts:AssumeRole
      Policies:
        - PolicyName: Events
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Action:
                  - "events:*"
                Resource:
                  - "*"

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-sns aws-event-bridge aws-chatbot


    【解决方案1】:

    您需要授权 Slack 频道收听已发布的 SNS 通知。请参阅link [1],了解有关分步操作的更多信息。此外,我会听取他们的建议并使用 Amazon 的预定义角色开放 IAM 权限。 (如 AWS-Chatbot-NotificationsOnly-Policy、AWS-Chatbot-LambdaInvoke-Policy、AWS-Chatbot-ReadOnly-Commands-Policy - 如果您认为它们过于宽松,您可以在使用自定义策略后拨回它们) .更多信息请访问link [2]

    1https://docs.aws.amazon.com/chatbot/latest/adminguide/getting-started.html

    2https://docs.aws.amazon.com/chatbot/latest/adminguide/getting-started.html#editing-iam-roles-for-chatbot

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-11
      • 1970-01-01
      相关资源
      最近更新 更多