SingletonFunction
- class aws_cdk.aws_lambda.SingletonFunction(scope, id, *, uuid, lambda_purpose=None, code, handler, runtime, allow_all_outbound=None, allow_public_subnet=None, architecture=None, architectures=None, code_signing_config=None, current_version_options=None, dead_letter_queue=None, dead_letter_queue_enabled=None, dead_letter_topic=None, description=None, environment=None, environment_encryption=None, ephemeral_storage_size=None, events=None, filesystem=None, function_name=None, initial_policy=None, insights_version=None, layers=None, log_retention=None, log_retention_retry_options=None, log_retention_role=None, memory_size=None, profiling=None, profiling_group=None, reserved_concurrent_executions=None, role=None, security_group=None, security_groups=None, timeout=None, tracing=None, vpc=None, vpc_subnets=None, max_event_age=None, on_failure=None, on_success=None, retry_attempts=None)
Bases:
FunctionBase
A Lambda that will only ever be added to a stack once.
This construct is a way to guarantee that the lambda function will be guaranteed to be part of the stack, once and only once, irrespective of how many times the construct is declared to be part of the stack. This is guaranteed as long as the
uuid
property and the optionallambdaPurpose
property stay the same whenever they’re declared into the stack.- Resource:
AWS::Lambda::Function
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_codeguruprofiler as codeguruprofiler import aws_cdk.aws_ec2 as ec2 import aws_cdk.aws_iam as iam import aws_cdk.aws_kms as kms import aws_cdk.aws_lambda as lambda_ import aws_cdk.aws_logs as logs import aws_cdk.aws_sns as sns import aws_cdk.aws_sqs as sqs import aws_cdk.core as cdk # architecture: lambda.Architecture # code: lambda.Code # code_signing_config: lambda.CodeSigningConfig # destination: lambda.IDestination # event_source: lambda.IEventSource # file_system: lambda.FileSystem # key: kms.Key # lambda_insights_version: lambda.LambdaInsightsVersion # layer_version: lambda.LayerVersion # policy_statement: iam.PolicyStatement # profiling_group: codeguruprofiler.ProfilingGroup # queue: sqs.Queue # role: iam.Role # runtime: lambda.Runtime # security_group: ec2.SecurityGroup # size: cdk.Size # subnet: ec2.Subnet # subnet_filter: ec2.SubnetFilter # topic: sns.Topic # vpc: ec2.Vpc singleton_function = lambda_.SingletonFunction(self, "MySingletonFunction", code=code, handler="handler", runtime=runtime, uuid="uuid", # the properties below are optional allow_all_outbound=False, allow_public_subnet=False, architecture=architecture, architectures=[architecture], code_signing_config=code_signing_config, current_version_options=lambda.VersionOptions( code_sha256="codeSha256", description="description", max_event_age=cdk.Duration.minutes(30), on_failure=destination, on_success=destination, provisioned_concurrent_executions=123, removal_policy=cdk.RemovalPolicy.DESTROY, retry_attempts=123 ), dead_letter_queue=queue, dead_letter_queue_enabled=False, dead_letter_topic=topic, description="description", environment={ "environment_key": "environment" }, environment_encryption=key, ephemeral_storage_size=size, events=[event_source], filesystem=file_system, function_name="functionName", initial_policy=[policy_statement], insights_version=lambda_insights_version, lambda_purpose="lambdaPurpose", layers=[layer_version], log_retention=logs.RetentionDays.ONE_DAY, log_retention_retry_options=lambda.LogRetentionRetryOptions( base=cdk.Duration.minutes(30), max_retries=123 ), log_retention_role=role, max_event_age=cdk.Duration.minutes(30), memory_size=123, on_failure=destination, on_success=destination, profiling=False, profiling_group=profiling_group, reserved_concurrent_executions=123, retry_attempts=123, role=role, security_group=security_group, security_groups=[security_group], timeout=cdk.Duration.minutes(30), tracing=lambda_.Tracing.ACTIVE, vpc=vpc, vpc_subnets=ec2.SubnetSelection( availability_zones=["availabilityZones"], one_per_az=False, subnet_filters=[subnet_filter], subnet_group_name="subnetGroupName", subnet_name="subnetName", subnets=[subnet], subnet_type=ec2.SubnetType.ISOLATED ) )
- Parameters:
scope (
Construct
)id (
str
)uuid (
str
) – A unique identifier to identify this lambda. The identifier should be unique across all custom resource providers. We recommend generating a UUID per provider.lambda_purpose (
Optional
[str
]) – A descriptive name for the purpose of this Lambda. If the Lambda does not have a physical name, this string will be reflected its generated name. The combination of lambdaPurpose and uuid must be unique. Default: SingletonLambdacode (
Code
) – The source code of your Lambda function. You can point to a file in an Amazon Simple Storage Service (Amazon S3) bucket or specify your source code as inline text.handler (
str
) – The name of the method within your code that Lambda calls to execute your function. The format includes the file name. It can also include namespaces and other qualifiers, depending on the runtime. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-features.html#gettingstarted-features-programmingmodel. UseHandler.FROM_IMAGE
when defining a function from a Docker image. NOTE: If you specify your source code as inline text by specifying the ZipFile property within the Code property, specify index.function_name as the handler.runtime (
Runtime
) – The runtime environment for the Lambda function that you are uploading. For valid values, see the Runtime property in the AWS Lambda Developer Guide. UseRuntime.FROM_IMAGE
when when defining a function from a Docker image.allow_all_outbound (
Optional
[bool
]) – Whether to allow the Lambda to send all network traffic. If set to false, you must individually add traffic rules to allow the Lambda to connect to network targets. Default: trueallow_public_subnet (
Optional
[bool
]) – Lambda Functions in a public subnet can NOT access the internet. Use this property to acknowledge this limitation and still place the function in a public subnet. Default: falsearchitecture (
Optional
[Architecture
]) – The system architectures compatible with this lambda function. Default: Architecture.X86_64architectures (
Optional
[Sequence
[Architecture
]]) – (deprecated) DEPRECATED. Default: [Architecture.X86_64]code_signing_config (
Optional
[ICodeSigningConfig
]) – Code signing config associated with this function. Default: - Not Sign the Codecurrent_version_options (
Union
[VersionOptions
,Dict
[str
,Any
],None
]) – Options for thelambda.Version
resource automatically created by thefn.currentVersion
method. Default: - default options as described inVersionOptions
dead_letter_queue (
Optional
[IQueue
]) – The SQS queue to use if DLQ is enabled. If SNS topic is desired, specifydeadLetterTopic
property instead. Default: - SQS queue with 14 day retention period ifdeadLetterQueueEnabled
istrue
dead_letter_queue_enabled (
Optional
[bool
]) – Enabled DLQ. IfdeadLetterQueue
is undefined, an SQS queue with default options will be defined for your Function. Default: - false unlessdeadLetterQueue
is set, which implies DLQ is enabled.dead_letter_topic (
Optional
[ITopic
]) – The SNS topic to use as a DLQ. Note that ifdeadLetterQueueEnabled
is set totrue
, an SQS queue will be created rather than an SNS topic. Using an SNS topic as a DLQ requires this property to be set explicitly. Default: - no SNS topicdescription (
Optional
[str
]) – A description of the function. Default: - No description.environment (
Optional
[Mapping
[str
,str
]]) – Key-value pairs that Lambda caches and makes available for your Lambda functions. Use environment variables to apply configuration changes, such as test and production environment configurations, without changing your Lambda function source code. Default: - No environment variables.environment_encryption (
Optional
[IKey
]) – The AWS KMS key that’s used to encrypt your function’s environment variables. Default: - AWS Lambda creates and uses an AWS managed customer master key (CMK).ephemeral_storage_size (
Optional
[Size
]) – The size of the function’s /tmp directory in MiB. Default: 512 MiBevents (
Optional
[Sequence
[IEventSource
]]) – Event sources for this function. You can also add event sources usingaddEventSource
. Default: - No event sources.filesystem (
Optional
[FileSystem
]) – The filesystem configuration for the lambda function. Default: - will not mount any filesystemfunction_name (
Optional
[str
]) – A name for the function. Default: - AWS CloudFormation generates a unique physical ID and uses that ID for the function’s name. For more information, see Name Type.initial_policy (
Optional
[Sequence
[PolicyStatement
]]) – Initial policy statements to add to the created Lambda Role. You can calladdToRolePolicy
to the created lambda to add statements post creation. Default: - No policy statements are added to the created Lambda role.insights_version (
Optional
[LambdaInsightsVersion
]) – Specify the version of CloudWatch Lambda insights to use for monitoring. Default: - No Lambda Insightslayers (
Optional
[Sequence
[ILayerVersion
]]) – A list of layers to add to the function’s execution environment. You can configure your Lambda function to pull in additional code during initialization in the form of layers. Layers are packages of libraries or other dependencies that can be used by multiple functions. Default: - No layers.log_retention (
Optional
[RetentionDays
]) – The number of days log events are kept in CloudWatch Logs. When updating this property, unsetting it doesn’t remove the log retention policy. To remove the retention policy, set the value toINFINITE
. Default: logs.RetentionDays.INFINITElog_retention_retry_options (
Union
[LogRetentionRetryOptions
,Dict
[str
,Any
],None
]) – When log retention is specified, a custom resource attempts to create the CloudWatch log group. These options control the retry policy when interacting with CloudWatch APIs. Default: - Default AWS SDK retry options.log_retention_role (
Optional
[IRole
]) – The IAM role for the Lambda function associated with the custom resource that sets the retention policy. Default: - A new role is created.memory_size (
Union
[int
,float
,None
]) – The amount of memory, in MB, that is allocated to your Lambda function. Lambda uses this value to proportionally allocate the amount of CPU power. For more information, see Resource Model in the AWS Lambda Developer Guide. Default: 128profiling (
Optional
[bool
]) – Enable profiling. Default: - No profiling.profiling_group (
Optional
[IProfilingGroup
]) – Profiling Group. Default: - A new profiling group will be created ifprofiling
is set.reserved_concurrent_executions (
Union
[int
,float
,None
]) – The maximum of concurrent executions you want to reserve for the function. Default: - No specific limit - account limit.role (
Optional
[IRole
]) – Lambda execution role. This is the role that will be assumed by the function upon execution. It controls the permissions that the function will have. The Role must be assumable by the ‘lambda.amazonaws.com’ service principal. The default Role automatically has permissions granted for Lambda execution. If you provide a Role, you must add the relevant AWS managed policies yourself. The relevant managed policies are “service-role/AWSLambdaBasicExecutionRole” and “service-role/AWSLambdaVPCAccessExecutionRole”. Default: - A unique role will be generated for this lambda function. Both supplied and generated roles can always be changed by callingaddToRolePolicy
.security_group (
Optional
[ISecurityGroup
]) – (deprecated) What security group to associate with the Lambda’s network interfaces. This property is being deprecated, consider using securityGroups instead. Only used if ‘vpc’ is supplied. Use securityGroups property instead. Function constructor will throw an error if both are specified. Default: - If the function is placed within a VPC and a security group is not specified, either by this or securityGroups prop, a dedicated security group will be created for this function.security_groups (
Optional
[Sequence
[ISecurityGroup
]]) – The list of security groups to associate with the Lambda’s network interfaces. Only used if ‘vpc’ is supplied. Default: - If the function is placed within a VPC and a security group is not specified, either by this or securityGroup prop, a dedicated security group will be created for this function.timeout (
Optional
[Duration
]) – The function execution time (in seconds) after which Lambda terminates the function. Because the execution time affects cost, set this value based on the function’s expected execution time. Default: Duration.seconds(3)tracing (
Optional
[Tracing
]) – Enable AWS X-Ray Tracing for Lambda Function. Default: Tracing.Disabledvpc (
Optional
[IVpc
]) – VPC network to place Lambda network interfaces. Specify this if the Lambda function needs to access resources in a VPC. Default: - Function is not placed within a VPC.vpc_subnets (
Union
[SubnetSelection
,Dict
[str
,Any
],None
]) – Where to place the network interfaces within the VPC. Only used if ‘vpc’ is supplied. Note: internet access for Lambdas requires a NAT gateway, so picking Public subnets is not allowed. Default: - the Vpc default strategy if not specifiedmax_event_age (
Optional
[Duration
]) – The maximum age of a request that Lambda sends to a function for processing. Minimum: 60 seconds Maximum: 6 hours Default: Duration.hours(6)on_failure (
Optional
[IDestination
]) – The destination for failed invocations. Default: - no destinationon_success (
Optional
[IDestination
]) – The destination for successful invocations. Default: - no destinationretry_attempts (
Union
[int
,float
,None
]) – The maximum number of times to retry when the function returns an error. Minimum: 0 Maximum: 2 Default: 2
Methods
- add_dependency(*up)
Using node.addDependency() does not work on this method as the underlying lambda function is modeled as a singleton across the stack. Use this method instead to declare dependencies.
- Parameters:
up (
IDependable
)- Return type:
None
- add_environment(key, value, *, remove_in_edge=None)
Adds an environment variable to this Lambda function.
If this is a ref to a Lambda function, this operation results in a no-op.
- Parameters:
key (
str
) – The environment variable key.value (
str
) – The environment variable’s value.remove_in_edge (
Optional
[bool
]) – When used in Lambda@Edge via edgeArn() API, these environment variables will be removed. If not set, an error will be thrown. Default: false - using the function in Lambda
- Return type:
- add_event_source(source)
Adds an event source to this function.
Event sources are implemented in the @aws-cdk/aws-lambda-event-sources module.
The following example adds an SQS Queue as an event source:
import { SqsEventSource } from '@aws-cdk/aws-lambda-event-sources'; myFunction.addEventSource(new SqsEventSource(myQueue));
- Parameters:
source (
IEventSource
)- Return type:
None
- add_event_source_mapping(id, *, batch_size=None, bisect_batch_on_error=None, enabled=None, event_source_arn=None, kafka_bootstrap_servers=None, kafka_topic=None, max_batching_window=None, max_record_age=None, on_failure=None, parallelization_factor=None, report_batch_item_failures=None, retry_attempts=None, source_access_configurations=None, starting_position=None, tumbling_window=None)
Adds an event source that maps to this AWS Lambda function.
- Parameters:
id (
str
)batch_size (
Union
[int
,float
,None
]) – The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records. Valid Range: Minimum value of 1. Maximum value of 10000. Default: - Amazon Kinesis, Amazon DynamoDB, and Amazon MSK is 100 records. The default for Amazon SQS is 10 messages. For standard SQS queues, the maximum is 10,000. For FIFO SQS queues, the maximum is 10.bisect_batch_on_error (
Optional
[bool
]) – If the function returns an error, split the batch in two and retry. Default: falseenabled (
Optional
[bool
]) – Set to false to disable the event source upon creation. Default: trueevent_source_arn (
Optional
[str
]) – The Amazon Resource Name (ARN) of the event source. Any record added to this stream can invoke the Lambda function. Default: - not set if using a self managed Kafka cluster, throws an error otherwisekafka_bootstrap_servers (
Optional
[Sequence
[str
]]) – A list of host and port pairs that are the addresses of the Kafka brokers in a self managed “bootstrap” Kafka cluster that a Kafka client connects to initially to bootstrap itself. They are in the formatabc.example.com:9096
. Default: - nonekafka_topic (
Optional
[str
]) – The name of the Kafka topic. Default: - no topicmax_batching_window (
Optional
[Duration
]) – The maximum amount of time to gather records before invoking the function. Maximum of Duration.minutes(5) Default: Duration.seconds(0)max_record_age (
Optional
[Duration
]) – The maximum age of a record that Lambda sends to a function for processing. Valid Range: - Minimum value of 60 seconds - Maximum value of 7 days Default: - infinite or until the record expires.on_failure (
Optional
[IEventSourceDlq
]) – An Amazon SQS queue or Amazon SNS topic destination for discarded records. Default: discarded records are ignoredparallelization_factor (
Union
[int
,float
,None
]) – The number of batches to process from each shard concurrently. Valid Range: - Minimum value of 1 - Maximum value of 10 Default: 1report_batch_item_failures (
Optional
[bool
]) – Allow functions to return partially successful responses for a batch of records. Default: falseretry_attempts (
Union
[int
,float
,None
]) – The maximum number of times to retry when the function returns an error. Set toundefined
if you want lambda to keep retrying infinitely or until the record expires. Valid Range: - Minimum value of 0 - Maximum value of 10000 Default: - infinite or until the record expires.source_access_configurations (
Optional
[Sequence
[Union
[SourceAccessConfiguration
,Dict
[str
,Any
]]]]) – Specific settings like the authentication protocol or the VPC components to secure access to your event source. Default: - nonestarting_position (
Optional
[StartingPosition
]) – The position in the DynamoDB, Kinesis or MSK stream where AWS Lambda should start reading. Default: - Required for Amazon Kinesis, Amazon DynamoDB, and Amazon MSK Streams sources.tumbling_window (
Optional
[Duration
]) – The size of the tumbling windows to group records sent to DynamoDB or Kinesis. Default: - None
- Return type:
- add_function_url(*, auth_type=None, cors=None)
Adds a url to this lambda function.
- Parameters:
auth_type (
Optional
[FunctionUrlAuthType
]) – The type of authentication that your function URL uses. Default: FunctionUrlAuthType.AWS_IAMcors (
Union
[FunctionUrlCorsOptions
,Dict
[str
,Any
],None
]) – The cross-origin resource sharing (CORS) settings for your function URL. Default: - No CORS configuration.
- Return type:
- add_layers(*layers)
Adds one or more Lambda Layers to this Lambda function.
- Parameters:
layers (
ILayerVersion
) – the layers to be added.- Throws:
if there are already 5 layers on this function, or the layer is incompatible with this function’s runtime.
- Return type:
None
- add_permission(name, *, principal, action=None, event_source_token=None, function_url_auth_type=None, scope=None, source_account=None, source_arn=None)
Adds a permission to the Lambda resource policy.
- Parameters:
name (
str
)principal (
IPrincipal
) – The entity for which you are granting permission to invoke the Lambda function. This entity can be any valid AWS service principal, such as s3.amazonaws.com or sns.amazonaws.com, or, if you are granting cross-account permission, an AWS account ID. For example, you might want to allow a custom application in another AWS account to push events to Lambda by invoking your function. The principal can be either an AccountPrincipal or a ServicePrincipal.action (
Optional
[str
]) – The Lambda actions that you want to allow in this statement. For example, you can specify lambda:CreateFunction to specify a certain action, or use a wildcard (lambda:*
) to grant permission to all Lambda actions. For a list of actions, see Actions and Condition Context Keys for AWS Lambda in the IAM User Guide. Default: ‘lambda:InvokeFunction’event_source_token (
Optional
[str
]) – A unique token that must be supplied by the principal invoking the function. Default: The caller would not need to present a token.function_url_auth_type (
Optional
[FunctionUrlAuthType
]) – The authType for the function URL that you are granting permissions for. Default: - No functionUrlAuthTypescope (
Optional
[Construct
]) – The scope to which the permission constructs be attached. The default is the Lambda function construct itself, but this would need to be different in cases such as cross-stack references where the Permissions would need to sit closer to the consumer of this permission (i.e., the caller). Default: - The instance of lambda.IFunctionsource_account (
Optional
[str
]) – The AWS account ID (without hyphens) of the source owner. For example, if you specify an S3 bucket in the SourceArn property, this value is the bucket owner’s account ID. You can use this property to ensure that all source principals are owned by a specific account.source_arn (
Optional
[str
]) – The ARN of a resource that is invoking your function. When granting Amazon Simple Storage Service (Amazon S3) permission to invoke your function, specify this property with the bucket ARN as its value. This ensures that events generated only from the specified bucket, not just any bucket from any AWS account that creates a mapping to your function, can invoke the function.
- Return type:
None
- add_to_role_policy(statement)
Adds a statement to the IAM role assumed by the instance.
- Parameters:
statement (
PolicyStatement
)- Return type:
None
- apply_removal_policy(policy)
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
RemovalPolicy
)- Return type:
None
- configure_async_invoke(*, max_event_age=None, on_failure=None, on_success=None, retry_attempts=None)
Configures options for asynchronous invocation.
- Parameters:
max_event_age (
Optional
[Duration
]) – The maximum age of a request that Lambda sends to a function for processing. Minimum: 60 seconds Maximum: 6 hours Default: Duration.hours(6)on_failure (
Optional
[IDestination
]) – The destination for failed invocations. Default: - no destinationon_success (
Optional
[IDestination
]) – The destination for successful invocations. Default: - no destinationretry_attempts (
Union
[int
,float
,None
]) – The maximum number of times to retry when the function returns an error. Minimum: 0 Maximum: 2 Default: 2
- Return type:
None
- consider_warning_on_invoke_function_permissions(scope, action)
A warning will be added to functions under the following conditions: - permissions that include
lambda:InvokeFunction
are added to the unqualified function.function.currentVersion is invoked before or after the permission is created.
This applies only to permissions on Lambda functions, not versions or aliases. This function is overridden as a noOp for QualifiedFunctionBase.
- Parameters:
scope (
Construct
)action (
str
)
- Return type:
None
- depend_on(down)
The SingletonFunction construct cannot be added as a dependency of another construct using node.addDependency(). Use this method instead to declare this as a dependency of another construct.
- Parameters:
down (
IConstruct
)- Return type:
None
- grant_invoke(grantee)
Grant the given identity permissions to invoke this Lambda.
- Parameters:
grantee (
IGrantable
)- Return type:
- grant_invoke_url(grantee)
Grant the given identity permissions to invoke this Lambda Function URL.
- Parameters:
grantee (
IGrantable
)- Return type:
- metric(metric_name, *, account=None, color=None, dimensions=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)
Return the given named metric for this Function.
- Parameters:
metric_name (
str
)account (
Optional
[str
]) – Account which this metric comes from. Default: - Deployment account.color (
Optional
[str
]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. TheColor
class has a set of standard colors that can be used here. Default: - Automatic colordimensions (
Optional
[Mapping
[str
,Any
]]) – (deprecated) Dimensions of the metric. Default: - No dimensions.dimensions_map (
Optional
[Mapping
[str
,str
]]) – Dimensions of the metric. Default: - No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No labelperiod (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: - Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream
- Return type:
- metric_duration(*, account=None, color=None, dimensions=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)
How long execution of this Lambda takes.
Average over 5 minutes
- Parameters:
account (
Optional
[str
]) – Account which this metric comes from. Default: - Deployment account.color (
Optional
[str
]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. TheColor
class has a set of standard colors that can be used here. Default: - Automatic colordimensions (
Optional
[Mapping
[str
,Any
]]) – (deprecated) Dimensions of the metric. Default: - No dimensions.dimensions_map (
Optional
[Mapping
[str
,str
]]) – Dimensions of the metric. Default: - No dimensions.label (
Optional
[str
]) –Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label
period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: - Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream
- Return type:
- metric_errors(*, account=None, color=None, dimensions=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)
How many invocations of this Lambda fail.
Sum over 5 minutes
- Parameters:
account (
Optional
[str
]) – Account which this metric comes from. Default: - Deployment account.color (
Optional
[str
]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. TheColor
class has a set of standard colors that can be used here. Default: - Automatic colordimensions (
Optional
[Mapping
[str
,Any
]]) – (deprecated) Dimensions of the metric. Default: - No dimensions.dimensions_map (
Optional
[Mapping
[str
,str
]]) – Dimensions of the metric. Default: - No dimensions.label (
Optional
[str
]) –Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label
period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: - Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream
- Return type:
- metric_invocations(*, account=None, color=None, dimensions=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)
How often this Lambda is invoked.
Sum over 5 minutes
- Parameters:
account (
Optional
[str
]) – Account which this metric comes from. Default: - Deployment account.color (
Optional
[str
]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. TheColor
class has a set of standard colors that can be used here. Default: - Automatic colordimensions (
Optional
[Mapping
[str
,Any
]]) – (deprecated) Dimensions of the metric. Default: - No dimensions.dimensions_map (
Optional
[Mapping
[str
,str
]]) – Dimensions of the metric. Default: - No dimensions.label (
Optional
[str
]) –Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label
period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: - Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream
- Return type:
- metric_throttles(*, account=None, color=None, dimensions=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)
How often this Lambda is throttled.
Sum over 5 minutes
- Parameters:
account (
Optional
[str
]) – Account which this metric comes from. Default: - Deployment account.color (
Optional
[str
]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. TheColor
class has a set of standard colors that can be used here. Default: - Automatic colordimensions (
Optional
[Mapping
[str
,Any
]]) – (deprecated) Dimensions of the metric. Default: - No dimensions.dimensions_map (
Optional
[Mapping
[str
,str
]]) – Dimensions of the metric. Default: - No dimensions.label (
Optional
[str
]) –Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label
period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: - Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream
- Return type:
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- architecture
The architecture of this Lambda Function.
- connections
Access the Connections object.
Will fail if not a VPC-enabled Lambda Function
- Inheritdoc:
true
- current_version
Returns a
lambda.Version
which represents the current version of this singleton Lambda function. A new version will be created every time the function’s configuration changes.You can specify options for this version using the
currentVersionOptions
prop when initializing thelambda.SingletonFunction
.
- env
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
- function_arn
The ARN fo the function.
- function_name
The name of the function.
- grant_principal
The principal this Lambda Function is running as.
- is_bound_to_vpc
Whether or not this Lambda function was bound to a VPC.
If this is is
false
, trying to access theconnections
object will fail.- Inheritdoc:
true
- latest_version
The
$LATEST
version of this function.Note that this is reference to a non-specific AWS Lambda version, which means the function this version refers to can return different results in different invocations.
To obtain a reference to an explicit version which references the current function configuration, use
lambdaFunction.currentVersion
instead.
- log_group
The LogGroup where the Lambda function’s logs are made available.
If either
logRetention
is set or this property is called, a CloudFormation custom resource is added to the stack that pre-creates the log group as part of the stack deployment, if it already doesn’t exist, and sets the correct log retention period (never expire, by default).Further, if the log group already exists and the
logRetention
is not set, the custom resource will reset the log retention to never expire even if it was configured with a different value.
- node
The construct tree node associated with this construct.
- permissions_node
The construct node where permissions are attached.
- resource_arns_for_grant_invoke
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
- role
The IAM role associated with this function.
Undefined if the function was imported without a role.
- runtime
The runtime environment for the Lambda function.
- stack
The stack in which this resource is defined.
Static Methods
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
)- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct
)- Return type:
bool