aws-cdk-lib.aws_chatbot.SlackChannelConfiguration

class SlackChannelConfiguration (construct)

LanguageType name
.NETAmazon.CDK.AWS.Chatbot.SlackChannelConfiguration
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awschatbot#SlackChannelConfiguration
Javasoftware.amazon.awscdk.services.chatbot.SlackChannelConfiguration
Pythonaws_cdk.aws_chatbot.SlackChannelConfiguration
TypeScript (source)aws-cdk-lib » aws_chatbot » SlackChannelConfiguration

Implements IConstruct, IDependable, IResource, ISlackChannelConfiguration, IGrantable, INotificationRuleTarget

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 SlackChannelConfigurationProps

Construct Props

NameTypeDescription
slackChannelConfigurationNamestringThe name of Slack channel configuration.
slackChannelIdstringThe ID of the Slack channel.
slackWorkspaceIdstringThe ID of the Slack workspace authorized with AWS Chatbot.
guardrailPolicies?IManagedPolicy[]A list of IAM managed policies that are applied as channel guardrails.
logRetention?RetentionDaysThe number of days log events are kept in CloudWatch Logs.
logRetentionRetryOptions?LogRetentionRetryOptionsWhen log retention is specified, a custom resource attempts to create the CloudWatch log group.
logRetentionRole?IRoleThe IAM role for the Lambda function associated with the custom resource that sets the retention policy.
loggingLevel?LoggingLevelSpecifies the logging level for this configuration.
notificationTopics?ITopic[]The SNS topics that deliver notifications to AWS Chatbot.
role?IRoleThe permission role of Slack channel 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: IManagedPolicy[] (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: RetentionDays (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: LogRetentionRetryOptions (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: LoggingLevel (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.

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
grantPrincipalIPrincipalThe principal to grant permissions to.
nodeNodeThe tree node.
slackChannelConfigurationArnstringThe ARN of the Slack channel configuration In the form of arn:aws:chatbot:{region}:{account}:chat-configuration/slack-channel/{slackChannelName}.
slackChannelConfigurationNamestringThe name of Slack channel configuration.
stackStackThe stack in which this resource is defined.
role?IRoleThe permission role of Slack channel configuration.

env

Type: ResourceEnvironment

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

NameDescription
addNotificationTopic(notificationTopic)Adds a SNS topic that deliver notifications to AWS Chatbot.
addToRolePolicy(statement)Adds extra permission to iam-role of Slack channel configuration.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
bindAsNotificationRuleTarget(_scope)Returns a target configuration for notification rule.
metric(metricName, props?)Return the given named metric for this SlackChannelConfiguration.
toString()Returns a string representation of this construct.
static fromSlackChannelConfigurationArn(scope, id, slackChannelConfigurationArn)Import an existing Slack channel configuration provided an ARN.
static metricAll(metricName, props?)Return the given named metric for All SlackChannelConfigurations.

addNotificationTopic(notificationTopic)

public addNotificationTopic(notificationTopic: ITopic): void

Parameters

  • notificationTopic ITopic

Adds a SNS topic that deliver notifications to AWS Chatbot.


addToRolePolicy(statement)

public addToRolePolicy(statement: PolicyStatement): void

Parameters

  • statement PolicyStatement

Adds extra permission to iam-role of Slack channel configuration.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

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).


bindAsNotificationRuleTarget(_scope)

public bindAsNotificationRuleTarget(_scope: Construct): NotificationRuleTargetConfig

Parameters

  • _scope Construct

Returns

  • NotificationRuleTargetConfig

Returns a target configuration for notification rule.


metric(metricName, props?)

public metric(metricName: string, props?: MetricOptions): Metric

Parameters

  • metricName string
  • props MetricOptions

Returns

  • Metric

Return the given named metric for this SlackChannelConfiguration.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromSlackChannelConfigurationArn(scope, id, slackChannelConfigurationArn)

public 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

  • ISlackChannelConfiguration

Import an existing Slack channel configuration provided an ARN.


static metricAll(metricName, props?)

public static metricAll(metricName: string, props?: MetricOptions): Metric

Parameters

  • metricName string
  • props MetricOptions

Returns

  • Metric

Return the given named metric for All SlackChannelConfigurations.