amazon-web-services - AWS 聊天机器人未发布到 Slack

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

我正在尝试使用 CloudFormation 创建聊天框。当通过在通知 Topi 中创建消息来测试它时,没有任何内容发布到 slack。

通知.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:
                  - "*"

最佳答案

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

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

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

关于amazon-web-services - AWS 聊天机器人未发布到 Slack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68147792/

相关文章:

aws-lambda - AWS CloudFormation 将 SNS 触发器设置为 Lambda

android - 用户重新安装适用于 Amazon SNS 的 Android 应用程序后,如何获取端点 ARN?

aws-cloudformation - 云形成模板设计

php - 亚马逊 S3 : How to use SEO-friendly URLs for Images

scala - 使用 AWS s3 的分段上传 API 时出现内存不足问题

amazon-web-services - 将 csv 数据文件中的数组字段加载到 Athena 表中

amazon-web-services - 如何指示 AWS CloudFormation 模板在特定区域创建资源?

python - 如何找到一个包含特定字符串和最大数字的对象?

node.js - 在 AWS 中 SNS 提供的 header 列表中未收到订阅 URL?

amazon-web-services - Amazon API ItemSearch 返回 (400) 错误请求