Skip to content

Commit

Permalink
feat(cdk-ops): latest boto3 layer
Browse files Browse the repository at this point in the history
- Introduces a new CDK construct `LatestBoto3Layer` that provisions a
  Lambda layer containing the latest boto3.
  `lambda/latest-boto3/requirements.txt` lists the modules and versions
  to be packaged as a Lambda layer. The latest boto3 is necessary
  because the default boto3 on the Lambda runtime does not support
  Redshift Serverless.

issue codemonger-io#30
  • Loading branch information
kikuomax committed Oct 1, 2022
1 parent 344b6d3 commit 91dfd32
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cdk-ops/lambda/latest-boto3/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
boto3==1.24.75
botocore==1.27.75
2 changes: 2 additions & 0 deletions cdk-ops/lib/cdk-ops-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
CodemongerResourceNames,
} from './codemonger-resources';
import { ContentsPipeline } from './contents-pipeline';
import { LatestBoto3Layer } from './latest-boto3-layer';

type Props = StackProps & Readonly<{
// names of the main codemonger resources.
Expand All @@ -22,6 +23,7 @@ export class CdkOpsStack extends Stack {
'CodemongerResources',
props.codemongerResourceNames,
);
const latestBoto3 = new LatestBoto3Layer(this, 'LatestBoto3');
const pipeline = new ContentsPipeline(this, 'ContentsPipeline', {
codemongerResources,
});
Expand Down
28 changes: 28 additions & 0 deletions cdk-ops/lib/latest-boto3-layer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as path from 'path';

import { aws_lambda as lambda } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { PythonLayerVersion } from '@aws-cdk/aws-lambda-python-alpha';

/** CDK construct that provisions a Lambda layer containing the latest boto3. */
export class LatestBoto3Layer extends Construct {
/** Lambda layer containing the latest boto3. */
readonly layer: lambda.ILayerVersion;

constructor(scope: Construct, id: string) {
super(scope, id);

this.layer = new PythonLayerVersion(this, 'LambdaLayer', {
description: 'Lambda layer containing the latest boto3',
entry: path.join('lambda', 'latest-boto3'),
compatibleRuntimes: [
lambda.Runtime.PYTHON_3_8,
lambda.Runtime.PYTHON_3_9,
],
compatibleArchitectures: [
lambda.Architecture.ARM_64,
lambda.Architecture.X86_64,
],
});
}
}

0 comments on commit 91dfd32

Please sign in to comment.