Class FunctionBase

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.lambda.FunctionBase
All Implemented Interfaces:
IConstruct, IDependable, IResource, IClientVpnConnectionHandler, IConnectable, IGrantable, IFunction, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct
Direct Known Subclasses:
Function, QualifiedFunctionBase, SingletonFunction

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:40.746Z") @Stability(Stable) public abstract class FunctionBase extends Resource implements IFunction, IClientVpnConnectionHandler
  • Constructor Details

    • FunctionBase

      protected FunctionBase(software.amazon.jsii.JsiiObjectRef objRef)
    • FunctionBase

      protected FunctionBase(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • FunctionBase

      @Stability(Stable) protected FunctionBase(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable ResourceProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props -
    • FunctionBase

      @Stability(Stable) protected FunctionBase(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
  • Method Details

    • addEventSource

      @Stability(Stable) public void addEventSource(@NotNull IEventSource 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));
       

      Specified by:
      addEventSource in interface IFunction
      Parameters:
      source - This parameter is required.
    • addEventSourceMapping

      @Stability(Stable) @NotNull public EventSourceMapping addEventSourceMapping(@NotNull String id, @NotNull EventSourceMappingOptions options)
      Adds an event source that maps to this AWS Lambda function.

      Specified by:
      addEventSourceMapping in interface IFunction
      Parameters:
      id - This parameter is required.
      options - This parameter is required.
    • addFunctionUrl

      @Stability(Stable) @NotNull public FunctionUrl addFunctionUrl(@Nullable FunctionUrlOptions options)
      Adds a url to this lambda function.

      Specified by:
      addFunctionUrl in interface IFunction
      Parameters:
      options -
    • addFunctionUrl

      @Stability(Stable) @NotNull public FunctionUrl addFunctionUrl()
      Adds a url to this lambda function.
      Specified by:
      addFunctionUrl in interface IFunction
    • addPermission

      @Stability(Stable) public void addPermission(@NotNull String id, @NotNull Permission permission)
      Adds a permission to the Lambda resource policy.

      Specified by:
      addPermission in interface IFunction
      Parameters:
      id - The id for the permission construct. This parameter is required.
      permission - The permission to grant to this Lambda function. This parameter is required.
      See Also:
    • addToRolePolicy

      @Stability(Stable) public void addToRolePolicy(@NotNull PolicyStatement statement)
      Adds a statement to the IAM role assumed by the instance.

      Specified by:
      addToRolePolicy in interface IFunction
      Parameters:
      statement - This parameter is required.
    • configureAsyncInvoke

      @Stability(Stable) public void configureAsyncInvoke(@NotNull EventInvokeConfigOptions options)
      Configures options for asynchronous invocation.

      Specified by:
      configureAsyncInvoke in interface IFunction
      Parameters:
      options - This parameter is required.
    • considerWarningOnInvokeFunctionPermissions

      @Stability(Stable) public void considerWarningOnInvokeFunctionPermissions(@NotNull Construct scope, @NotNull String 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 - This parameter is required.
      action - This parameter is required.
    • grantInvoke

      @Stability(Stable) @NotNull public Grant grantInvoke(@NotNull IGrantable grantee)
      Grant the given identity permissions to invoke this Lambda.

      Specified by:
      grantInvoke in interface IFunction
      Parameters:
      grantee - This parameter is required.
    • grantInvokeUrl

      @Stability(Stable) @NotNull public Grant grantInvokeUrl(@NotNull IGrantable grantee)
      Grant the given identity permissions to invoke this Lambda Function URL.

      Specified by:
      grantInvokeUrl in interface IFunction
      Parameters:
      grantee - This parameter is required.
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props)
      Return the given named metric for this Function.

      Specified by:
      metric in interface IFunction
      Parameters:
      metricName - This parameter is required.
      props -
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName)
      Return the given named metric for this Function.

      Specified by:
      metric in interface IFunction
      Parameters:
      metricName - This parameter is required.
    • metricDuration

      @Stability(Stable) @NotNull public Metric metricDuration(@Nullable MetricOptions props)
      How long execution of this Lambda takes.

      Average over 5 minutes

      Specified by:
      metricDuration in interface IFunction
      Parameters:
      props -
    • metricDuration

      @Stability(Stable) @NotNull public Metric metricDuration()
      How long execution of this Lambda takes.

      Average over 5 minutes

      Specified by:
      metricDuration in interface IFunction
    • metricErrors

      @Stability(Stable) @NotNull public Metric metricErrors(@Nullable MetricOptions props)
      How many invocations of this Lambda fail.

      Sum over 5 minutes

      Specified by:
      metricErrors in interface IFunction
      Parameters:
      props -
    • metricErrors

      @Stability(Stable) @NotNull public Metric metricErrors()
      How many invocations of this Lambda fail.

      Sum over 5 minutes

      Specified by:
      metricErrors in interface IFunction
    • metricInvocations

      @Stability(Stable) @NotNull public Metric metricInvocations(@Nullable MetricOptions props)
      How often this Lambda is invoked.

      Sum over 5 minutes

      Specified by:
      metricInvocations in interface IFunction
      Parameters:
      props -
    • metricInvocations

      @Stability(Stable) @NotNull public Metric metricInvocations()
      How often this Lambda is invoked.

      Sum over 5 minutes

      Specified by:
      metricInvocations in interface IFunction
    • metricThrottles

      @Stability(Stable) @NotNull public Metric metricThrottles(@Nullable MetricOptions props)
      How often this Lambda is throttled.

      Sum over 5 minutes

      Specified by:
      metricThrottles in interface IFunction
      Parameters:
      props -
    • metricThrottles

      @Stability(Stable) @NotNull public Metric metricThrottles()
      How often this Lambda is throttled.

      Sum over 5 minutes

      Specified by:
      metricThrottles in interface IFunction
    • warnInvokeFunctionPermissions

      @Stability(Stable) protected void warnInvokeFunctionPermissions(@NotNull Construct scope)
      Parameters:
      scope - This parameter is required.
    • getArchitecture

      @Stability(Stable) @NotNull public abstract Architecture getArchitecture()
      The architecture of this Lambda Function.
      Specified by:
      getArchitecture in interface IFunction
    • getCanCreatePermissions

      @Stability(Stable) @NotNull protected abstract Boolean getCanCreatePermissions()
      Whether the addPermission() call adds any permissions.

      True for new Lambdas, false for version $LATEST and imported Lambdas from different accounts.

    • getConnections

      @Stability(Stable) @NotNull public Connections getConnections()
      Access the Connections object.

      Will fail if not a VPC-enabled Lambda Function

      Specified by:
      getConnections in interface IConnectable
    • getFunctionArn

      @Stability(Stable) @NotNull public abstract String getFunctionArn()
      The ARN fo the function.
      Specified by:
      getFunctionArn in interface IClientVpnConnectionHandler
      Specified by:
      getFunctionArn in interface IFunction
    • getFunctionName

      @Stability(Stable) @NotNull public abstract String getFunctionName()
      The name of the function.
      Specified by:
      getFunctionName in interface IClientVpnConnectionHandler
      Specified by:
      getFunctionName in interface IFunction
    • getGrantPrincipal

      @Stability(Stable) @NotNull public abstract IPrincipal getGrantPrincipal()
      The principal this Lambda Function is running as.
      Specified by:
      getGrantPrincipal in interface IGrantable
    • getIsBoundToVpc

      @Stability(Stable) @NotNull public Boolean getIsBoundToVpc()
      Whether or not this Lambda function was bound to a VPC.

      If this is is false, trying to access the connections object will fail.

      Specified by:
      getIsBoundToVpc in interface IFunction
    • getLatestVersion

      @Stability(Stable) @NotNull public IVersion getLatestVersion()
      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.

      Specified by:
      getLatestVersion in interface IFunction
    • getPermissionsNode

      @Stability(Stable) @NotNull public abstract ConstructNode getPermissionsNode()
      The construct node where permissions are attached.
      Specified by:
      getPermissionsNode in interface IFunction
    • getResourceArnsForGrantInvoke

      @Stability(Stable) @NotNull public abstract List<String> getResourceArnsForGrantInvoke()
      The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
      Specified by:
      getResourceArnsForGrantInvoke in interface IFunction
    • getRole

      @Stability(Stable) @Nullable public abstract IRole getRole()
      The IAM role associated with this function.

      Undefined if the function was imported without a role.

      Specified by:
      getRole in interface IFunction