Author: Andres Solorzano.
Level: Basic.
Technologies: Java, Apache Maven, DynamoDB, Lambda Functions, JSON API, and Log4J.
Summary: Lambda function that return electronic devices in a Smart City platform.
Target Product: Lambda Function with Java 8.
Lambda function that return electronic devices in a Smart City platform.
- AWS CLI already configured with at least PowerUser permission
- [Java SE Development Kit 11 installed]
- Maven
- SAM CLI
We use maven
to install our dependencies and package our application into a JAR file:
mvn clean package
Firstly, we need a S3 bucket
where we can upload our Lambda functions packaged as ZIP before we
deploy anything - If you don't have a S3 bucket to store code artifacts then this is a good time to
create one...
Next, run the following command to package our Lambda function to S3:
sam package --template-file template.yaml --output-template-file packaged.yaml --s3-bucket <BUCKET_NAME>
Next, the following command will create a CloudFormation Stack and deploy your SAM resources.
sam deploy --template-file packaged.yaml --stack-name devices-sector-function-stack --capabilities CAPABILITY_IAM
See Serverless Application Model (SAM) HOWTO Guide for more details in how to get started.
After deployment is complete you can run the following command to retrieve the API Gateway EndPoint URL:
aws cloudformation describe-stacks --stack-name sam-devices-function --query 'Stacks[].Outputs'