Registry / aws / aws-cdk-aws-sns

aws-cdk-aws-sns

JSON →
library1.204.0pypiunverified

The `aws-cdk-aws-sns` library provides AWS Cloud Development Kit (CDK) constructs specifically for AWS Simple Notification Service (SNS) resources. This package is part of AWS CDK v1, which is currently in maintenance mode. For new projects, it is strongly recommended to use AWS CDK v2 and the consolidated `aws-cdk-lib` package. AWS CDK generally has a rapid release cadence, with minor versions released frequently, and major versions (like v2) introducing significant changes.

pip install aws-cdk.core==1.204.0 aws-cdk.aws-sns==1.204.0
INSTALL
IMPORT
SIG · AWS-CDK-AWS-SNS
A
aws-cdk-aws-sns
awsenv1.204.0
Install
4.5s avg
Import
Disk
34MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.204.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 35MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.5s · import 0.000s · 35MB
34MB installed
● package 34MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Topic
from aws_cdk import aws_sns
from aws_cdk_aws_sns import Topic
AWS CDK v1 constructs are imported from the `aws_cdk` namespace, not directly from the package name `aws_cdk_aws_sns`.
Topic
from aws_cdk import aws_sns
from aws_cdk.aws_sns import Topic
This import path is correct for AWS CDK v2 (where constructs are part of `aws-cdk-lib`), but not for this specific AWS CDK v1 package.

This quickstart demonstrates creating a basic AWS SNS Topic using `aws-cdk-aws-sns` within an AWS CDK v1 application. Save this as `app.py`, then run `cdk synth` from your terminal after installing the required packages (`aws-cdk.core` and `aws-cdk.aws-sns`) and setting up your AWS environment.

import os from aws_cdk import core as cdk from aws_cdk import aws_sns as sns class MySnsStack(cdk.Stack): def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None: super().__init__(scope, construct_id, **kwargs) # Create an SNS Topic topic = sns.Topic(self, "MyCdkSnsTopic", display_name="My First CDK SNS Topic" ) cdk.CfnOutput(self, "TopicName", value=topic.topic_name) cdk.CfnOutput(self, "TopicArn", value=topic.topic_arn) app = cdk.App() # Ensure AWS account and region are set via env vars or AWS CLI config for cdk synth/deploy # Example: MySnsStack(app, "MySnsStack", env=cdk.Environment(account=os.environ.get('CDK_DEFAULT_ACCOUNT'), region=os.environ.get('CDK_DEFAULT_REGION'))) MySnsStack(app, "MySnsStack") app.synth()
Debug
Known issues
breakingThis `aws-cdk-aws-sns` package is specifically for AWS CDK v1. AWS CDK v2 consolidated all constructs into a single `aws-cdk-lib` package and uses different import paths and sometimes different construct properties. Mixing v1 and v2 packages or import styles will lead to errors.
fix
For new projects, use `pip install aws-cdk-lib` and update imports to `from aws_cdk import aws_sns` etc. If maintaining a v1 project, ensure all CDK packages are pinned to v1 versions and use `from aws_cdk import aws_sns`.
affects: All versions of `aws-cdk-aws-sns` (which are v1)
gotchaAWS CDK requires the AWS CLI to be installed and configured with credentials for synthesizing and deploying stacks. Your AWS account and region must also be 'bootstrapped' for CDK.
fix
Install AWS CLI (`pip install awscli` or system package manager). Configure it (`aws configure`). Run `cdk bootstrap aws://ACCOUNT_ID/REGION` in your target environment.
affects: All versions
gotchaChanging the logical ID (the `construct_id` in `super().__init__(scope, construct_id, ...)` or the second argument in `sns.Topic(self, 'MyTopic', ...)`) of a construct after initial deployment will cause CloudFormation to replace the resource, leading to potential data loss or downtime.
fix
Choose stable, descriptive logical IDs from the start. If a change is necessary, plan for resource replacement, backups, and potential downtime, or manually migrate resources outside of CDK.
affects: All versions
gotchaCDK applications can generate large CloudFormation templates, especially with many resources or complex patterns. This can hit CloudFormation template size limits (50KB or 200 parameters/resources).
fix
Break down large applications into smaller, interconnected CDK stacks (e.g., using cross-stack references) or consider using nested stacks for reusable components.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aws_cdk_lib'
You are trying to import AWS CDK v2 modules (`aws_cdk_lib`) but have AWS CDK v1 packages (like `aws-cdk-aws-sns`) installed, or vice-versa.
fix
Decide whether to use AWS CDK v1 or v2. If v2, uninstall v1 packages and install `aws-cdk-lib`. If v1, ensure all CDK related packages are v1 and imports match `from aws_cdk import ...`.
jsii.errors.JavaScriptError: Error: Stack 'MySnsStack' is not bootstrapped. Please run 'cdk bootstrap' in the account/region.
The AWS environment (account and region) where you are trying to deploy has not been prepared for AWS CDK deployments. CDK needs to provision a few resources (e.g., S3 bucket, IAM roles) to manage deployments.
fix
Run `cdk bootstrap aws://YOUR_ACCOUNT_ID/YOUR_REGION` from your terminal, replacing with your actual AWS account ID and desired region.
AttributeError: module 'aws_cdk' has no attribute 'aws_sns'
The `aws-cdk.aws-sns` package is either not installed, or there's a version mismatch between `aws-cdk.core` and `aws-cdk.aws-sns`, or you're attempting a v1 import with a v2 setup.
fix
Ensure both `aws-cdk.core` and `aws-cdk.aws-sns` are installed and their versions are compatible (ideally the same v1 version, e.g., `pip install aws-cdk.core==1.204.0 aws-cdk.aws-sns==1.204.0`). Verify your imports are `from aws_cdk import aws_sns`.
Upgrade
Version history
1.204.0latest on PyPI · released Jun 19, 2023
Audit
Dependencies
aws-cdk.corerequiredEssential for any AWS CDK v1 application; provides core classes like App, Stack, and Construct.
Agent activity
29 hits · last 30 days
node
24
OpenAI (training)
3
Resources
aws-cdk-aws-sns — pip install aws-cdk-aws-sns · libregistry