如何解决AWS Chatbot 未发布到 Slack notifications.yml
我正在尝试使用 CloudFormation 创建一个聊天框。通过在通知主题中创建消息来测试它时,没有任何内容可以发布到 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:
- "*"
解决方法
您需要授权slack频道收听已发布的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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。