Skip to content
GitHubXDiscord

ChannelAssociation

The ChannelAssociation resource allows you to manage AWS Notifications ChannelAssociations which enable notifications to be sent to various channels based on specified configurations.

This example demonstrates how to create a basic ChannelAssociation with the required properties.

import AWS from "alchemy/aws/control";
const basicChannelAssociation = await AWS.Notifications.ChannelAssociation("basicChannelAssociation", {
NotificationConfigurationArn: "arn:aws:notifications:us-east-1:123456789012:notification-configuration/example",
Arn: "arn:aws:notifications:us-east-1:123456789012:channel-association/example",
adopt: true // Adopts existing resource if it already exists
});

In this example, we configure a ChannelAssociation with additional properties such as CreationTime and LastUpdateTime.

const advancedChannelAssociation = await AWS.Notifications.ChannelAssociation("advancedChannelAssociation", {
NotificationConfigurationArn: "arn:aws:notifications:us-west-2:123456789012:notification-configuration/example-advanced",
Arn: "arn:aws:notifications:us-west-2:123456789012:channel-association/example-advanced",
adopt: false // Do not adopt existing resources
});

Use Case: Associating with a Lambda Function

Section titled “Use Case: Associating with a Lambda Function”

This example shows how to create a ChannelAssociation that is configured to work with an AWS Lambda function for sending notifications.

const lambdaChannelAssociation = await AWS.Notifications.ChannelAssociation("lambdaChannelAssociation", {
NotificationConfigurationArn: "arn:aws:notifications:us-east-1:123456789012:notification-configuration/lambda-function",
Arn: "arn:aws:notifications:us-east-1:123456789012:channel-association/lambda-function",
});

This example demonstrates how to associate a ChannelAssociation with an SNS topic for notifications.

const snsChannelAssociation = await AWS.Notifications.ChannelAssociation("snsChannelAssociation", {
NotificationConfigurationArn: "arn:aws:sns:us-east-1:123456789012:my-sns-topic",
Arn: "arn:aws:notifications:us-east-1:123456789012:channel-association/sns-topic",
adopt: true // Adopts existing resource
});