Skip to content

Latest commit

 

History

History

README.md

S3 Object Lambda


Stability: Stable

This is a stable example. It should successfully build out of the box

This example is built on Construct Libraries marked "Stable" and does not have any infrastructure prerequisites to build.


Overview

CDK example to create a S3 Object Lambda that uses Python. The example demonstrates setting up a S3 Access Point, Object Lambda Access Point and an Object Lambda to process the GET object requests using CDK.

Once deployed, any uploaded object in the bucket created will be available through the Object Access Point. When trying to access an object, you will see an object metadata output generated by the lambda similar to the following:

{
  "metadata": {
    "length": 1048576,
    "md5": "b6d81b360a5672d80c27430f39153e2c",
    "sha1": "3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3",
    "sha256": "30e14955ebf1352266dc2ff8067e68104607e750abb9d3b36582b8af909fcb58"
  }
}

Build and Deploy

The cdk.json file tells the CDK Toolkit how to execute your app.

Python setup

This project is set up like a standard Python project. The initialization process also creates a virtualenv within this project, stored under the .env directory. To create the virtualenv it assumes that there is a python3 (or python for Windows) executable in your path with access to the venv package. If for any reason the automatic creation of the virtualenv fails, you can create the virtualenv manually.

To manually create a virtualenv on MacOS and Linux:

$ python3 -m venv .env

After the init process completes and the virtualenv is created, you can use the following step to activate your virtualenv.

$ source .env/bin/activate

If you are a Windows platform, you would activate the virtualenv like this:

% .env\Scripts\activate.bat

Once the virtualenv is activated, you can install the required dependencies.

$ pip install -r requirements.txt

At this point you can now synthesize the CloudFormation template for this code.

$ cdk synth

CDK Deploy

With specific profile,

$ cdk deploy --profile test

Using the default profile

$ cdk deploy