class SlackChannelConfiguration (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Chatbot.SlackChannelConfiguration |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awschatbot#SlackChannelConfiguration |
Java | software.amazon.awscdk.services.chatbot.SlackChannelConfiguration |
Python | aws_cdk.aws_chatbot.SlackChannelConfiguration |
TypeScript (source) | aws-cdk-lib » aws_chatbot » SlackChannelConfiguration |
Implements
IConstruct
, IDependable
, IResource
, ISlack
, IGrantable
, INotification
A new Slack channel configuration.
Example
import * as chatbot from 'aws-cdk-lib/aws-chatbot';
declare const project: codebuild.Project;
const target = new chatbot.SlackChannelConfiguration(this, 'MySlackChannel', {
slackChannelConfigurationName: 'YOUR_CHANNEL_NAME',
slackWorkspaceId: 'YOUR_SLACK_WORKSPACE_ID',
slackChannelId: 'YOUR_SLACK_CHANNEL_ID',
});
const rule = project.notifyOnBuildSucceeded('NotifyOnBuildSucceeded', target);
Initializer
new SlackChannelConfiguration(scope: Construct, id: string, props: SlackChannelConfigurationProps)
Parameters
- scope
Construct
- id
string
- props
Slack
Channel Configuration Props
Construct Props
Name | Type | Description |
---|---|---|
slack | string | The name of Slack channel configuration. |
slack | string | The ID of the Slack channel. |
slack | string | The ID of the Slack workspace authorized with AWS Chatbot. |
guardrail | IManaged [] | A list of IAM managed policies that are applied as channel guardrails. |
log | Retention | The number of days log events are kept in CloudWatch Logs. |
log | Log | When log retention is specified, a custom resource attempts to create the CloudWatch log group. |
log | IRole | The IAM role for the Lambda function associated with the custom resource that sets the retention policy. |
logging | Logging | Specifies the logging level for this configuration. |
notification | ITopic [] | The SNS topics that deliver notifications to AWS Chatbot. |
role? | IRole | The permission role of Slack channel configuration. |
user | boolean | Enables use of a user role requirement in your chat configuration. |
slackChannelConfigurationName
Type:
string
The name of Slack channel configuration.
slackChannelId
Type:
string
The ID of the Slack channel.
To get the ID, open Slack, right click on the channel name in the left pane, then choose Copy Link. The channel ID is the 9-character string at the end of the URL. For example, ABCBBLZZZ.
slackWorkspaceId
Type:
string
The ID of the Slack workspace authorized with AWS Chatbot.
To get the workspace ID, you must perform the initial authorization flow with Slack in the AWS Chatbot console. Then you can copy and paste the workspace ID from the console. For more details, see steps 1-4 in Setting Up AWS Chatbot with Slack in the AWS Chatbot User Guide.
See also: https://docs.aws.amazon.com/chatbot/latest/adminguide/setting-up.html#Setup_intro
guardrailPolicies?
Type:
IManaged
[]
(optional, default: The AWS managed 'AdministratorAccess' policy is applied as a default if this is not set.)
A list of IAM managed policies that are applied as channel guardrails.
logRetention?
Type:
Retention
(optional, default: logs.RetentionDays.INFINITE)
The number of days log events are kept in CloudWatch Logs.
When updating
this property, unsetting it doesn't remove the log retention policy. To
remove the retention policy, set the value to INFINITE
.
logRetentionRetryOptions?
Type:
Log
(optional, default: Default AWS SDK retry options.)
When log retention is specified, a custom resource attempts to create the CloudWatch log group.
These options control the retry policy when interacting with CloudWatch APIs.
logRetentionRole?
Type:
IRole
(optional, default: A new role is created.)
The IAM role for the Lambda function associated with the custom resource that sets the retention policy.
loggingLevel?
Type:
Logging
(optional, default: LoggingLevel.NONE)
Specifies the logging level for this configuration.
This property affects the log entries pushed to Amazon CloudWatch Logs.
notificationTopics?
Type:
ITopic
[]
(optional, default: None)
The SNS topics that deliver notifications to AWS Chatbot.
role?
Type:
IRole
(optional, default: A role will be created.)
The permission role of Slack channel configuration.
userRoleRequired?
Type:
boolean
(optional, default: false)
Enables use of a user role requirement in your chat configuration.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
grant | IPrincipal | The principal to grant permissions to. |
node | Node | The tree node. |
slack | string | The ARN of the Slack channel configuration In the form of arn:aws:chatbot:{region}:{account}:chat-configuration/slack-channel/{slackChannelName}. |
slack | string | The name of Slack channel configuration. |
stack | Stack | The stack in which this resource is defined. |
role? | IRole | The permission role of Slack channel configuration. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
grantPrincipal
Type:
IPrincipal
The principal to grant permissions to.
node
Type:
Node
The tree node.
slackChannelConfigurationArn
Type:
string
The ARN of the Slack channel configuration In the form of arn:aws:chatbot:{region}:{account}:chat-configuration/slack-channel/{slackChannelName}.
slackChannelConfigurationName
Type:
string
The name of Slack channel configuration.
stack
Type:
Stack
The stack in which this resource is defined.
role?
Type:
IRole
(optional)
The permission role of Slack channel configuration.
Methods
Name | Description |
---|---|
add | Adds a SNS topic that deliver notifications to AWS Chatbot. |
add | Adds extra permission to iam-role of Slack channel configuration. |
apply | Apply the given removal policy to this resource. |
bind | Returns a target configuration for notification rule. |
metric(metricName, props?) | Return the given named metric for this SlackChannelConfiguration. |
to | Returns a string representation of this construct. |
static from | Import an existing Slack channel configuration provided an ARN. |
static metric | Return the given named metric for All SlackChannelConfigurations. |
NotificationTopic(notificationTopic)
addpublic addNotificationTopic(notificationTopic: ITopic): void
Parameters
- notificationTopic
ITopic
Adds a SNS topic that deliver notifications to AWS Chatbot.
ToRolePolicy(statement)
addpublic addToRolePolicy(statement: PolicyStatement): void
Parameters
- statement
Policy
Statement
Adds extra permission to iam-role of Slack channel configuration.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
AsNotificationRuleTarget(_scope)
bindpublic bindAsNotificationRuleTarget(_scope: Construct): NotificationRuleTargetConfig
Parameters
- _scope
Construct
Returns
Returns a target configuration for notification rule.
metric(metricName, props?)
public metric(metricName: string, props?: MetricOptions): Metric
Parameters
- metricName
string
- props
Metric
Options
Returns
Return the given named metric for this SlackChannelConfiguration.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
SlackChannelConfigurationArn(scope, id, slackChannelConfigurationArn)
static frompublic static fromSlackChannelConfigurationArn(scope: Construct, id: string, slackChannelConfigurationArn: string): ISlackChannelConfiguration
Parameters
- scope
Construct
— The parent creating construct. - id
string
— The construct's name. - slackChannelConfigurationArn
string
— configuration ARN (i.e. arn:aws:chatbot::1234567890:chat-configuration/slack-channel/my-slack).
Returns
Import an existing Slack channel configuration provided an ARN.
All(metricName, props?)
static metricpublic static metricAll(metricName: string, props?: MetricOptions): Metric
Parameters
- metricName
string
- props
Metric
Options
Returns
Return the given named metric for All SlackChannelConfigurations.