@aws-cdk_aws-lambda-go-alpha.GoFunctionProps

interface GoFunctionProps ๐Ÿ”น

LanguageType name
.NETAmazon.CDK.AWS.Lambda.Go.Alpha.GoFunctionProps
Gogithub.com/aws/aws-cdk-go/awscdklambdagoalpha/v2#GoFunctionProps
Javasoftware.amazon.awscdk.services.lambda.go.alpha.GoFunctionProps
Pythonaws_cdk.aws_lambda_go_alpha.GoFunctionProps
TypeScript (source)@aws-cdk/aws-lambda-go-alpha ยป GoFunctionProps

Properties for a GolangFunction.

Example

new go.GoFunction(this, 'handler', {
  entry: 'app/cmd/api',
  bundling: {
    dockerImage: DockerImage.fromBuild('/path/to/Dockerfile'),
  },
});

Properties

NameTypeDescription
entry๐Ÿ”นstringThe path to the folder or file that contains the main application entry point files for the project.
adotInstrumentation?๐Ÿ”นAdotInstrumentationConfigSpecify the configuration of AWS Distro for OpenTelemetry (ADOT) instrumentation.
allowAllOutbound?๐Ÿ”นbooleanWhether to allow the Lambda to send all network traffic.
allowPublicSubnet?๐Ÿ”นbooleanLambda Functions in a public subnet can NOT access the internet.
architecture?๐Ÿ”นArchitectureThe system architectures compatible with this lambda function.
bundling?๐Ÿ”นBundlingOptionsBundling options.
codeSigningConfig?๐Ÿ”นICodeSigningConfigCode signing config associated with this function.
currentVersionOptions?๐Ÿ”นVersionOptionsOptions for the lambda.Version resource automatically created by the fn.currentVersion method.
deadLetterQueue?๐Ÿ”นIQueueThe SQS queue to use if DLQ is enabled.
deadLetterQueueEnabled?๐Ÿ”นbooleanEnabled DLQ.
deadLetterTopic?๐Ÿ”นITopicThe SNS topic to use as a DLQ.
description?๐Ÿ”นstringA description of the function.
environment?๐Ÿ”น{ [string]: string }Key-value pairs that Lambda caches and makes available for your Lambda functions.
environmentEncryption?๐Ÿ”นIKeyThe AWS KMS key that's used to encrypt your function's environment variables.
ephemeralStorageSize?๐Ÿ”นSizeThe size of the functionโ€™s /tmp directory in MiB.
events?๐Ÿ”นIEventSource[]Event sources for this function.
filesystem?๐Ÿ”นFileSystemThe filesystem configuration for the lambda function.
functionName?๐Ÿ”นstringA name for the function.
initialPolicy?๐Ÿ”นPolicyStatement[]Initial policy statements to add to the created Lambda Role.
insightsVersion?๐Ÿ”นLambdaInsightsVersionSpecify the version of CloudWatch Lambda insights to use for monitoring.
layers?๐Ÿ”นILayerVersion[]A list of layers to add to the function's execution environment.
logRetention?๐Ÿ”นRetentionDaysThe number of days log events are kept in CloudWatch Logs.
logRetentionRetryOptions?๐Ÿ”นLogRetentionRetryOptionsWhen log retention is specified, a custom resource attempts to create the CloudWatch log group.
logRetentionRole?๐Ÿ”นIRoleThe IAM role for the Lambda function associated with the custom resource that sets the retention policy.
maxEventAge?๐Ÿ”นDurationThe maximum age of a request that Lambda sends to a function for processing.
memorySize?๐Ÿ”นnumberThe amount of memory, in MB, that is allocated to your Lambda function.
moduleDir?๐Ÿ”นstringDirectory containing your go.mod file.
onFailure?๐Ÿ”นIDestinationThe destination for failed invocations.
onSuccess?๐Ÿ”นIDestinationThe destination for successful invocations.
paramsAndSecrets?๐Ÿ”นParamsAndSecretsLayerVersionSpecify the configuration of Parameters and Secrets Extension.
profiling?๐Ÿ”นbooleanEnable profiling.
profilingGroup?๐Ÿ”นIProfilingGroupProfiling Group.
reservedConcurrentExecutions?๐Ÿ”นnumberThe maximum of concurrent executions you want to reserve for the function.
retryAttempts?๐Ÿ”นnumberThe maximum number of times to retry when the function returns an error.
role?๐Ÿ”นIRoleLambda execution role.
runtime?๐Ÿ”นRuntimeThe runtime environment.
runtimeManagementMode?๐Ÿ”นRuntimeManagementModeSets the runtime management configuration for a function's version.
securityGroups?๐Ÿ”นISecurityGroup[]The list of security groups to associate with the Lambda's network interfaces.
timeout?๐Ÿ”นDurationThe function execution time (in seconds) after which Lambda terminates the function.
tracing?๐Ÿ”นTracingEnable AWS X-Ray Tracing for Lambda Function.
vpc?๐Ÿ”นIVpcVPC network to place Lambda network interfaces.
vpcSubnets?๐Ÿ”นSubnetSelectionWhere to place the network interfaces within the VPC.

entry๐Ÿ”น

Type: string

The path to the folder or file that contains the main application entry point files for the project.

This accepts either a path to a directory or file.

If a directory path is provided then it will assume there is a Go entry file (i.e. main.go) and will construct the build command using the directory path.

For example, if you provide the entry as:

entry: 'my-lambda-app/cmd/api'

Then the go build command would be:

`go build ./cmd/api`

If a path to a file is provided then it will use the filepath in the build command.

For example, if you provide the entry as:

entry: 'my-lambda-app/cmd/api/main.go'

Then the go build command would be:

`go build ./cmd/api/main.go`

adotInstrumentation?๐Ÿ”น

Type: AdotInstrumentationConfig (optional, default: No ADOT instrumentation)

Specify the configuration of AWS Distro for OpenTelemetry (ADOT) instrumentation.

See also: https://aws-otel.github.io/docs/getting-started/lambda


allowAllOutbound?๐Ÿ”น

Type: boolean (optional, default: true)

Whether to allow the Lambda to send all network traffic.

If set to false, you must individually add traffic rules to allow the Lambda to connect to network targets.


allowPublicSubnet?๐Ÿ”น

Type: boolean (optional, default: false)

Lambda Functions in a public subnet can NOT access the internet.

Use this property to acknowledge this limitation and still place the function in a public subnet.

See also: https://stackoverflow.com/questions/52992085/why-cant-an-aws-lambda-function-inside-a-public-subnet-in-a-vpc-connect-to-the/52994841#52994841


architecture?๐Ÿ”น

Type: Architecture (optional, default: Architecture.X86_64)

The system architectures compatible with this lambda function.


bundling?๐Ÿ”น

Type: BundlingOptions (optional, default: use default bundling options)

Bundling options.


codeSigningConfig?๐Ÿ”น

Type: ICodeSigningConfig (optional, default: Not Sign the Code)

Code signing config associated with this function.


currentVersionOptions?๐Ÿ”น

Type: VersionOptions (optional, default: default options as described in VersionOptions)

Options for the lambda.Version resource automatically created by the fn.currentVersion method.


deadLetterQueue?๐Ÿ”น

Type: IQueue (optional, default: SQS queue with 14 day retention period if deadLetterQueueEnabled is true)

The SQS queue to use if DLQ is enabled.

If SNS topic is desired, specify deadLetterTopic property instead.


deadLetterQueueEnabled?๐Ÿ”น

Type: boolean (optional, default: false unless deadLetterQueue is set, which implies DLQ is enabled.)

Enabled DLQ.

If deadLetterQueue is undefined, an SQS queue with default options will be defined for your Function.


deadLetterTopic?๐Ÿ”น

Type: ITopic (optional, default: no SNS topic)

The SNS topic to use as a DLQ.

Note that if deadLetterQueueEnabled is set to true, an SQS queue will be created rather than an SNS topic. Using an SNS topic as a DLQ requires this property to be set explicitly.


description?๐Ÿ”น

Type: string (optional, default: No description.)

A description of the function.


environment?๐Ÿ”น

Type: { [string]: string } (optional, default: No environment variables.)

Key-value pairs that Lambda caches and makes available for your Lambda functions.

Use environment variables to apply configuration changes, such as test and production environment configurations, without changing your Lambda function source code.


environmentEncryption?๐Ÿ”น

Type: IKey (optional, default: AWS Lambda creates and uses an AWS managed customer master key (CMK).)

The AWS KMS key that's used to encrypt your function's environment variables.


ephemeralStorageSize?๐Ÿ”น

Type: Size (optional, default: 512 MiB)

The size of the functionโ€™s /tmp directory in MiB.


events?๐Ÿ”น

Type: IEventSource[] (optional, default: No event sources.)

Event sources for this function.

You can also add event sources using addEventSource.


filesystem?๐Ÿ”น

Type: FileSystem (optional, default: will not mount any filesystem)

The filesystem configuration for the lambda function.


functionName?๐Ÿ”น

Type: string (optional, default: AWS CloudFormation generates a unique physical ID and uses that ID for the function's name. For more information, see Name Type.)

A name for the function.


initialPolicy?๐Ÿ”น

Type: PolicyStatement[] (optional, default: No policy statements are added to the created Lambda role.)

Initial policy statements to add to the created Lambda Role.

You can call addToRolePolicy to the created lambda to add statements post creation.


insightsVersion?๐Ÿ”น

Type: LambdaInsightsVersion (optional, default: No Lambda Insights)

Specify the version of CloudWatch Lambda insights to use for monitoring.

See also: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-Getting-Started-docker.html


layers?๐Ÿ”น

Type: ILayerVersion[] (optional, default: No layers.)

A list of layers to add to the function's execution environment.

You can configure your Lambda function to pull in additional code during initialization in the form of layers. Layers are packages of libraries or other dependencies that can be used by multiple functions.


logRetention?๐Ÿ”น

Type: RetentionDays (optional, default: logs.RetentionDays.INFINITE)

The number of days log events are kept in CloudWatch Logs.

When updating this property, unsetting it doesn't remove the log retention policy. To remove the retention policy, set the value to INFINITE.


logRetentionRetryOptions?๐Ÿ”น

Type: LogRetentionRetryOptions (optional, default: Default AWS SDK retry options.)

When log retention is specified, a custom resource attempts to create the CloudWatch log group.

These options control the retry policy when interacting with CloudWatch APIs.


logRetentionRole?๐Ÿ”น

Type: IRole (optional, default: A new role is created.)

The IAM role for the Lambda function associated with the custom resource that sets the retention policy.


maxEventAge?๐Ÿ”น

Type: Duration (optional, default: Duration.hours(6))

The maximum age of a request that Lambda sends to a function for processing.

Minimum: 60 seconds Maximum: 6 hours


memorySize?๐Ÿ”น

Type: number (optional, default: 128)

The amount of memory, in MB, that is allocated to your Lambda function.

Lambda uses this value to proportionally allocate the amount of CPU power. For more information, see Resource Model in the AWS Lambda Developer Guide.


moduleDir?๐Ÿ”น

Type: string (optional, default: the path is found by walking up parent directories searching for a go.mod file from the location of entry)

Directory containing your go.mod file.

This will accept either a directory path containing a go.mod file or a filepath to your go.mod file (i.e. path/to/go.mod).

This will be used as the source of the volume mounted in the Docker container and will be the directory where it will run go build from.


onFailure?๐Ÿ”น

Type: IDestination (optional, default: no destination)

The destination for failed invocations.


onSuccess?๐Ÿ”น

Type: IDestination (optional, default: no destination)

The destination for successful invocations.


paramsAndSecrets?๐Ÿ”น

Type: ParamsAndSecretsLayerVersion (optional, default: No Parameters and Secrets Extension)

Specify the configuration of Parameters and Secrets Extension.

See also: https://docs.aws.amazon.com/systems-manager/latest/userguide/ps-integration-lambda-extensions.html


profiling?๐Ÿ”น

Type: boolean (optional, default: No profiling.)

Enable profiling.

See also: https://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html


profilingGroup?๐Ÿ”น

Type: IProfilingGroup (optional, default: A new profiling group will be created if profiling is set.)

Profiling Group.

See also: https://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html


reservedConcurrentExecutions?๐Ÿ”น

Type: number (optional, default: No specific limit - account limit.)

The maximum of concurrent executions you want to reserve for the function.

See also: https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html


retryAttempts?๐Ÿ”น

Type: number (optional, default: 2)

The maximum number of times to retry when the function returns an error.

Minimum: 0 Maximum: 2


role?๐Ÿ”น

Type: IRole (optional, default: A unique role will be generated for this lambda function. Both supplied and generated roles can always be changed by calling addToRolePolicy.)

Lambda execution role.

This is the role that will be assumed by the function upon execution. It controls the permissions that the function will have. The Role must be assumable by the 'lambda.amazonaws.com' service principal.

The default Role automatically has permissions granted for Lambda execution. If you provide a Role, you must add the relevant AWS managed policies yourself.

The relevant managed policies are "service-role/AWSLambdaBasicExecutionRole" and "service-role/AWSLambdaVPCAccessExecutionRole".


runtime?๐Ÿ”น

Type: Runtime (optional, default: lambda.Runtime.PROVIDED_AL2)

The runtime environment.

Only runtimes of the Golang family and provided family are supported.


runtimeManagementMode?๐Ÿ”น

Type: RuntimeManagementMode (optional, default: Auto)

Sets the runtime management configuration for a function's version.


securityGroups?๐Ÿ”น

Type: ISecurityGroup[] (optional, default: If the function is placed within a VPC and a security group is not specified, either by this or securityGroup prop, a dedicated security group will be created for this function.)

The list of security groups to associate with the Lambda's network interfaces.

Only used if 'vpc' is supplied.


timeout?๐Ÿ”น

Type: Duration (optional, default: Duration.seconds(3))

The function execution time (in seconds) after which Lambda terminates the function.

Because the execution time affects cost, set this value based on the function's expected execution time.


tracing?๐Ÿ”น

Type: Tracing (optional, default: Tracing.Disabled)

Enable AWS X-Ray Tracing for Lambda Function.


vpc?๐Ÿ”น

Type: IVpc (optional, default: Function is not placed within a VPC.)

VPC network to place Lambda network interfaces.

Specify this if the Lambda function needs to access resources in a VPC. This is required when vpcSubnets is specified.


vpcSubnets?๐Ÿ”น

Type: SubnetSelection (optional, default: the Vpc default strategy if not specified)

Where to place the network interfaces within the VPC.

This requires vpc to be specified in order for interfaces to actually be placed in the subnets. If vpc is not specify, this will raise an error.

Note: Internet access for Lambda Functions requires a NAT Gateway, so picking public subnets is not allowed (unless allowPublicSubnet is set to true).