Skip to main content

core-aws-cdk

This project contains common elements and constructs to create infrastructure in AWS using AWS CDK with Python.


PyPI Downloads Python Versions License Pipeline Status Docs Status Security

Features

  • Base Stacks: Pre-configured CDK stacks with tagging support

  • Lambda Functions: Simplified Lambda creation with automatic packaging

  • S3 Buckets: S3 bucket creation with security best practices

  • SQS Queues: Queue creation with dead-letter queue support

  • SNS Topics: Topic creation with subscription management

  • Network Stack: VPC and networking resource management

  • ZIP Asset Packaging: Automatic Lambda ZIP creation with dependencies

Quick Start

Setting Up Environment

  1. Install required libraries:

pip install --upgrade pip
pip install virtualenv
  1. Create Python virtual environment:

virtualenv --python=python3.12 .venv
  1. Activate the virtual environment:

source .venv/bin/activate

Install packages

pip install .
pip install -e ".[dev]"

Check tests and coverage

python manager.py run-tests
python manager.py run-tests --test-type integration
python manager.py run-coverage

# Having proper AWS credentials...
python manager.py run-tests --test-type functional --pattern "*.py"

Note: bare pytest/pytest -n auto correctly discovers and runs the tests_*.py unit suite. check_*.py functional tests are deliberately excluded from auto-discovery, since they deploy real AWS resources; pass them to pytest as explicit paths, which is also how to run them with parallelism manager.py doesn’t offer:

Run a specific functional test file (requires AWS credentials):

pytest tests/functional/check_lambda_creation.py

Run a specific test:

pytest tests/functional/check_lambda_creation.py::TestLambdaCreation::test_create_and_invoke_lambda_with_inline_code

Run a few functional test files with limited parallelism (recommended, to avoid AWS rate limits):

pytest tests/functional/*.py -n 2

IMPORTANT: Functional tests deploy real resources to AWS and may incur costs and require AWS credentials configured.

Prerequisites

  1. AWS credentials configured.

  2. CDK CLI installed npm install -g aws-cdk.

  3. Required AWS permissions: * Lambda (create, invoke, delete) * S3 (create bucket, put/get objects, delete) * SNS (create topic, publish) * SQS (create queue, send/receive messages) * CloudFormation (create/update/delete stacks) * IAM (create roles and policies)

Important Notes:

  • Tests automatically clean up resources after completion

  • Each test uses temporary directories and unique resource names

  • Tests include 10-minute timeouts for deployment and cleanup

  • All logs captured with DEBUG level for troubleshooting

Architecture Examples

Complete SNS → SQS → Lambda → S3 Integration

from aws_cdk import App, Environment, Duration, CfnOutput
from aws_cdk.aws_lambda import Code, Runtime
from aws_cdk.aws_lambda_event_sources import SqsEventSource
from aws_cdk.aws_sns_subscriptions import SqsSubscription
from core_aws_cdk.stacks.lambdas import BaseLambdaStack
from core_aws_cdk.stacks.s3 import BaseS3Stack
from core_aws_cdk.stacks.sns import BaseSnsStack
from core_aws_cdk.stacks.sqs import BaseSqsStack

class IntegratedStack(
    BaseSnsStack,
    BaseSqsStack,
    BaseLambdaStack,
    BaseS3Stack
):
    """ My Custom Stack """

app = App()

stack = IntegratedStack(
    app,
    "IntegratedStack",
    env=Environment(
        account="123456789",
        region="us-east-1"
    ))

# Create S3 bucket
bucket = stack.create_bucket(
    bucket_id="DataBucket",
    bucket_name=None  # Auto-generate
)

# Create SQS queue with DLQ
queue = stack.create_sqs_queue(
    queue_id="ProcessQueue",
    queue_name="process-queue",
    with_dlq=True,
    dlq_id="ProcessQueueDLQ",
    max_receive_count=3
)

# Create SNS topic
topic = stack.create_sns_topic(
    topic_id="EventTopic",
    topic_name="event-topic"
)

# Subscribe queue to topic
topic.add_subscription(SqsSubscription(queue))

# Create Lambda processor
lambda_function = stack.create_lambda(
    function_id="Processor",
    handler="handler.lambda_handler",
    code=Code.from_asset("./lambda"),
    runtime=Runtime.PYTHON_3_12,
    timeout=Duration.minutes(5),
    environment={"BUCKET_NAME": bucket.bucket_name}
)

# Configure SQS as Lambda trigger
lambda_function.add_event_source(SqsEventSource(queue))

# Grant permissions
bucket.grant_write(lambda_function)

# Export outputs
CfnOutput(stack, "TopicArn", value=topic.topic_arn)
CfnOutput(stack, "BucketName", value=bucket.bucket_name)

app.synth()

Issue: CDK version mismatch

Solution: Ensure CDK CLI version matches library version

npm install -g aws-cdk@latest
cdk --version

Issue: Node.js version warning

Solution: Ensure Node.js v20 or v22 is installed and accessible

node --version
which node

Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Write tests for new functionality

  4. Ensure all tests pass with full coverage: python manager.py run-coverage

  5. Run linters: ty check core_aws_cdk, ruff check ., mypy core_aws_cdk, pyright core_aws_cdk, pylint core_aws_cdk

  6. Run security checks: bandit -r core_aws_cdk, pip-audit

  7. Submit a pull request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For questions or support, please open an issue on GitLab or contact the maintainers.

Authors

Metadata

Release files for core-aws-cdk 3.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for core-aws-cdk 3.1.4
File Size Uploaded Provenance Actions
core_aws_cdk-3.1.4.tar.gz 38.1 kB With provenance Details for core_aws_cdk-3.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for core-aws-cdk 3.1.4
File Interpreter ABI Platform Actions
core_aws_cdk-3.1.4-py3-none-any.whl Python 3 none any Details for core_aws_cdk-3.1.4-py3-none-any.whl

Total release size: 78.6 kB

Release files / core_aws_cdk-3.1.4.tar.gz

Download URL core_aws_cdk-3.1.4.tar.gz
Size 38.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4cd7d6e051de28719ba3c3cde4c611241c95fa187c1210a7a59dc3b08343b84d
BLAKE2b-256 checksum
How to use checksums
8cb5c25199c44fc47eac9f0975ed8dee2f55261aec2418f13e9900dd28285dfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.15.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / core_aws_cdk-3.1.4-py3-none-any.whl

Download URL core_aws_cdk-3.1.4-py3-none-any.whl
Size 40.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbd20531fdc6908357960e49c74cddb9c299996752396d748b5976708bffd072
BLAKE2b-256 checksum
How to use checksums
9e5ad478a6b564935c32104b831fd45e49216beb830e2f652eb579df96c2782c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.15.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Nov 16, 2026.

Transparency log

Security for core-aws-cdk 3.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for core_aws_cdk-3.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page