Invoking the Lambda function via AWS Console or AWS CLI to either create an order, get the object data, or delete the object from the S3 Bucket.
- Go to Lambda → Lambda Function → Test tab
- Update the Event JSON textarea field (see sample payload)
- Click on the Test button in the upper right corner
-
Use the following command and replace the placeholder
lambda_function_name
with the actual Lambda function nameaws lambda invoke \ --function-name lambda_function_name \ --payload '{"action": "put", "key": "sample-1.json", "quantity": 1, "order": { "referenceId": "SMPLORDR-1234567890", "item": [{ "id": "SMPLITM-12345", "name": "Sample Item", "price": 1234.50 }]} }' \ --cli-binary-format raw-in-base64-out \ response.json
-
Create a new object
{ "action": "put", "key": "sample-1.json", "quantity": 1, "order": { "referenceId": "SMPLORDR-1234567890", "item": [{ "id": "SMPLITM-12345", "name": "Sample Item", "price": 1234.50 }] } }
-
Retrieve object data
{ "action": "get", "key": "sample-1.json" }
-
Delete object
{ "action": "delete", "key": "sample-1.json" }
- Bucket restrictions and limitations
- How can I resolve the "Bucket name already exists" or "BucketAlreadyExists" error from Amazon S3?
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
-
Install all the dependencies, bootstrap your project, and synthesized CloudFormation template.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/lambda/lambda-s3$ make init # With "profile" parameter dev@dev:~:aws-cdk-samples/lambda/lambda-s3$ make init profile=[profile_name]
-
Deploy the project.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/lambda/lambda-s3$ make deploy # With "profile" parameter dev@dev:~:aws-cdk-samples/lambda/lambda-s3$ make deploy profile=[profile_name]