AWS Solutions Constructs Core

2.101.0 · active · verified Fri Apr 17

The `aws-solutions-constructs-core` library provides base classes, helper functions, and common utilities for building and extending AWS Solutions Constructs patterns. It simplifies the creation of well-architected AWS infrastructure using the AWS Cloud Development Kit (CDK). Currently at version 2.101.0, it maintains a rapid release cadence, often updated weekly or bi-weekly to align with `aws-cdk-lib` releases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates using `aws-solutions-constructs-core.add_tags` to apply standardized tags to a simple AWS Lambda function within an AWS CDK stack. This highlights how core utilities can be directly leveraged alongside standard CDK resources.

import os
from aws_cdk import (
    App,
    Stack,
    aws_lambda as _lambda,
)
from constructs import Construct
from aws_solutions_constructs.aws_solutions_constructs_core import add_tags

class MyCoreUsageStack(Stack):
    def __init__(self, scope: Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        # Create a basic Lambda function
        my_function = _lambda.Function(
            self, "MyFunction",
            runtime=_lambda.Runtime.PYTHON_3_9,
            handler="index.handler",
            code=_lambda.Code.from_inline("def handler(event, context): return 'Hello from Lambda!'")
        )

        # Use a utility from aws_solutions_constructs_core to add tags to the Lambda
        # add_tags is often used implicitly by pattern constructs, but can be used directly.
        add_tags(my_function, {
            "Project": "MyCDKApp",
            "Environment": "Development"
        })

app = App()
MyCoreUsageStack(app, "MyCoreUsageStack", env={
    'account': os.environ.get('CDK_DEFAULT_ACCOUNT', ''),
    'region': os.environ.get('CDK_DEFAULT_REGION', 'us-east-1')
})
app.synth()

view raw JSON →