Function

Provides a Lambda Function resource. Lambda allows you to trigger execution of code in response to events in AWS, enabling serverless backend solutions. The Lambda Function itself includes source code and runtime configuration.

For information about Lambda and how to use it, see What is AWS Lambda?

NOTE: Due to AWS Lambda improved VPC networking changes that began deploying in September 2019, EC2 subnets and security groups associated with Lambda Functions can take up to 45 minutes to successfully delete.

Specifying the Deployment Package

AWS Lambda expects source code to be provided as a deployment package whose structure varies depending on which runtime is in use. See Runtimes for the valid values of runtime. The expected structure of the deployment package can be found in the AWS Lambda documentation for each runtime.

Once you have created your deployment package you can specify it either directly as a local file (using the filename argument) or indirectly via Amazon S3 (using the s3_bucket, s3_key and s3_object_version arguments). When providing the deployment package via S3 it may be useful to use the aws.s3.BucketObject resource to upload it.

For larger deployment packages it is recommended by Amazon to upload via S3, since the S3 API has better support for uploading large files efficiently.

Example Usage

Basic Example

Coming soon!

Coming soon!

Coming soon!

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const iamForLambda = new aws.iam.Role("iam_for_lambda", {
    assumeRolePolicy: `{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
`,
});
const testLambda = new aws.lambda.Function("test_lambda", {
    environment: {
        variables: {
            foo: "bar",
        },
    },
    code: new pulumi.asset.FileArchive("lambda_function_payload.zip"),
    handler: "exports.test",
    role: iamForLambda.arn,
    runtime: "nodejs12.x",
});

Lambda Layers

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleLayerVersion = new Aws.Lambda.LayerVersion("exampleLayerVersion", new Aws.Lambda.LayerVersionArgs
        {
        });
        var exampleFunction = new Aws.Lambda.Function("exampleFunction", new Aws.Lambda.FunctionArgs
        {
            Layers = 
            {
                exampleLayerVersion.Arn,
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/lambda"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        exampleLayerVersion, err := lambda.NewLayerVersion(ctx, "exampleLayerVersion", nil)
        if err != nil {
            return err
        }
        _, err = lambda.NewFunction(ctx, "exampleFunction", &lambda.FunctionArgs{
            Layers: pulumi.StringArray{
                exampleLayerVersion.Arn,
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

example_layer_version = aws.lambda_.LayerVersion("exampleLayerVersion")
example_function = aws.lambda_.Function("exampleFunction", layers=[example_layer_version.arn])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const exampleLayerVersion = new aws.lambda.LayerVersion("example", {});
const exampleFunction = new aws.lambda.Function("example", {
    // ... other configuration ...
    layers: [exampleLayerVersion.arn],
});

CloudWatch Logging and Permissions

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var testLambda = new Aws.Lambda.Function("testLambda", new Aws.Lambda.FunctionArgs
        {
        }, new CustomResourceOptions
        {
            DependsOn = 
            {
                "aws_cloudwatch_log_group.example",
                "aws_iam_role_policy_attachment.lambda_logs",
            },
        });
        // This is to optionally manage the CloudWatch Log Group for the Lambda Function.
        // If skipping this resource configuration, also add "logs:CreateLogGroup" to the IAM policy below.
        var example = new Aws.CloudWatch.LogGroup("example", new Aws.CloudWatch.LogGroupArgs
        {
            RetentionInDays = 14,
        });
        // See also the following AWS managed policy: AWSLambdaBasicExecutionRole
        var lambdaLogging = new Aws.Iam.Policy("lambdaLogging", new Aws.Iam.PolicyArgs
        {
            Description = "IAM policy for logging from a lambda",
            Path = "/",
            Policy = @"{
  ""Version"": ""2012-10-17"",
  ""Statement"": [
    {
      ""Action"": [
        ""logs:CreateLogGroup"",
        ""logs:CreateLogStream"",
        ""logs:PutLogEvents""
      ],
      ""Resource"": ""arn:aws:logs:*:*:*"",
      ""Effect"": ""Allow""
    }
  ]
}

",
        });
        var lambdaLogs = new Aws.Iam.RolePolicyAttachment("lambdaLogs", new Aws.Iam.RolePolicyAttachmentArgs
        {
            PolicyArn = lambdaLogging.Arn,
            Role = aws_iam_role.Iam_for_lambda.Name,
        });
    }

}
package main

import (
    "fmt"

    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/cloudwatch"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/iam"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/lambda"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := lambda.NewFunction(ctx, "testLambda", nil, pulumi.DependsOn([]pulumi.Resource{
            "aws_cloudwatch_log_group.example",
            "aws_iam_role_policy_attachment.lambda_logs",
        }))
        if err != nil {
            return err
        }
        _, err = cloudwatch.NewLogGroup(ctx, "example", &cloudwatch.LogGroupArgs{
            RetentionInDays: pulumi.Int(14),
        })
        if err != nil {
            return err
        }
        lambdaLogging, err := iam.NewPolicy(ctx, "lambdaLogging", &iam.PolicyArgs{
            Description: pulumi.String("IAM policy for logging from a lambda"),
            Path:        pulumi.String("/"),
            Policy:      pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v", "{\n", "  \"Version\": \"2012-10-17\",\n", "  \"Statement\": [\n", "    {\n", "      \"Action\": [\n", "        \"logs:CreateLogGroup\",\n", "        \"logs:CreateLogStream\",\n", "        \"logs:PutLogEvents\"\n", "      ],\n", "      \"Resource\": \"arn:aws:logs:*:*:*\",\n", "      \"Effect\": \"Allow\"\n", "    }\n", "  ]\n", "}\n", "\n")),
        })
        if err != nil {
            return err
        }
        _, err = iam.NewRolePolicyAttachment(ctx, "lambdaLogs", &iam.RolePolicyAttachmentArgs{
            PolicyArn: lambdaLogging.Arn,
            Role:      pulumi.String(aws_iam_role.Iam_for_lambda.Name),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

test_lambda = aws.lambda_.Function("testLambda", opts=ResourceOptions(depends_on=[
        "aws_cloudwatch_log_group.example",
        "aws_iam_role_policy_attachment.lambda_logs",
    ]))
# This is to optionally manage the CloudWatch Log Group for the Lambda Function.
# If skipping this resource configuration, also add "logs:CreateLogGroup" to the IAM policy below.
example = aws.cloudwatch.LogGroup("example", retention_in_days=14)
# See also the following AWS managed policy: AWSLambdaBasicExecutionRole
lambda_logging = aws.iam.Policy("lambdaLogging",
    description="IAM policy for logging from a lambda",
    path="/",
    policy="""{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents"
      ],
      "Resource": "arn:aws:logs:*:*:*",
      "Effect": "Allow"
    }
  ]
}

""")
lambda_logs = aws.iam.RolePolicyAttachment("lambdaLogs",
    policy_arn=lambda_logging.arn,
    role=aws_iam_role["iam_for_lambda"]["name"])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// This is to optionally manage the CloudWatch Log Group for the Lambda Function.
// If skipping this resource configuration, also add "logs:CreateLogGroup" to the IAM policy below.
const example = new aws.cloudwatch.LogGroup("example", {
    retentionInDays: 14,
});
// See also the following AWS managed policy: AWSLambdaBasicExecutionRole
const lambdaLogging = new aws.iam.Policy("lambda_logging", {
    description: "IAM policy for logging from a lambda",
    path: "/",
    policy: `{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents"
      ],
      "Resource": "arn:aws:logs:*:*:*",
      "Effect": "Allow"
    }
  ]
}
`,
});
const lambdaLogs = new aws.iam.RolePolicyAttachment("lambda_logs", {
    policyArn: lambdaLogging.arn,
    role: aws_iam_role_iam_for_lambda.name,
});
const testLambda = new aws.lambda.Function("test_lambda", {}, { dependsOn: [example, lambdaLogs] });

Create a Function Resource

def Function(resource_name, opts=None, code=None, dead_letter_config=None, description=None, environment=None, file_system_config=None, handler=None, kms_key_arn=None, layers=None, memory_size=None, name=None, publish=None, reserved_concurrent_executions=None, role=None, runtime=None, s3_bucket=None, s3_key=None, s3_object_version=None, source_code_hash=None, tags=None, timeout=None, tracing_config=None, vpc_config=None, __props__=None);
func NewFunction(ctx *Context, name string, args FunctionArgs, opts ...ResourceOption) (*Function, error)
public Function(string name, FunctionArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args FunctionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args FunctionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args FunctionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Function Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Function resource accepts the following input properties:

Handler string

The function entrypoint in your code.

Role string

IAM role attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. See Lambda Permission Model for more details.

Runtime string

See Runtimes for valid values.

Code Archive

The path to the function’s deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used.

DeadLetterConfig FunctionDeadLetterConfigArgs

Nested block to configure the function’s dead letter queue. See details below.

Description string

Description of what your Lambda Function does.

Environment FunctionEnvironmentArgs

The Lambda environment’s configuration settings. Fields documented below.

FileSystemConfig FunctionFileSystemConfigArgs

The connection settings for an EFS file system. Fields documented below. Before creating or updating Lambda functions with file_system_config, EFS mount targets much be in available lifecycle state. Use depends_on to explicitly declare this dependency. See Using Amazon EFS with Lambda.

KmsKeyArn string

Amazon Resource Name (ARN) of the AWS Key Management Service (KMS) key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key. If this configuration is provided when environment variables are not in use, the AWS Lambda API does not save this configuration and this provider will show a perpetual difference of adding the key. To fix the perpetual difference, remove this configuration.

Layers List<string>

List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. See Lambda Layers

MemorySize int

Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. See Limits

Name string

A unique name for your Lambda Function.

Publish bool

Whether to publish creation/change as new Lambda Function Version. Defaults to false.

ReservedConcurrentExecutions int

The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. See Managing Concurrency

S3Bucket string

The S3 bucket location containing the function’s deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function.

S3Key string

The S3 key of an object containing the function’s deployment package. Conflicts with filename.

S3ObjectVersion string

The object version containing the function’s deployment package. Conflicts with filename.

SourceCodeHash string

Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename or s3_key. The usual way to set this is filebase64sha256("file.zip") (this provider 0.11.12 and later) or base64sha256(file("file.zip")) (this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.

Tags Dictionary<string, string>

A mapping of tags to assign to the object.

Timeout int

The amount of time your Lambda Function has to run in seconds. Defaults to 3. See Limits

TracingConfig FunctionTracingConfigArgs
VpcConfig FunctionVpcConfigArgs

Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC

Handler string

The function entrypoint in your code.

Role string

IAM role attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. See Lambda Permission Model for more details.

Runtime string

See Runtimes for valid values.

Code pulumi.Archive

The path to the function’s deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used.

DeadLetterConfig FunctionDeadLetterConfig

Nested block to configure the function’s dead letter queue. See details below.

Description string

Description of what your Lambda Function does.

Environment FunctionEnvironment

The Lambda environment’s configuration settings. Fields documented below.

FileSystemConfig FunctionFileSystemConfig

The connection settings for an EFS file system. Fields documented below. Before creating or updating Lambda functions with file_system_config, EFS mount targets much be in available lifecycle state. Use depends_on to explicitly declare this dependency. See Using Amazon EFS with Lambda.

KmsKeyArn string

Amazon Resource Name (ARN) of the AWS Key Management Service (KMS) key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key. If this configuration is provided when environment variables are not in use, the AWS Lambda API does not save this configuration and this provider will show a perpetual difference of adding the key. To fix the perpetual difference, remove this configuration.

Layers []string

List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. See Lambda Layers

MemorySize int

Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. See Limits

Name string

A unique name for your Lambda Function.

Publish bool

Whether to publish creation/change as new Lambda Function Version. Defaults to false.

ReservedConcurrentExecutions int

The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. See Managing Concurrency

S3Bucket string

The S3 bucket location containing the function’s deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function.

S3Key string

The S3 key of an object containing the function’s deployment package. Conflicts with filename.

S3ObjectVersion string

The object version containing the function’s deployment package. Conflicts with filename.

SourceCodeHash string

Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename or s3_key. The usual way to set this is filebase64sha256("file.zip") (this provider 0.11.12 and later) or base64sha256(file("file.zip")) (this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.

Tags map[string]string

A mapping of tags to assign to the object.

Timeout int

The amount of time your Lambda Function has to run in seconds. Defaults to 3. See Limits

TracingConfig FunctionTracingConfig
VpcConfig FunctionVpcConfig

Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC

handler string

The function entrypoint in your code.

role ARN

IAM role attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. See Lambda Permission Model for more details.

runtime string

See Runtimes for valid values.

code pulumi.asset.Archive

The path to the function’s deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used.

deadLetterConfig FunctionDeadLetterConfig

Nested block to configure the function’s dead letter queue. See details below.

description string

Description of what your Lambda Function does.

environment FunctionEnvironment

The Lambda environment’s configuration settings. Fields documented below.

fileSystemConfig FunctionFileSystemConfig

The connection settings for an EFS file system. Fields documented below. Before creating or updating Lambda functions with file_system_config, EFS mount targets much be in available lifecycle state. Use depends_on to explicitly declare this dependency. See Using Amazon EFS with Lambda.

kmsKeyArn string

Amazon Resource Name (ARN) of the AWS Key Management Service (KMS) key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key. If this configuration is provided when environment variables are not in use, the AWS Lambda API does not save this configuration and this provider will show a perpetual difference of adding the key. To fix the perpetual difference, remove this configuration.

layers string[]

List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. See Lambda Layers

memorySize number

Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. See Limits

name string

A unique name for your Lambda Function.

publish boolean

Whether to publish creation/change as new Lambda Function Version. Defaults to false.

reservedConcurrentExecutions number

The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. See Managing Concurrency

s3Bucket string

The S3 bucket location containing the function’s deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function.

s3Key string

The S3 key of an object containing the function’s deployment package. Conflicts with filename.

s3ObjectVersion string

The object version containing the function’s deployment package. Conflicts with filename.

sourceCodeHash string

Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename or s3_key. The usual way to set this is filebase64sha256("file.zip") (this provider 0.11.12 and later) or base64sha256(file("file.zip")) (this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.

tags {[key: string]: string}

A mapping of tags to assign to the object.

timeout number

The amount of time your Lambda Function has to run in seconds. Defaults to 3. See Limits

tracingConfig FunctionTracingConfig
vpcConfig FunctionVpcConfig

Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC

handler str

The function entrypoint in your code.

role str

IAM role attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. See Lambda Permission Model for more details.

runtime str

See Runtimes for valid values.

code pulumi.Archive

The path to the function’s deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used.

dead_letter_config Dict[FunctionDeadLetterConfig]

Nested block to configure the function’s dead letter queue. See details below.

description str

Description of what your Lambda Function does.

environment Dict[FunctionEnvironment]

The Lambda environment’s configuration settings. Fields documented below.

file_system_config Dict[FunctionFileSystemConfig]

The connection settings for an EFS file system. Fields documented below. Before creating or updating Lambda functions with file_system_config, EFS mount targets much be in available lifecycle state. Use depends_on to explicitly declare this dependency. See Using Amazon EFS with Lambda.

kms_key_arn str

Amazon Resource Name (ARN) of the AWS Key Management Service (KMS) key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key. If this configuration is provided when environment variables are not in use, the AWS Lambda API does not save this configuration and this provider will show a perpetual difference of adding the key. To fix the perpetual difference, remove this configuration.

layers List[str]

List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. See Lambda Layers

memory_size float

Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. See Limits

name str

A unique name for your Lambda Function.

publish bool

Whether to publish creation/change as new Lambda Function Version. Defaults to false.

reserved_concurrent_executions float

The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. See Managing Concurrency

s3_bucket str

The S3 bucket location containing the function’s deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function.

s3_key str

The S3 key of an object containing the function’s deployment package. Conflicts with filename.

s3_object_version str

The object version containing the function’s deployment package. Conflicts with filename.

source_code_hash str

Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename or s3_key. The usual way to set this is filebase64sha256("file.zip") (this provider 0.11.12 and later) or base64sha256(file("file.zip")) (this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.

tags Dict[str, str]

A mapping of tags to assign to the object.

timeout float

The amount of time your Lambda Function has to run in seconds. Defaults to 3. See Limits

tracing_config Dict[FunctionTracingConfig]
vpc_config Dict[FunctionVpcConfig]

Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC

Outputs

All input properties are implicitly available as output properties. Additionally, the Function resource produces the following output properties:

Arn string

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

Id string
The provider-assigned unique ID for this managed resource.
InvokeArn string

The ARN to be used for invoking Lambda Function from API Gateway - to be used in aws.apigateway.Integration’s uri

LastModified string

The date this resource was last modified.

QualifiedArn string

The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via publish = true).

SourceCodeSize int

The size in bytes of the function .zip file.

Version string

Latest published version of your Lambda Function.

Arn string

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

Id string
The provider-assigned unique ID for this managed resource.
InvokeArn string

The ARN to be used for invoking Lambda Function from API Gateway - to be used in aws.apigateway.Integration’s uri

LastModified string

The date this resource was last modified.

QualifiedArn string

The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via publish = true).

SourceCodeSize int

The size in bytes of the function .zip file.

Version string

Latest published version of your Lambda Function.

arn string

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

id string
The provider-assigned unique ID for this managed resource.
invokeArn string

The ARN to be used for invoking Lambda Function from API Gateway - to be used in aws.apigateway.Integration’s uri

lastModified string

The date this resource was last modified.

qualifiedArn string

The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via publish = true).

sourceCodeSize number

The size in bytes of the function .zip file.

version string

Latest published version of your Lambda Function.

arn str

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

id str
The provider-assigned unique ID for this managed resource.
invoke_arn str

The ARN to be used for invoking Lambda Function from API Gateway - to be used in aws.apigateway.Integration’s uri

last_modified str

The date this resource was last modified.

qualified_arn str

The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via publish = true).

source_code_size float

The size in bytes of the function .zip file.

version str

Latest published version of your Lambda Function.

Look up an Existing Function Resource

Get an existing Function resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: FunctionState, opts?: CustomResourceOptions): Function
static get(resource_name, id, opts=None, arn=None, code=None, dead_letter_config=None, description=None, environment=None, file_system_config=None, handler=None, invoke_arn=None, kms_key_arn=None, last_modified=None, layers=None, memory_size=None, name=None, publish=None, qualified_arn=None, reserved_concurrent_executions=None, role=None, runtime=None, s3_bucket=None, s3_key=None, s3_object_version=None, source_code_hash=None, source_code_size=None, tags=None, timeout=None, tracing_config=None, version=None, vpc_config=None, __props__=None);
func GetFunction(ctx *Context, name string, id IDInput, state *FunctionState, opts ...ResourceOption) (*Function, error)
public static Function Get(string name, Input<string> id, FunctionState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Arn string

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

Code Archive

The path to the function’s deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used.

DeadLetterConfig FunctionDeadLetterConfigArgs

Nested block to configure the function’s dead letter queue. See details below.

Description string

Description of what your Lambda Function does.

Environment FunctionEnvironmentArgs

The Lambda environment’s configuration settings. Fields documented below.

FileSystemConfig FunctionFileSystemConfigArgs

The connection settings for an EFS file system. Fields documented below. Before creating or updating Lambda functions with file_system_config, EFS mount targets much be in available lifecycle state. Use depends_on to explicitly declare this dependency. See Using Amazon EFS with Lambda.

Handler string

The function entrypoint in your code.

InvokeArn string

The ARN to be used for invoking Lambda Function from API Gateway - to be used in aws.apigateway.Integration’s uri

KmsKeyArn string

Amazon Resource Name (ARN) of the AWS Key Management Service (KMS) key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key. If this configuration is provided when environment variables are not in use, the AWS Lambda API does not save this configuration and this provider will show a perpetual difference of adding the key. To fix the perpetual difference, remove this configuration.

LastModified string

The date this resource was last modified.

Layers List<string>

List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. See Lambda Layers

MemorySize int

Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. See Limits

Name string

A unique name for your Lambda Function.

Publish bool

Whether to publish creation/change as new Lambda Function Version. Defaults to false.

QualifiedArn string

The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via publish = true).

ReservedConcurrentExecutions int

The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. See Managing Concurrency

Role string

IAM role attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. See Lambda Permission Model for more details.

Runtime string

See Runtimes for valid values.

S3Bucket string

The S3 bucket location containing the function’s deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function.

S3Key string

The S3 key of an object containing the function’s deployment package. Conflicts with filename.

S3ObjectVersion string

The object version containing the function’s deployment package. Conflicts with filename.

SourceCodeHash string

Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename or s3_key. The usual way to set this is filebase64sha256("file.zip") (this provider 0.11.12 and later) or base64sha256(file("file.zip")) (this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.

SourceCodeSize int

The size in bytes of the function .zip file.

Tags Dictionary<string, string>

A mapping of tags to assign to the object.

Timeout int

The amount of time your Lambda Function has to run in seconds. Defaults to 3. See Limits

TracingConfig FunctionTracingConfigArgs
Version string

Latest published version of your Lambda Function.

VpcConfig FunctionVpcConfigArgs

Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC

Arn string

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

Code pulumi.Archive

The path to the function’s deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used.

DeadLetterConfig FunctionDeadLetterConfig

Nested block to configure the function’s dead letter queue. See details below.

Description string

Description of what your Lambda Function does.

Environment FunctionEnvironment

The Lambda environment’s configuration settings. Fields documented below.

FileSystemConfig FunctionFileSystemConfig

The connection settings for an EFS file system. Fields documented below. Before creating or updating Lambda functions with file_system_config, EFS mount targets much be in available lifecycle state. Use depends_on to explicitly declare this dependency. See Using Amazon EFS with Lambda.

Handler string

The function entrypoint in your code.

InvokeArn string

The ARN to be used for invoking Lambda Function from API Gateway - to be used in aws.apigateway.Integration’s uri

KmsKeyArn string

Amazon Resource Name (ARN) of the AWS Key Management Service (KMS) key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key. If this configuration is provided when environment variables are not in use, the AWS Lambda API does not save this configuration and this provider will show a perpetual difference of adding the key. To fix the perpetual difference, remove this configuration.

LastModified string

The date this resource was last modified.

Layers []string

List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. See Lambda Layers

MemorySize int

Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. See Limits

Name string

A unique name for your Lambda Function.

Publish bool

Whether to publish creation/change as new Lambda Function Version. Defaults to false.

QualifiedArn string

The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via publish = true).

ReservedConcurrentExecutions int

The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. See Managing Concurrency

Role string

IAM role attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. See Lambda Permission Model for more details.

Runtime string

See Runtimes for valid values.

S3Bucket string

The S3 bucket location containing the function’s deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function.

S3Key string

The S3 key of an object containing the function’s deployment package. Conflicts with filename.

S3ObjectVersion string

The object version containing the function’s deployment package. Conflicts with filename.

SourceCodeHash string

Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename or s3_key. The usual way to set this is filebase64sha256("file.zip") (this provider 0.11.12 and later) or base64sha256(file("file.zip")) (this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.

SourceCodeSize int

The size in bytes of the function .zip file.

Tags map[string]string

A mapping of tags to assign to the object.

Timeout int

The amount of time your Lambda Function has to run in seconds. Defaults to 3. See Limits

TracingConfig FunctionTracingConfig
Version string

Latest published version of your Lambda Function.

VpcConfig FunctionVpcConfig

Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC

arn string

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

code pulumi.asset.Archive

The path to the function’s deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used.

deadLetterConfig FunctionDeadLetterConfig

Nested block to configure the function’s dead letter queue. See details below.

description string

Description of what your Lambda Function does.

environment FunctionEnvironment

The Lambda environment’s configuration settings. Fields documented below.

fileSystemConfig FunctionFileSystemConfig

The connection settings for an EFS file system. Fields documented below. Before creating or updating Lambda functions with file_system_config, EFS mount targets much be in available lifecycle state. Use depends_on to explicitly declare this dependency. See Using Amazon EFS with Lambda.

handler string

The function entrypoint in your code.

invokeArn string

The ARN to be used for invoking Lambda Function from API Gateway - to be used in aws.apigateway.Integration’s uri

kmsKeyArn string

Amazon Resource Name (ARN) of the AWS Key Management Service (KMS) key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key. If this configuration is provided when environment variables are not in use, the AWS Lambda API does not save this configuration and this provider will show a perpetual difference of adding the key. To fix the perpetual difference, remove this configuration.

lastModified string

The date this resource was last modified.

layers string[]

List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. See Lambda Layers

memorySize number

Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. See Limits

name string

A unique name for your Lambda Function.

publish boolean

Whether to publish creation/change as new Lambda Function Version. Defaults to false.

qualifiedArn string

The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via publish = true).

reservedConcurrentExecutions number

The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. See Managing Concurrency

role ARN

IAM role attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. See Lambda Permission Model for more details.

runtime string

See Runtimes for valid values.

s3Bucket string

The S3 bucket location containing the function’s deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function.

s3Key string

The S3 key of an object containing the function’s deployment package. Conflicts with filename.

s3ObjectVersion string

The object version containing the function’s deployment package. Conflicts with filename.

sourceCodeHash string

Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename or s3_key. The usual way to set this is filebase64sha256("file.zip") (this provider 0.11.12 and later) or base64sha256(file("file.zip")) (this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.

sourceCodeSize number

The size in bytes of the function .zip file.

tags {[key: string]: string}

A mapping of tags to assign to the object.

timeout number

The amount of time your Lambda Function has to run in seconds. Defaults to 3. See Limits

tracingConfig FunctionTracingConfig
version string

Latest published version of your Lambda Function.

vpcConfig FunctionVpcConfig

Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC

arn str

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

code pulumi.Archive

The path to the function’s deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used.

dead_letter_config Dict[FunctionDeadLetterConfig]

Nested block to configure the function’s dead letter queue. See details below.

description str

Description of what your Lambda Function does.

environment Dict[FunctionEnvironment]

The Lambda environment’s configuration settings. Fields documented below.

file_system_config Dict[FunctionFileSystemConfig]

The connection settings for an EFS file system. Fields documented below. Before creating or updating Lambda functions with file_system_config, EFS mount targets much be in available lifecycle state. Use depends_on to explicitly declare this dependency. See Using Amazon EFS with Lambda.

handler str

The function entrypoint in your code.

invoke_arn str

The ARN to be used for invoking Lambda Function from API Gateway - to be used in aws.apigateway.Integration’s uri

kms_key_arn str

Amazon Resource Name (ARN) of the AWS Key Management Service (KMS) key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key. If this configuration is provided when environment variables are not in use, the AWS Lambda API does not save this configuration and this provider will show a perpetual difference of adding the key. To fix the perpetual difference, remove this configuration.

last_modified str

The date this resource was last modified.

layers List[str]

List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. See Lambda Layers

memory_size float

Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. See Limits

name str

A unique name for your Lambda Function.

publish bool

Whether to publish creation/change as new Lambda Function Version. Defaults to false.

qualified_arn str

The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via publish = true).

reserved_concurrent_executions float

The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. See Managing Concurrency

role str

IAM role attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. See Lambda Permission Model for more details.

runtime str

See Runtimes for valid values.

s3_bucket str

The S3 bucket location containing the function’s deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function.

s3_key str

The S3 key of an object containing the function’s deployment package. Conflicts with filename.

s3_object_version str

The object version containing the function’s deployment package. Conflicts with filename.

source_code_hash str

Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename or s3_key. The usual way to set this is filebase64sha256("file.zip") (this provider 0.11.12 and later) or base64sha256(file("file.zip")) (this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.

source_code_size float

The size in bytes of the function .zip file.

tags Dict[str, str]

A mapping of tags to assign to the object.

timeout float

The amount of time your Lambda Function has to run in seconds. Defaults to 3. See Limits

tracing_config Dict[FunctionTracingConfig]
version str

Latest published version of your Lambda Function.

vpc_config Dict[FunctionVpcConfig]

Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC

Supporting Types

FunctionDeadLetterConfig

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

TargetArn string

The ARN of an SNS topic or SQS queue to notify when an invocation fails. If this option is used, the function’s IAM role must be granted suitable access to write to the target object, which means allowing either the sns:Publish or sqs:SendMessage action on this ARN, depending on which service is targeted.

TargetArn string

The ARN of an SNS topic or SQS queue to notify when an invocation fails. If this option is used, the function’s IAM role must be granted suitable access to write to the target object, which means allowing either the sns:Publish or sqs:SendMessage action on this ARN, depending on which service is targeted.

targetArn string

The ARN of an SNS topic or SQS queue to notify when an invocation fails. If this option is used, the function’s IAM role must be granted suitable access to write to the target object, which means allowing either the sns:Publish or sqs:SendMessage action on this ARN, depending on which service is targeted.

target_arn str

The ARN of an SNS topic or SQS queue to notify when an invocation fails. If this option is used, the function’s IAM role must be granted suitable access to write to the target object, which means allowing either the sns:Publish or sqs:SendMessage action on this ARN, depending on which service is targeted.

FunctionEnvironment

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Variables Dictionary<string, string>

A map that defines environment variables for the Lambda function.

Variables map[string]string

A map that defines environment variables for the Lambda function.

variables {[key: string]: string}

A map that defines environment variables for the Lambda function.

variables Dict[str, str]

A map that defines environment variables for the Lambda function.

FunctionFileSystemConfig

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Arn string

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

LocalMountPath string

The path where the function can access the file system, starting with /mnt/.

Arn string

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

LocalMountPath string

The path where the function can access the file system, starting with /mnt/.

arn string

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

localMountPath string

The path where the function can access the file system, starting with /mnt/.

arn str

The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.

localMountPath str

The path where the function can access the file system, starting with /mnt/.

FunctionTracingConfig

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Mode string

Can be either PassThrough or Active. If PassThrough, Lambda will only trace the request from an upstream service if it contains a tracing header with “sampled=1”. If Active, Lambda will respect any tracing header it receives from an upstream service. If no tracing header is received, Lambda will call X-Ray for a tracing decision.

Mode string

Can be either PassThrough or Active. If PassThrough, Lambda will only trace the request from an upstream service if it contains a tracing header with “sampled=1”. If Active, Lambda will respect any tracing header it receives from an upstream service. If no tracing header is received, Lambda will call X-Ray for a tracing decision.

mode string

Can be either PassThrough or Active. If PassThrough, Lambda will only trace the request from an upstream service if it contains a tracing header with “sampled=1”. If Active, Lambda will respect any tracing header it receives from an upstream service. If no tracing header is received, Lambda will call X-Ray for a tracing decision.

mode str

Can be either PassThrough or Active. If PassThrough, Lambda will only trace the request from an upstream service if it contains a tracing header with “sampled=1”. If Active, Lambda will respect any tracing header it receives from an upstream service. If no tracing header is received, Lambda will call X-Ray for a tracing decision.

FunctionVpcConfig

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

SecurityGroupIds List<string>

A list of security group IDs associated with the Lambda function.

SubnetIds List<string>

A list of subnet IDs associated with the Lambda function.

VpcId string
SecurityGroupIds []string

A list of security group IDs associated with the Lambda function.

SubnetIds []string

A list of subnet IDs associated with the Lambda function.

VpcId string
securityGroupIds string[]

A list of security group IDs associated with the Lambda function.

subnetIds string[]

A list of subnet IDs associated with the Lambda function.

vpcId string
security_group_ids List[str]

A list of security group IDs associated with the Lambda function.

subnet_ids List[str]

A list of subnet IDs associated with the Lambda function.

vpc_id str

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.