xxxxxxxxxx
Many people consider AWS Lambda to be a little confusing, but it is not.
It is just a simple four-step process that begins with uploading code to AWS Lambda.
The next step is to set up your code to trigger from other AWS services, HTTP endpoints, or mobile apps.
AWS Lambda will only run a code when it is triggered and will only use the computing resources needed to run it.
xxxxxxxxxx
fn = lambda_.Function(self, "MyFunction",
runtime=lambda_.Runtime.NODEJS_16_X,
handler="index.handler",
code=lambda_.Code.from_asset(path.join(__dirname, "lambda-handler"))
)
xxxxxxxxxx
It is an AWS serverless computing service offered by Amazon Web Services that runs the code in response to events and automatically manages the compute resource.
xxxxxxxxxx
exports.fn = (event, context, callback) => {
console.log(event);
const age = event.age;
callback(null, age * 2);
};
xxxxxxxxxx
create-function
--function-name <value>
[--runtime <value>]
--role <value>
[--handler <value>]
[--code <value>]
[--description <value>]
[--timeout <value>]
[--memory-size <value>]
[--publish | --no-publish]
[--vpc-config <value>]
[--package-type <value>]
[--dead-letter-config <value>]
[--environment <value>]
[--kms-key-arn <value>]
[--tracing-config <value>]
[--tags <value>]
[--layers <value>]
[--file-system-configs <value>]
[--image-config <value>]
[--code-signing-config-arn <value>]
[--architectures <value>]
[--zip-file <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
xxxxxxxxxx
One can use Lambda in the following ways:
• As an event-driven compute service, AWS Lambda runs code in response to events.
• These events can be the changes to data in an Amazon S3 bucket or AWS DynamoDB
• Lambda can run code in response to HTTP requests using Amazon API Gateway or API calls made using AWS SDKs.