### Minimal Fargate to S3 Construct Deployment (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-fargate-s3.adoc This Python example demonstrates the basic setup for the Fargate to S3 construct. Provide the ECR repository ARN for your image. ```python from aws_solutions_constructs.aws_fargate_s3 import FargateToS3, FargateToS3Props from aws_cdk import ( Stack ) from constructs import Construct FargateToS3(self, 'test_construct', public_api=True, ecr_repository_arn="arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo") ``` -------------------------------- ### Minimal ApiGatewayToSqs Pattern Deployment (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-apigateway-sqs.adoc This Python example demonstrates the basic deployment of the ApiGatewayToSqs pattern. Ensure you have the aws_solutions_constructs.aws_apigateway_sqs package installed and import the required classes. ```python from aws_solutions_constructs.aws_apigateway_sqs import ApiGatewayToSqs from aws_cdk import Stack from constructs import Construct ApiGatewayToSqs(self, 'ApiGatewayToSqsPattern') ``` -------------------------------- ### Minimal CloudFrontToOaiToS3 Deployment (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-cloudfront-oai-s3.adoc This Python example demonstrates the simplest way to deploy a CloudFront distribution with OAI for S3 content. It requires the aws-solutions-constructs library to be installed. ```python from aws_solutions_constructs.aws_cloudfront_oai_s3 import CloudFrontToOaiToS3 from aws_cdk import Stack from constructs import Construct CloudFrontToOaiToS3(self, 'test-cloudfront-oai-s3') ``` -------------------------------- ### Minimal Lambda to Transcribe Setup (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/@aws-solutions-constructs/aws-lambda-transcribe/README.md This Python example demonstrates the basic configuration for the LambdaToTranscribe construct. It assumes your Lambda handler code is located in a 'lambda' directory. ```python from aws_solutions_constructs.aws_lambda_transcribe import LambdaToTranscribe from aws_cdk import ( aws_lambda as _lambda, Stack ) from constructs import Construct LambdaToTranscribe(self, 'LambdaToTranscribePattern', lambda_function_props=_lambda.FunctionProps( code=_lambda.Code.from_asset('lambda'), runtime=_lambda.Runtime.PYTHON_3_11, handler='index.handler' ) ) ``` -------------------------------- ### Minimal Fargate to Secrets Manager Deployment (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-fargate-secretsmanager.adoc This Python example demonstrates the basic setup for deploying a Fargate service with Secrets Manager. Provide the ECR repository ARN for your image. ```python from aws_solutions_constructs.aws_fargate_secretsmanager import FargateToSecretsmanager, FargateToSecretsmanagerProps from aws_cdk import ( Stack ) from constructs import Construct FargateToSecretsmanager(self, 'test_construct', public_api=True, ecr_repository_arn="arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo") ``` -------------------------------- ### Minimal Lambda to Polly Deployment (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-lambda-polly.adoc This Python example demonstrates the basic setup for integrating AWS Lambda with Amazon Polly. It configures the Lambda function's runtime, handler, and code location. ```python from aws_solutions_constructs.aws_lambda_polly import LambdaToPolly from aws_cdk import ( aws_lambda as _lambda, Stack ) from constructs import Construct LambdaToPolly(self, 'LambdaToPollyPattern', lambda_function_props=_lambda.FunctionProps( code=_lambda.Code.from_asset('lambda'), runtime=_lambda.Runtime.PYTHON_3_14, handler='index.handler' ) ) ``` -------------------------------- ### Minimal Fargate to DynamoDB Construct Deployment Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/@aws-solutions-constructs/aws-fargate-dynamodb/README.adoc This example shows the basic setup for deploying a Fargate service with DynamoDB access. Ensure you provide a valid ECR repository ARN for your container image. ```typescript import { Construct } from 'constructs'; import { Stack, StackProps } from 'aws-cdk-lib'; import { FargateToDynamoDB, FargateToDynamoDBProps } from '@aws-solutions-constructs/aws-fargate-dynamodb'; const constructProps: FargateToDynamoDBProps = { publicApi: true, ecrRepositoryArn: "arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo", }; new FargateToDynamoDB(stack, 'test-construct', constructProps); ``` ```python from aws_solutions_constructs.aws_fargate_dynamodb import FargateToDynamoDB, FargateToDynamoDBProps from aws_cdk import ( Stack ) from constructs import Construct FargateToDynamoDB(self, 'test_construct', public_api=True, ecr_repository_arn="arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo") ``` ```java import software.constructs.Construct; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awsconstructs.services.fargatedynamodb.*; new FargateToDynamoDB(this, "test-construct", new FargateToDynamoDBProps.Builder() .publicApi(true) .ecrRepositoryArn("arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo") .build()); ``` -------------------------------- ### Deploy API Gateway with Lambda and Attach WAF WebACL Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-wafwebacl-apigateway.adoc This example demonstrates deploying an API Gateway with a Lambda function and then attaching a WAF WebACL to it. It utilizes the ApiGatewayToLambda construct for the API Gateway and Lambda setup. ```java import software.constructs.Construct; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awscdk.services.apigateway.*; import software.amazon.awscdk.services.lambda.*; import software.amazon.awscdk.services.lambda.Runtime; import software.amazon.awsconstructs.services.apigatewaylambda.*; import software.amazon.awsconstructs.services.wafwebaclapigateway.*; final ApiGatewayToLambda apiGatewayToLambda = new ApiGatewayToLambda(this, "ApiGatewayToLambdaPattern", new ApiGatewayToLambdaProps.Builder() .lambdaFunctionProps(new FunctionProps.Builder() .runtime(Runtime.NODEJS_22_X) .code(Code.fromAsset("lambda")) .handler("index.handler") .build()) .build()); // This construct can only be attached to a configured Application Load // Balancer. new WafwebaclToApiGateway(this, "test-wafwebacl-apigateway", new WafwebaclToApiGatewayProps.Builder() .existingApiGatewayInterface(apiGatewayToLambda.getApiGateway()) .build()); ``` -------------------------------- ### Example Lambda Function Implementations Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/@aws-solutions-constructs/aws-lambda-stepfunctions/README.adoc Provides links to example Lambda function implementations in Python and other languages that can be used with Step Functions. These examples are hosted on the aws-doc-sdk-examples GitHub repository. ```python https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/stepfunctions ``` -------------------------------- ### Start Docker Build Container Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/DEVELOPER_GUIDE.md This command downloads and starts the Docker image for building Solutions Constructs. It mounts the current directory into the container and sets it as the working directory, allowing for repeated builds. ```bash docker run -u root --rm --net=host -it -v $PWD:$PWD -w $PWD public.ecr.aws/jsii/superchain:1-bookworm-slim ``` -------------------------------- ### Minimal Python Example for IotToKinesisFirehoseToS3 Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-iot-kinesisfirehose-s3.adoc This Python example demonstrates the basic setup for the IotToKinesisFirehoseToS3 construct. It configures an IoT rule to forward data to Kinesis Firehose and S3. Ensure the aws-solutions-constructs library is installed. ```python from aws_solutions_constructs.aws_iot_kinesisfirehose_s3 import IotToKinesisFirehoseToS3Props, IotToKinesisFirehoseToS3 from aws_cdk import ( aws_iot as iot, Stack ) from constructs import Construct IotToKinesisFirehoseToS3(self, 'test_iot_firehose_s3', iot_topic_rule_props=iot.CfnTopicRuleProps( topic_rule_payload=iot.CfnTopicRule.TopicRulePayloadProperty( rule_disabled=False, description="Persistent storage of connected vehicle telematics data", sql="SELECT * FROM 'connectedcar/telemetry/#'", actions=[] ) )) ``` -------------------------------- ### Minimal KinesisStreamsToKinesisFirehoseToS3 Deployment (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-kinesisstreams-kinesisfirehose-s3.adoc This Python example demonstrates the basic setup for the Kinesis Data Stream to Kinesis Data Firehose to S3 pattern. It requires the aws-solutions-constructs library to be installed. ```python from aws_solutions_constructs.aws_kinesis_streams_kinesis_firehose_s3 import KinesisStreamsToKinesisFirehoseToS3 from aws_cdk import Stack from constructs import Construct KinesisStreamsToKinesisFirehoseToS3(self, 'test_stream_firehose_s3') ``` -------------------------------- ### Minimal Fargate to SQS Construct Deployment (Java) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-fargate-sqs.adoc Use this minimal example to deploy a Fargate service that writes to an SQS queue. Ensure you provide a valid ECR repository ARN. ```java import software.constructs.Construct; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awsconstructs.services.fargatesqs.*; new FargateToSqs(this, "test_construct", new FargateToSqsProps.Builder() .publicApi(true) .ecrRepositoryArn("arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo") .build()); ``` -------------------------------- ### Minimal API Gateway to Kinesis Streams Construct (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-apigateway-kinesisstreams.adoc This Python example demonstrates the basic setup for the API Gateway to Kinesis Streams construct. It requires the aws-solutions-constructs library to be installed. ```python from aws_solutions_constructs.aws_apigateway_kinesisstreams import ApiGatewayToKinesisStreams from aws_cdk import Stack from constructs import Construct ApiGatewayToKinesisStreams(self, 'test-apigw-kinesis') ``` -------------------------------- ### Minimal TypeScript Example for IotToKinesisFirehoseToS3 Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-iot-kinesisfirehose-s3.adoc Use this minimal example to set up an AWS IoT rule that sends data to Kinesis Data Firehose and then to S3. Ensure you have the necessary AWS CDK libraries installed. ```typescript import { Construct } from 'constructs'; import { Stack, StackProps } from 'aws-cdk-lib'; import { IotToKinesisFirehoseToS3Props, IotToKinesisFirehoseToS3 } from '@aws-solutions-constructs/aws-iot-kinesisfirehose-s3'; const constructProps: IotToKinesisFirehoseToS3Props = { iotTopicRuleProps: { topicRulePayload: { ruleDisabled: false, description: "Persistent storage of connected vehicle telematics data", sql: "SELECT * FROM 'connectedcar/telemetry/#'", actions: [] } } }; new IotToKinesisFirehoseToS3(this, 'test-iot-firehose-s3', constructProps); ``` -------------------------------- ### Align Versions and Set Up Environment Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/DEVELOPER_GUIDE.md Source this script to align package versions and set up necessary environment variables for partial builds. This must be run after `build-patterns.sh` has been executed at least once. ```bash source ./deployment/v2/allow-partial-builds.sh ``` -------------------------------- ### Minimal Fargate to SQS Construct Deployment (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-fargate-sqs.adoc Use this minimal example to deploy a Fargate service that writes to an SQS queue. Ensure you provide a valid ECR repository ARN. ```python from aws_solutions_constructs.aws_fargate_sqs import FargateToSqs, FargateToSqsProps from aws_cdk import ( Stack ) from constructs import Construct FargateToSqs(self, 'test_construct', public_api=True, ecr_repository_arn="arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo") ``` -------------------------------- ### Minimal LambdaToBedrockInferenceProfile in Python Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-lambda-bedrockinferenceprofile.adoc This Python example demonstrates the basic setup for the LambdaToBedrockInferenceProfile construct. It requires the aws-cdk and aws-solutions-constructs libraries. ```python from constructs import Construct from aws_cdk import ( aws_lambda as _lambda, Stack ) from aws_solutions_constructs import ( aws_lambda_bedrockinferenceprofile as lambda_bedrock ) lambda_bedrock.LambdaToBedrockinferenceprofile( self, 'bedrock-construct', bedrock_model_id="amazon.nova-lite-v1:0", lambda_function_props=_lambda.FunctionProps( runtime=_lambda.Runtime.NODEJS_22_X, code=_lambda.Code.from_asset('lambda'), handler='index.handler', ) ) ``` -------------------------------- ### Example Python Code for Kinesis Firehose Put Actions Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-lambda-kinesisfirehose.adoc This Python code demonstrates how to perform Put actions with Kinesis Firehose. It is provided as an example for implementing the Lambda function that interacts with Firehose. Ensure you have the AWS SDK for Python (Boto3) installed and configured. ```python import boto3 from botocore.exceptions import ClientError def put_record(firehose_client, delivery_stream_name, data): """Put a single record into the specified Kinesis Data Firehose delivery stream. :param firehose_client: A Boto3 Firehose client. :param delivery_stream_name: The name of the delivery stream. :param data: The data to send to the delivery stream. This is automatically encoded as UTF-8. :return: The response from the PutRecord API call, or None if an error occurred. """ try: response = firehose_client.put_record( DeliveryStreamName=delivery_stream_name, Record={'Data': data.encode('utf-8')} ) print(f"Successfully put record to {delivery_stream_name}") return response except ClientError as e: print(f"Error putting record to {delivery_stream_name}: {e}") return None def put_record_batch(firehose_client, delivery_stream_name, records): """Put multiple records into the specified Kinesis Data Firehose delivery stream. :param firehose_client: A Boto3 Firehose client. :param delivery_stream_name: The name of the delivery stream. :param records: A list of records to send to the delivery stream. Each record is a dictionary with a 'Data' key. The data is automatically encoded as UTF-8. :return: The response from the PutRecordBatch API call, or None if an error occurred. """ try: response = firehose_client.put_record_batch( DeliveryStreamName=delivery_stream_name, Records=[{'Data': r['Data'].encode('utf-8')} for r in records] ) print(f"Successfully put record batch to {delivery_stream_name}") return response except ClientError as e: print(f"Error putting record batch to {delivery_stream_name}: {e}") return None def main(): # Replace with your delivery stream name delivery_stream_name = 'my-delivery-stream' firehose_client = boto3.client('firehose') # Example of putting a single record data_to_send = "This is a single record." put_record(firehose_client, delivery_stream_name, data_to_send) # Example of putting a batch of records records_to_send = [ {'Data': 'This is the first record in the batch.'}, {'Data': 'This is the second record in the batch.'} ] put_record_batch(firehose_client, delivery_stream_name, records_to_send) if __name__ == '__main__': main() ``` -------------------------------- ### Minimal Deployable Pattern Definition in Java Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-iot-s3.adoc This Java example shows how to instantiate the IotToS3 construct with essential configurations. Ensure you have the necessary AWS CDK and construct dependencies. ```java import software.constructs.Construct; import java.util.List; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awscdk.services.iot.*; import software.amazon.awscdk.services.iot.CfnTopicRule.TopicRulePayloadProperty; import software.amazon.awsconstructs.services.iots3.*; new IotToS3(this, "test_iot_s3", new IotToS3Props.Builder() .iotTopicRuleProps(new CfnTopicRuleProps.Builder() .topicRulePayload(new TopicRulePayloadProperty.Builder() .ruleDisabled(false) .description("Testing the IotToS3 Pattern") .sql("SELECT * FROM 'solutions/constructs'") .actions(List.of()) .build()) .build()) .build()); ``` -------------------------------- ### AWS Lambda Kinesis Firehose Construct Example Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/@aws-solutions-constructs/aws-lambda-kinesisfirehose/README.md This example demonstrates how to use the AWS Lambda Kinesis Firehose Solutions Construct to create a Kinesis Data Firehose delivery stream that is triggered by an AWS Lambda function. Ensure you have the necessary AWS SDK and construct libraries installed. ```typescript import * as cdk from 'aws-cdk-lib'; import * as lambda from 'aws-cdk-lib/aws-lambda'; import * as firehose from '@aws-solutions-constructs/aws-lambda-kinesisfirehose'; export class LambdaKinesisFirehoseStack extends cdk.Stack { constructor(scope: cdk.App, id: string, props?: cdk.StackProps) { super(scope, id, props); new firehose.LambdaToKinesisFirehose(this, 'LambdaKinesisFirehosePattern', { lambdaFunctionProps: { runtime: lambda.Runtime.NODEJS_18_X, handler: 'index.handler', memorySize: 128, timeout: cdk.Duration.minutes(5), description: 'Lambda function to process and send data to Kinesis Firehose' } }); } } ``` -------------------------------- ### VPC Configuration with ec2.Vpc.fromLookup() Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-lambda-dynamodb.adoc Demonstrates how to use `ec2.Vpc.fromLookup()` to provide an existing VPC to the construct. It also explains the `vpcProps` and `deployVpc` properties for configuring or creating a new VPC. ```APIDOC ## VPC Configuration ### Description This section details how to configure the VPC for the AWS Lambda DynamoDB Solutions Construct. You can either provide an existing VPC using `ec2.Vpc.fromLookup()` or allow the construct to deploy a new VPC based on provided properties. ### Method `ec2.Vpc.fromLookup(scope: Construct, id: string, options: VpcLookupOptions)` ### Endpoint N/A (This is a CDK method, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters for Construct Constructor #### `vpcProps` (Optional) - **Type**: `ec2.VpcProps` - **Description**: Optional user-provided properties to override the default properties for the new VPC. Properties like `enableDnsHostnames`, `enableDnsSupport`, `natGateways`, and `subnetConfiguration` are set by the pattern, so any values for those properties supplied here will be overridden. If `deployVpc` is not `true`, then this property will be ignored. #### `deployVpc` (Optional) - **Type**: `boolean` - **Description**: Whether to create a new VPC based on `vpcProps` into which to deploy this pattern. Setting this to `true` will deploy the minimal, most private VPC to run the pattern. ``` -------------------------------- ### Minimal LambdaToBedrockInferenceProfile in TypeScript Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-lambda-bedrockinferenceprofile.adoc Use this minimal example to deploy a Lambda function with access to a Bedrock inference profile. Ensure you have the necessary AWS CDK libraries installed. ```typescript import { Construct } from 'constructs'; import { Stack, StackProps } from 'aws-cdk-lib'; import { LambdaToBedrockInferenceProfile } from "@aws-solutions-constructs/aws-lambda-bedrockinferenceprofile"; import * as lambda from 'aws-cdk-lib/aws-lambda'; new LambdaToBedrockInferenceProfile(this, 'LambdaToBedrockPattern', { lambdaFunctionProps: { runtime: lambda.Runtime.NODEJS_22_X, handler: 'index.handler', code: lambda.Code.fromAsset(`lambda`) }, model: "amazon.nova-lite-v1:0" }); ``` -------------------------------- ### Deploy Static Website with AWS CDK Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/source/use_cases/aws-s3-static-website/README.md Follow these commands to set up and deploy the static website use case using the AWS CDK. ```bash # Set the proper version numbers in the package.json file ../../../deployment/v2/align-version.sh # Install dependencies npm install # Build the use case npm run build # Deploy the use case cdk deploy ``` -------------------------------- ### Minimal S3 to Step Functions Deployment (Java) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-s3-stepfunctions.adoc A minimal Java example for deploying an S3 bucket connected to a Step Functions state machine. Verify that all necessary AWS CDK and construct libraries are imported. ```java import software.constructs.Construct; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awscdk.services.stepfunctions.*; import software.amazon.awsc constructs.services.s3stepfunctions.*; final Pass startState = new Pass(this, "StartState"); new S3ToStepfunctions(this, "test_s3_stepfunctions_stack", new S3ToStepfunctionsProps.Builder() .stateMachineProps(new StateMachineProps.Builder() .definition(startState) .build()) .build()); ``` -------------------------------- ### Minimal S3 to SNS Construct Deployment (Java) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-s3-sns.adoc Use this minimal example to quickly deploy an S3 bucket that sends event notifications to an SNS topic. No additional configuration is provided. ```java import software.constructs.Construct; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awsconstructs.services.s3sns.*; new S3ToSns(this, "S3ToSNSPattern", new S3ToSnsProps.Builder() .build()); ``` -------------------------------- ### Minimal S3 to Lambda Construct (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-s3-lambda.adoc This Python example demonstrates the basic setup for an S3 bucket triggering a Lambda function. The Lambda function code should be located in a 'lambda' directory. ```python from aws_solutions_constructs.aws_s3_lambda import S3ToLambda from aws_cdk import ( aws_lambda as _lambda, Stack ) from constructs import Construct S3ToLambda(self, 'test_s3_lambda', lambda_function_props=_lambda.FunctionProps( code=_lambda.Code.from_asset('lambda'), runtime=_lambda.Runtime.PYTHON_3_14, handler='index.handler' ) ) ``` -------------------------------- ### Minimal S3 to SNS Construct Deployment (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-s3-sns.adoc Use this minimal example to quickly deploy an S3 bucket that sends event notifications to an SNS topic. No additional configuration is provided. ```python from aws_solutions_constructs.aws_s3_sns import S3ToSns from aws_cdk import Stack from constructs import Construct S3ToSns(self, 'S3ToSNSPattern') ``` -------------------------------- ### Minimal SQS to Lambda Pattern (Java) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/@aws-solutions-constructs/aws-sqs-lambda/README.adoc A Java example for setting up an SQS queue to trigger a Lambda function. This requires a 'lambda' directory with your handler code. ```java import software.constructs.Construct; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awscdk.services.lambda.*; import software.amazon.awscdk.services.lambda.Runtime; import software.amazon.awsconstructs.services.sqslambda.*; new SqsToLambda(this, "SnsToSqsPattern", new SqsToLambdaProps.Builder() .lambdaFunctionProps(new FunctionProps.Builder() .runtime(Runtime.NODEJS_22_X) .code(Code.fromAsset("lambda")) .handler("index.handler") .build()) .build()); ``` -------------------------------- ### Create Fargate-to-Step Functions construct in Java Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/@aws-solutions-constructs/aws-fargate-stepfunctions/README.adoc Minimal example showing how to instantiate FargateToStepfunctions with a public API, ECR repository, and state machine definition. Uses builder pattern for configuration. ```java import software.constructs.Construct; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awsconstructs.services.fargatestepfunctions.*; import software.amazon.awscdk.services.stepfunctions.*; start_state = stepfunctions.Pass(self, 'start_state') new FargateToStepfunctions(this, "test-construct", new FargateToStepfunctionsProps.Builder() .publicApi(true) .ecrRepositoryArn("arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo") .stateMachineProps(new StateMachineProps.Builder() .definition(startState) .build() .build()); ``` -------------------------------- ### Minimal Lambda to SNS Construct Deployment (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-lambda-sns.adoc This Python example demonstrates the basic setup for deploying an AWS Lambda function integrated with an Amazon SNS topic. It requires the aws-solutions-constructs library. ```python from aws_solutions_constructs.aws_lambda_sns import LambdaToSns from aws_cdk import ( aws_lambda as _lambda, Stack ) from constructs import Construct LambdaToSns( self, 'test-lambda-sns-stack', lambda_function_props=_lambda.FunctionProps( code=_lambda.Code.from_asset('lambda'), runtime=_lambda.Runtime.PYTHON_3_14, handler='index.handler' ) ) ``` -------------------------------- ### Initialize AWS CDK Project (Python) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/walkthrough-part1.adoc Create a new directory and initialize an AWS CDK application with Python as the language. ```bash mkdir hello-constructs cd hello-constructs cdk init --language python ``` -------------------------------- ### Minimal API Gateway to Kinesis Streams Construct (TypeScript) Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-apigateway-kinesisstreams.adoc Use this minimal example to quickly deploy an API Gateway connected to Kinesis Streams. Ensure you have the necessary AWS CDK libraries installed. ```typescript import { Construct } from 'constructs'; import { Stack, StackProps } from 'aws-cdk-lib'; import { ApiGatewayToKinesisStreams, ApiGatewayToKinesisStreamsProps } from '@aws-solutions-constructs/aws-apigateway-kinesisstreams'; new ApiGatewayToKinesisStreams(this, 'test-apigw-kinesis', {}); ``` -------------------------------- ### Minimal SQS to Pipes to Step Functions Construct Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-sqs-pipes-stepfunctions.adoc This is a minimal example of how to deploy the SQS to Pipes to Step Functions construct. It requires setting the state machine definition body. ```typescript import { Construct } from 'constructs'; import { Stack, StackProps } from 'aws-cdk-lib'; import * as sfn from 'aws-cdk-lib/aws-stepfunctions'; import { SqsToPipesToStepfunctions, SqsToPipesToStepfunctionsProps } from "@aws-solutions-constructs/aws-sqs-pipes-stepfunctions"; const startState = new sfn.Pass(this, 'StartState'); new SqsToPipesToStepfunctions(this, 'SqsToPipesToStepfunctionsPattern', { stateMachineProps: { definitionBody: sfn.DefinitionBody.fromChainable(sfn.Chain.start(new sfn.Pass(this, 'Pass'))), } }); ``` ```python from constructs import Construct from aws_cdk import ( aws_stepfunctions as _sfn, Stack ) from aws_solutions_constructs import ( aws_sqs_pipes_stepfunctions as sqs_pipes_stepfunctions ) sqs_pipes_stepfunctions.SqsToPipesToStepfunctions( self, 'SqsToPipesToStepfunctions', state_machine_props=_sfn.StateMachineProps( definition_body=_sfn.DefinitionBody.from_chainable(_sfn.Chain.start(_sfn.Pass(self, "pass"))) ) ) ``` ```java package com.myorg; import software.constructs.Construct; import software.amazon.awscdk.Stack; import software.amazon.awscdk.StackProps; import software.amazon.awscdk.services.stepfunctions.*; import software.amazon.awsconstructs.services.sqspipesstepfunctions.SqsToPipesToStepfunctions; import software.amazon.awsconstructs.services.sqspipesstepfunctions.SqsToPipesToStepfunctionsProps; new SqsToPipesToStepfunctions(this, "SqsToLambdaToStepfunctionsPattern", SqsToPipesToStepfunctionsProps.builder() .stateMachineProps(StateMachineProps.builder() .definitionBody(DefinitionBody.fromChainable(Chain.start(new Pass(scope, "Pass")))) .build()) .build()); ``` -------------------------------- ### Minimal EventBridge to Kinesis Streams Construct in Python Source: https://github.com/awslabs/aws-solutions-constructs/blob/main/documentation/aws-eventbridge-kinesisstreams.adoc This Python example demonstrates the basic setup for an EventBridge rule targeting a Kinesis Data Stream at 5-minute intervals. It requires the aws-solutions-constructs and aws-cdk libraries. ```python from aws_solutions_constructs.aws_eventbridge_kinesis_streams import EventbridgeToKinesisStreams, EventbridgeToKinesisStreamsProps from aws_cdk import ( aws_events as events, Duration, Stack ) from constructs import Construct EventbridgeToKinesisStreams(self, 'test-eventbridge-kinesis-streams', event_rule_props=events.RuleProps( schedule=events.Schedule.rate(Duration.minutes(5)), )) ```