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
new Function(name: string, args: FunctionArgs, opts?: CustomResourceOptions);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.- Dead
Letter FunctionConfig Dead Letter Config Args Nested block to configure the function’s dead letter queue. See details below.
- Description string
Description of what your Lambda Function does.
- Environment
Function
Environment Args The Lambda environment’s configuration settings. Fields documented below.
- File
System FunctionConfig File System Config Args 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. Usedepends_onto explicitly declare this dependency. See Using Amazon EFS with Lambda.- Kms
Key stringArn 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
- Memory
Size 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.- Reserved
Concurrent intExecutions The amount of reserved concurrent executions for this lambda function. A value of
0disables lambda from being triggered and-1removes 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.- S3Object
Version string The object version containing the function’s deployment package. Conflicts with
filename.- Source
Code stringHash Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either
filenameors3_key. The usual way to set this isfilebase64sha256("file.zip")(this provider 0.11.12 and later) orbase64sha256(file("file.zip"))(this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.- 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- Tracing
Config FunctionTracing Config Args - Vpc
Config FunctionVpc Config Args 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.- Dead
Letter FunctionConfig Dead Letter Config Nested block to configure the function’s dead letter queue. See details below.
- Description string
Description of what your Lambda Function does.
- Environment
Function
Environment The Lambda environment’s configuration settings. Fields documented below.
- File
System FunctionConfig File System Config 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. Usedepends_onto explicitly declare this dependency. See Using Amazon EFS with Lambda.- Kms
Key stringArn 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
- Memory
Size 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.- Reserved
Concurrent intExecutions The amount of reserved concurrent executions for this lambda function. A value of
0disables lambda from being triggered and-1removes 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.- S3Object
Version string The object version containing the function’s deployment package. Conflicts with
filename.- Source
Code stringHash Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either
filenameors3_key. The usual way to set this isfilebase64sha256("file.zip")(this provider 0.11.12 and later) orbase64sha256(file("file.zip"))(this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.- 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- Tracing
Config FunctionTracing Config - Vpc
Config FunctionVpc Config 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.- dead
Letter FunctionConfig Dead Letter Config Nested block to configure the function’s dead letter queue. See details below.
- description string
Description of what your Lambda Function does.
- environment
Function
Environment The Lambda environment’s configuration settings. Fields documented below.
- file
System FunctionConfig File System Config 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. Usedepends_onto explicitly declare this dependency. See Using Amazon EFS with Lambda.- kms
Key stringArn 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
- memory
Size 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.- reserved
Concurrent numberExecutions The amount of reserved concurrent executions for this lambda function. A value of
0disables lambda from being triggered and-1removes 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.- s3Object
Version string The object version containing the function’s deployment package. Conflicts with
filename.- source
Code stringHash Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either
filenameors3_key. The usual way to set this isfilebase64sha256("file.zip")(this provider 0.11.12 and later) orbase64sha256(file("file.zip"))(this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.- {[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- tracing
Config FunctionTracing Config - vpc
Config FunctionVpc Config 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_ Dict[Functionconfig Dead Letter Config] Nested block to configure the function’s dead letter queue. See details below.
- description str
Description of what your Lambda Function does.
- environment
Dict[Function
Environment] The Lambda environment’s configuration settings. Fields documented below.
- file_
system_ Dict[Functionconfig File System Config] 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. Usedepends_onto explicitly declare this dependency. See Using Amazon EFS with Lambda.- kms_
key_ strarn 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_ floatexecutions The amount of reserved concurrent executions for this lambda function. A value of
0disables lambda from being triggered and-1removes 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_ strversion The object version containing the function’s deployment package. Conflicts with
filename.- source_
code_ strhash Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either
filenameors3_key. The usual way to set this isfilebase64sha256("file.zip")(this provider 0.11.12 and later) orbase64sha256(file("file.zip"))(this provider 0.11.11 and earlier), where “file.zip” is the local filename of the lambda function source archive.- 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[FunctionTracing Config] - vpc_
config Dict[FunctionVpc Config] 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.
- Invoke
Arn string The ARN to be used for invoking Lambda Function from API Gateway - to be used in
aws.apigateway.Integration’suri- Last
Modified string The date this resource was last modified.
- Qualified
Arn string The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via
publish = true).- Source
Code intSize 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.
- Invoke
Arn string The ARN to be used for invoking Lambda Function from API Gateway - to be used in
aws.apigateway.Integration’suri- Last
Modified string The date this resource was last modified.
- Qualified
Arn string The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via
publish = true).- Source
Code intSize 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.
- invoke
Arn string The ARN to be used for invoking Lambda Function from API Gateway - to be used in
aws.apigateway.Integration’suri- last
Modified string The date this resource was last modified.
- qualified
Arn string The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via
publish = true).- source
Code numberSize 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’suri- 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_ floatsize 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): Functionstatic 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.- Dead
Letter FunctionConfig Dead Letter Config Args Nested block to configure the function’s dead letter queue. See details below.
- Description string
Description of what your Lambda Function does.
- Environment
Function
Environment Args The Lambda environment’s configuration settings. Fields documented below.
- File
System FunctionConfig File System Config Args 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. Usedepends_onto explicitly declare this dependency. See Using Amazon EFS with Lambda.- Handler string
The function entrypoint in your code.
- Invoke
Arn string The ARN to be used for invoking Lambda Function from API Gateway - to be used in
aws.apigateway.Integration’suri- Kms
Key stringArn 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 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
- Memory
Size 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.- Qualified
Arn string The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via
publish = true).- Reserved
Concurrent intExecutions The amount of reserved concurrent executions for this lambda function. A value of
0disables lambda from being triggered and-1removes 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.- S3Object
Version string The object version containing the function’s deployment package. Conflicts with
filename.- Source
Code stringHash Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either
filenameors3_key. The usual way to set this isfilebase64sha256("file.zip")(this provider 0.11.12 and later) orbase64sha256(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 intSize The size in bytes of the function .zip file.
- 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- Tracing
Config FunctionTracing Config Args - Version string
Latest published version of your Lambda Function.
- Vpc
Config FunctionVpc Config Args 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.- Dead
Letter FunctionConfig Dead Letter Config Nested block to configure the function’s dead letter queue. See details below.
- Description string
Description of what your Lambda Function does.
- Environment
Function
Environment The Lambda environment’s configuration settings. Fields documented below.
- File
System FunctionConfig File System Config 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. Usedepends_onto explicitly declare this dependency. See Using Amazon EFS with Lambda.- Handler string
The function entrypoint in your code.
- Invoke
Arn string The ARN to be used for invoking Lambda Function from API Gateway - to be used in
aws.apigateway.Integration’suri- Kms
Key stringArn 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 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
- Memory
Size 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.- Qualified
Arn string The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via
publish = true).- Reserved
Concurrent intExecutions The amount of reserved concurrent executions for this lambda function. A value of
0disables lambda from being triggered and-1removes 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.- S3Object
Version string The object version containing the function’s deployment package. Conflicts with
filename.- Source
Code stringHash Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either
filenameors3_key. The usual way to set this isfilebase64sha256("file.zip")(this provider 0.11.12 and later) orbase64sha256(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 intSize The size in bytes of the function .zip file.
- 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- Tracing
Config FunctionTracing Config - Version string
Latest published version of your Lambda Function.
- Vpc
Config FunctionVpc Config 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.- dead
Letter FunctionConfig Dead Letter Config Nested block to configure the function’s dead letter queue. See details below.
- description string
Description of what your Lambda Function does.
- environment
Function
Environment The Lambda environment’s configuration settings. Fields documented below.
- file
System FunctionConfig File System Config 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. Usedepends_onto explicitly declare this dependency. See Using Amazon EFS with Lambda.- handler string
The function entrypoint in your code.
- invoke
Arn string The ARN to be used for invoking Lambda Function from API Gateway - to be used in
aws.apigateway.Integration’suri- kms
Key stringArn 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 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
- memory
Size 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.- qualified
Arn string The Amazon Resource Name (ARN) identifying your Lambda Function Version (if versioning is enabled via
publish = true).- reserved
Concurrent numberExecutions The amount of reserved concurrent executions for this lambda function. A value of
0disables lambda from being triggered and-1removes 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.- s3Object
Version string The object version containing the function’s deployment package. Conflicts with
filename.- source
Code stringHash Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either
filenameors3_key. The usual way to set this isfilebase64sha256("file.zip")(this provider 0.11.12 and later) orbase64sha256(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 numberSize The size in bytes of the function .zip file.
- {[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- tracing
Config FunctionTracing Config - version string
Latest published version of your Lambda Function.
- vpc
Config FunctionVpc Config 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_ Dict[Functionconfig Dead Letter Config] Nested block to configure the function’s dead letter queue. See details below.
- description str
Description of what your Lambda Function does.
- environment
Dict[Function
Environment] The Lambda environment’s configuration settings. Fields documented below.
- file_
system_ Dict[Functionconfig File System Config] 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. Usedepends_onto 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’suri- kms_
key_ strarn 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_ floatexecutions The amount of reserved concurrent executions for this lambda function. A value of
0disables lambda from being triggered and-1removes 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_ strversion The object version containing the function’s deployment package. Conflicts with
filename.- source_
code_ strhash Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either
filenameors3_key. The usual way to set this isfilebase64sha256("file.zip")(this provider 0.11.12 and later) orbase64sha256(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_ floatsize The size in bytes of the function .zip file.
- 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[FunctionTracing Config] - version str
Latest published version of your Lambda Function.
- vpc_
config Dict[FunctionVpc Config] Provide this to allow your function to access your VPC. Fields documented below. See Lambda in VPC
Supporting Types
FunctionDeadLetterConfig
- Target
Arn 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:Publishorsqs:SendMessageaction on this ARN, depending on which service is targeted.
- Target
Arn 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:Publishorsqs:SendMessageaction on this ARN, depending on which service is targeted.
- target
Arn 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:Publishorsqs:SendMessageaction 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:Publishorsqs:SendMessageaction on this ARN, depending on which service is targeted.
FunctionEnvironment
- 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
- Arn string
The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system.
- Local
Mount stringPath 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.
- Local
Mount stringPath 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.
- local
Mount stringPath 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.
- local
Mount strPath The path where the function can access the file system, starting with /mnt/.
FunctionTracingConfig
- Mode string
Can be either
PassThroughorActive. 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
PassThroughorActive. 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
PassThroughorActive. 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
PassThroughorActive. 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
- Security
Group List<string>Ids A list of security group IDs associated with the Lambda function.
- Subnet
Ids List<string> A list of subnet IDs associated with the Lambda function.
- Vpc
Id string
- security_
group_ List[str]ids 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
awsTerraform Provider.