All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awscdk.services.lambda.go.GoFunction Maven / Gradle / Ivy

There is a newer version: 1.204.0
Show newest version
package software.amazon.awscdk.services.lambda.go;

/**
 * (experimental) A Golang Lambda function.
 * 

* Example: *

*

 * GoFunction.Builder.create(this, "handler")
 *         .entry("app/cmd/api")
 *         .bundling(BundlingOptions.builder()
 *                 .goBuildFlags(List.of("-ldflags \"-s -w\""))
 *                 .build())
 *         .build();
 * 
*/ @javax.annotation.Generated(value = "jsii-pacmak/1.54.0 (build b1b977a)", date = "2022-02-24T23:24:24.396Z") @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.lambda.go.$Module.class, fqn = "@aws-cdk/aws-lambda-go.GoFunction") public class GoFunction extends software.amazon.awscdk.services.lambda.Function { protected GoFunction(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); } protected GoFunction(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { super(initializationMode); } /** * @param scope This parameter is required. * @param id This parameter is required. * @param props This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public GoFunction(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.core.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.lambda.go.GoFunctionProps props) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(props, "props is required") }); } /** * (experimental) A fluent builder for {@link software.amazon.awscdk.services.lambda.go.GoFunction}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static final class Builder implements software.amazon.jsii.Builder { /** * @return a new instance of {@link Builder}. * @param scope This parameter is required. * @param id This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static Builder create(final software.amazon.awscdk.core.Construct scope, final java.lang.String id) { return new Builder(scope, id); } private final software.amazon.awscdk.core.Construct scope; private final java.lang.String id; private final software.amazon.awscdk.services.lambda.go.GoFunctionProps.Builder props; private Builder(final software.amazon.awscdk.core.Construct scope, final java.lang.String id) { this.scope = scope; this.id = id; this.props = new software.amazon.awscdk.services.lambda.go.GoFunctionProps.Builder(); } /** * The maximum age of a request that Lambda sends to a function for processing. *

* Minimum: 60 seconds * Maximum: 6 hours *

* Default: Duration.hours(6) *

* @return {@code this} * @param maxEventAge The maximum age of a request that Lambda sends to a function for processing. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder maxEventAge(final software.amazon.awscdk.core.Duration maxEventAge) { this.props.maxEventAge(maxEventAge); return this; } /** * The destination for failed invocations. *

* Default: - no destination *

* @return {@code this} * @param onFailure The destination for failed invocations. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder onFailure(final software.amazon.awscdk.services.lambda.IDestination onFailure) { this.props.onFailure(onFailure); return this; } /** * The destination for successful invocations. *

* Default: - no destination *

* @return {@code this} * @param onSuccess The destination for successful invocations. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder onSuccess(final software.amazon.awscdk.services.lambda.IDestination onSuccess) { this.props.onSuccess(onSuccess); return this; } /** * The maximum number of times to retry when the function returns an error. *

* Minimum: 0 * Maximum: 2 *

* Default: 2 *

* @return {@code this} * @param retryAttempts The maximum number of times to retry when the function returns an error. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder retryAttempts(final java.lang.Number retryAttempts) { this.props.retryAttempts(retryAttempts); return this; } /** * 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. *

* Default: true *

* @return {@code this} * @param allowAllOutbound Whether to allow the Lambda to send all network traffic. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder allowAllOutbound(final java.lang.Boolean allowAllOutbound) { this.props.allowAllOutbound(allowAllOutbound); return this; } /** * 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. *

* Default: false *

* @return {@code this} * @see https://stackoverflow.com/questions/52992085/why-cant-an-aws-lambda-function-inside-a-public-subnet-in-a-vpc-connect-to-the/52994841#52994841 * @param allowPublicSubnet Lambda Functions in a public subnet can NOT access the internet. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder allowPublicSubnet(final java.lang.Boolean allowPublicSubnet) { this.props.allowPublicSubnet(allowPublicSubnet); return this; } /** * The system architectures compatible with this lambda function. *

* Default: Architecture.X86_64 *

* @return {@code this} * @param architecture The system architectures compatible with this lambda function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder architecture(final software.amazon.awscdk.services.lambda.Architecture architecture) { this.props.architecture(architecture); return this; } /** * (deprecated) DEPRECATED. *

* Default: [Architecture.X86_64] *

* @return {@code this} * @deprecated use `architecture` * @param architectures DEPRECATED. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) @Deprecated public Builder architectures(final java.util.List architectures) { this.props.architectures(architectures); return this; } /** * Code signing config associated with this function. *

* Default: - Not Sign the Code *

* @return {@code this} * @param codeSigningConfig Code signing config associated with this function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder codeSigningConfig(final software.amazon.awscdk.services.lambda.ICodeSigningConfig codeSigningConfig) { this.props.codeSigningConfig(codeSigningConfig); return this; } /** * Options for the `lambda.Version` resource automatically created by the `fn.currentVersion` method. *

* Default: - default options as described in `VersionOptions` *

* @return {@code this} * @param currentVersionOptions Options for the `lambda.Version` resource automatically created by the `fn.currentVersion` method. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder currentVersionOptions(final software.amazon.awscdk.services.lambda.VersionOptions currentVersionOptions) { this.props.currentVersionOptions(currentVersionOptions); return this; } /** * The SQS queue to use if DLQ is enabled. *

* If SNS topic is desired, specify deadLetterTopic property instead. *

* Default: - SQS queue with 14 day retention period if `deadLetterQueueEnabled` is `true` *

* @return {@code this} * @param deadLetterQueue The SQS queue to use if DLQ is enabled. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder deadLetterQueue(final software.amazon.awscdk.services.sqs.IQueue deadLetterQueue) { this.props.deadLetterQueue(deadLetterQueue); return this; } /** * Enabled DLQ. *

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

* Default: - false unless `deadLetterQueue` is set, which implies DLQ is enabled. *

* @return {@code this} * @param deadLetterQueueEnabled Enabled DLQ. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder deadLetterQueueEnabled(final java.lang.Boolean deadLetterQueueEnabled) { this.props.deadLetterQueueEnabled(deadLetterQueueEnabled); return this; } /** * 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. *

* Default: - no SNS topic *

* @return {@code this} * @param deadLetterTopic The SNS topic to use as a DLQ. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder deadLetterTopic(final software.amazon.awscdk.services.sns.ITopic deadLetterTopic) { this.props.deadLetterTopic(deadLetterTopic); return this; } /** * A description of the function. *

* Default: - No description. *

* @return {@code this} * @param description A description of the function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder description(final java.lang.String description) { this.props.description(description); return this; } /** * 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. *

* Default: - No environment variables. *

* @return {@code this} * @param environment Key-value pairs that Lambda caches and makes available for your Lambda functions. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder environment(final java.util.Map environment) { this.props.environment(environment); return this; } /** * The AWS KMS key that's used to encrypt your function's environment variables. *

* Default: - AWS Lambda creates and uses an AWS managed customer master key (CMK). *

* @return {@code this} * @param environmentEncryption The AWS KMS key that's used to encrypt your function's environment variables. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder environmentEncryption(final software.amazon.awscdk.services.kms.IKey environmentEncryption) { this.props.environmentEncryption(environmentEncryption); return this; } /** * Event sources for this function. *

* You can also add event sources using addEventSource. *

* Default: - No event sources. *

* @return {@code this} * @param events Event sources for this function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder events(final java.util.List events) { this.props.events(events); return this; } /** * The filesystem configuration for the lambda function. *

* Default: - will not mount any filesystem *

* @return {@code this} * @param filesystem The filesystem configuration for the lambda function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder filesystem(final software.amazon.awscdk.services.lambda.FileSystem filesystem) { this.props.filesystem(filesystem); return this; } /** * A name for the function. *

* Default: - AWS CloudFormation generates a unique physical ID and uses that * ID for the function's name. For more information, see Name Type. *

* @return {@code this} * @param functionName A name for the function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder functionName(final java.lang.String functionName) { this.props.functionName(functionName); return this; } /** * Initial policy statements to add to the created Lambda Role. *

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

* Default: - No policy statements are added to the created Lambda role. *

* @return {@code this} * @param initialPolicy Initial policy statements to add to the created Lambda Role. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder initialPolicy(final java.util.List initialPolicy) { this.props.initialPolicy(initialPolicy); return this; } /** * Specify the version of CloudWatch Lambda insights to use for monitoring. *

* Default: - No Lambda Insights *

* @return {@code this} * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-Getting-Started-docker.html * @param insightsVersion Specify the version of CloudWatch Lambda insights to use for monitoring. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder insightsVersion(final software.amazon.awscdk.services.lambda.LambdaInsightsVersion insightsVersion) { this.props.insightsVersion(insightsVersion); return this; } /** * 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. *

* Default: - No layers. *

* @return {@code this} * @param layers A list of layers to add to the function's execution environment. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder layers(final java.util.List layers) { this.props.layers(layers); return this; } /** * 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. *

* Default: logs.RetentionDays.INFINITE *

* @return {@code this} * @param logRetention The number of days log events are kept in CloudWatch Logs. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder logRetention(final software.amazon.awscdk.services.logs.RetentionDays logRetention) { this.props.logRetention(logRetention); return this; } /** * 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. *

* Default: - Default AWS SDK retry options. *

* @return {@code this} * @param logRetentionRetryOptions When log retention is specified, a custom resource attempts to create the CloudWatch log group. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder logRetentionRetryOptions(final software.amazon.awscdk.services.lambda.LogRetentionRetryOptions logRetentionRetryOptions) { this.props.logRetentionRetryOptions(logRetentionRetryOptions); return this; } /** * The IAM role for the Lambda function associated with the custom resource that sets the retention policy. *

* Default: - A new role is created. *

* @return {@code this} * @param logRetentionRole The IAM role for the Lambda function associated with the custom resource that sets the retention policy. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder logRetentionRole(final software.amazon.awscdk.services.iam.IRole logRetentionRole) { this.props.logRetentionRole(logRetentionRole); return this; } /** * 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. *

* Default: 128 *

* @return {@code this} * @param memorySize The amount of memory, in MB, that is allocated to your Lambda function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder memorySize(final java.lang.Number memorySize) { this.props.memorySize(memorySize); return this; } /** * Enable profiling. *

* Default: - No profiling. *

* @return {@code this} * @see https://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html * @param profiling Enable profiling. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder profiling(final java.lang.Boolean profiling) { this.props.profiling(profiling); return this; } /** * Profiling Group. *

* Default: - A new profiling group will be created if `profiling` is set. *

* @return {@code this} * @see https://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html * @param profilingGroup Profiling Group. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder profilingGroup(final software.amazon.awscdk.services.codeguruprofiler.IProfilingGroup profilingGroup) { this.props.profilingGroup(profilingGroup); return this; } /** * The maximum of concurrent executions you want to reserve for the function. *

* Default: - No specific limit - account limit. *

* @return {@code this} * @see https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html * @param reservedConcurrentExecutions The maximum of concurrent executions you want to reserve for the function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder reservedConcurrentExecutions(final java.lang.Number reservedConcurrentExecutions) { this.props.reservedConcurrentExecutions(reservedConcurrentExecutions); return this; } /** * 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". *

* Default: - A unique role will be generated for this lambda function. * Both supplied and generated roles can always be changed by calling `addToRolePolicy`. *

* @return {@code this} * @param role Lambda execution role. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder role(final software.amazon.awscdk.services.iam.IRole role) { this.props.role(role); return this; } /** * (deprecated) What security group to associate with the Lambda's network interfaces. This property is being deprecated, consider using securityGroups instead. *

* Only used if 'vpc' is supplied. *

* Use securityGroups property instead. * Function constructor will throw an error if both are specified. *

* Default: - If the function is placed within a VPC and a security group is * not specified, either by this or securityGroups prop, a dedicated security * group will be created for this function. *

* @return {@code this} * @deprecated - This property is deprecated, use securityGroups instead * @param securityGroup What security group to associate with the Lambda's network interfaces. This property is being deprecated, consider using securityGroups instead. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) @Deprecated public Builder securityGroup(final software.amazon.awscdk.services.ec2.ISecurityGroup securityGroup) { this.props.securityGroup(securityGroup); return this; } /** * The list of security groups to associate with the Lambda's network interfaces. *

* Only used if 'vpc' is supplied. *

* 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. *

* @return {@code this} * @param securityGroups The list of security groups to associate with the Lambda's network interfaces. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder securityGroups(final java.util.List securityGroups) { this.props.securityGroups(securityGroups); return this; } /** * 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. *

* Default: Duration.seconds(3) *

* @return {@code this} * @param timeout The function execution time (in seconds) after which Lambda terminates the function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder timeout(final software.amazon.awscdk.core.Duration timeout) { this.props.timeout(timeout); return this; } /** * Enable AWS X-Ray Tracing for Lambda Function. *

* Default: Tracing.Disabled *

* @return {@code this} * @param tracing Enable AWS X-Ray Tracing for Lambda Function. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder tracing(final software.amazon.awscdk.services.lambda.Tracing tracing) { this.props.tracing(tracing); return this; } /** * VPC network to place Lambda network interfaces. *

* Specify this if the Lambda function needs to access resources in a VPC. *

* Default: - Function is not placed within a VPC. *

* @return {@code this} * @param vpc VPC network to place Lambda network interfaces. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder vpc(final software.amazon.awscdk.services.ec2.IVpc vpc) { this.props.vpc(vpc); return this; } /** * Where to place the network interfaces within the VPC. *

* Only used if 'vpc' is supplied. Note: internet access for Lambdas * requires a NAT gateway, so picking Public subnets is not allowed. *

* Default: - the Vpc default strategy if not specified *

* @return {@code this} * @param vpcSubnets Where to place the network interfaces within the VPC. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder vpcSubnets(final software.amazon.awscdk.services.ec2.SubnetSelection vpcSubnets) { this.props.vpcSubnets(vpcSubnets); return this; } /** * (experimental) 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`
         * 
*

* @return {@code this} * @param entry The path to the folder or file that contains the main application entry point files for the project. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder entry(final java.lang.String entry) { this.props.entry(entry); return this; } /** * (experimental) Bundling options. *

* Default: - use default bundling options *

* @return {@code this} * @param bundling Bundling options. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder bundling(final software.amazon.awscdk.services.lambda.go.BundlingOptions bundling) { this.props.bundling(bundling); return this; } /** * (experimental) 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. *

* Default: - the path is found by walking up parent directories searching for * a `go.mod` file from the location of `entry` *

* @return {@code this} * @param moduleDir Directory containing your go.mod file. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder moduleDir(final java.lang.String moduleDir) { this.props.moduleDir(moduleDir); return this; } /** * (experimental) The runtime environment. *

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

* Default: lambda.Runtime.PROVIDED_AL2 *

* @return {@code this} * @param runtime The runtime environment. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder runtime(final software.amazon.awscdk.services.lambda.Runtime runtime) { this.props.runtime(runtime); return this; } /** * @returns a newly built instance of {@link software.amazon.awscdk.services.lambda.go.GoFunction}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public software.amazon.awscdk.services.lambda.go.GoFunction build() { return new software.amazon.awscdk.services.lambda.go.GoFunction( this.scope, this.id, this.props.build() ); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy