Function
Provides an Lambda Function
Examples
Create a Lambda Function
exports.createResources = () => [
{
type: "Role",
group: "IAM",
name: "lambda-role",
properties: ({}) => ({
Path: "/",
AssumeRolePolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Sid: "",
Effect: "Allow",
Principal: {
Service: "lambda.amazonaws.com",
},
Action: "sts:AssumeRole",
},
],
},
}),
dependencies: () => ({
policies: ["lambda-policy"],
}),
},
{
type: "Policy",
group: "IAM",
name: "lambda-policy",
properties: ({}) => ({
PolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Action: ["logs:*"],
Effect: "Allow",
Resource: "*",
},
{
Action: ["sqs:*"],
Effect: "Allow",
Resource: "*",
},
],
},
Path: "/",
Description: "Allow logs",
}),
},
{
type: "Function",
group: "Lambda",
properties: ({}) => ({
Configuration: {
FunctionName: "lambda-hello-world",
Handler: "helloworld.handler",
Runtime: "nodejs14.x",
},
}),
dependencies: () => ({
role: "lambda-role",
}),
},
];
Source Code Examples
- ApiGatewayV2 http-lambda
- hello world lambda
- lambda url
- lambda sqs
- AppSync graphql
- CloudWatch Subscription Filter
- EFS simple
- Firehose stream
- Kinesis stream
- serverless-patterns apigw-http-api-eventbridge
- serverless-patterns apigw-websocket-api-lambda
- serverless-patterns cdk-lambda-appsync
- serverless-patterns cdk-vpc-lambda-sfn
- serverless-patterns cognito-httpapi
- serverless-patterns lambda
- serverless-patterns lambda-aurora-serverless
- serverless-patterns lambda-cloudwatch
- serverless-patterns lambda-dynamodb
- serverless-patterns lambda-layer-terraform
- serverless-patterns lambda-s3
- serverless-patterns lambda-ssm-parameter
- serverless-patterns sfn-apigw
- serverless-patterns sns-lambda
- serverless-patterns sqs-lambda-terraform-python
- serverless-patterns step-functions-lambda-terraform
- serverless-patterns systems-manager-automation-to-lambda
- serverless-patterns ta-eventbridge-lambda-s3
- lambda triggered by a write to an S3 Bucket
Properties
Dependencies
Used By
- ApiGateway Integration
- ApplicationAutoScaling Target
- CloudWatchLogs Subscription Filter
- S3 Bucket
- StepFunctions StateMachine
List
The list of functions can be displayed and filtered with the type Function:
gc list -t Function
┌──────────────────────────────────────────────────────────────────┐
│ 2 Lambda::Function from aws │
├──────────────────────────────────────────────────────────────────┤
│ name: LambdaLayerXRayStackStack-BucketNotificationsHandl-1XcDZ1… │
│ managedByUs: Yes │
│ live: │
│ Configuration: │
│ Architectures: │
│ - "x86_64" │
│ CodeSha256: hzxBwXE8vF5htCF3abiYzTqjRnM2KRxbveRsojrrXhs= │
│ CodeSize: 1337 │
│ Description: AWS CloudFormation handler for "Custom::S3Buck… │
│ EphemeralStorage: │
│ Size: 512 │
│ FunctionArn: arn:aws:lambda:us-east-1:840541460064:function… │
│ FunctionName: LambdaLayerXRayStackStack-BucketNotifications… │
│ Handler: index.handler │
│ LastModified: 2022-04-17T18:32:29.881+0000 │
│ LastUpdateStatus: Successful │
│ MemorySize: 128 │
│ PackageType: Zip │
│ RevisionId: fee4d397-44a6-4dfe-b070-9b0c8204d012 │
│ Role: arn:aws:iam::840541460064:role/LambdaLayerXRayStackSt… │
│ Runtime: python3.7 │
│ State: Active │
│ Timeout: 300 │
│ TracingConfig: │
│ Mode: PassThrough │
│ Version: $LATEST │
│ Code: │
│ Location: https://prod-04-2014-tasks.s3.us-east-1.amazonaws… │
│ RepositoryType: S3 │
│ Tags: │
│ aws:cloudformation:stack-name: LambdaLayerXRayStackStack │
│ gc-project-name: xray-lambdalayers-cdk-python │
│ aws:cloudformation:stack-id: arn:aws:cloudformation:us-east… │
│ aws:cloudformation:logical-id: BucketNotificationsHandler05… │
│ gc-managed-by: grucloud │
│ gc-stage: dev │
│ gc-created-by-provider: aws │
│ Name: LambdaLayerXRayStackStack-BucketNotificationsHandl-1X… │
│ │
├──────────────────────────────────────────────────────────────────┤