Class SingletonFunction

All Implemented Interfaces:
IConstruct, IDependable, IResource, IClientVpnConnectionHandler, IConnectable, IGrantable, IFunction,, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:40.818Z") @Stability(Stable) public class SingletonFunction extends 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 optional lambdaPurpose property stay the same whenever they're declared into the stack.


 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 Architecture architecture;
 Code code;
 CodeSigningConfig codeSigningConfig;
 IDestination destination;
 IEventSource eventSource;
 FileSystem fileSystem;
 Key key;
 LambdaInsightsVersion lambdaInsightsVersion;
 LayerVersion layerVersion;
 PolicyStatement policyStatement;
 ProfilingGroup profilingGroup;
 Queue queue;
 Role role;
 Runtime runtime;
 SecurityGroup securityGroup;
 Size size;
 Subnet subnet;
 SubnetFilter subnetFilter;
 Topic topic;
 Vpc vpc;
 SingletonFunction singletonFunction = SingletonFunction.Builder.create(this, "MySingletonFunction")
         // the properties below are optional
                 "environmentKey", "environment"))
  • Constructor Details

    • SingletonFunction

      protected SingletonFunction( objRef)
    • SingletonFunction

      protected SingletonFunction( initializationMode)
    • SingletonFunction

      @Stability(Stable) public SingletonFunction(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull SingletonFunctionProps props)
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • addDependency

      @Stability(Stable) public void addDependency(@NotNull @NotNull IDependable... 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.

      up - This parameter is required.
    • addEnvironment

      @Stability(Stable) @NotNull public Function addEnvironment(@NotNull String key, @NotNull String value, @Nullable EnvironmentOptions options)
      Adds an environment variable to this Lambda function.

      If this is a ref to a Lambda function, this operation results in a no-op.

      key - The environment variable key. This parameter is required.
      value - The environment variable's value. This parameter is required.
      options - Environment variable options.
    • addEnvironment

      @Stability(Stable) @NotNull public Function addEnvironment(@NotNull String key, @NotNull String value)
      Adds an environment variable to this Lambda function.

      If this is a ref to a Lambda function, this operation results in a no-op.

      key - The environment variable key. This parameter is required.
      value - The environment variable's value. This parameter is required.
    • addLayers

      @Stability(Stable) public void addLayers(@NotNull @NotNull ILayerVersion... layers)
      Adds one or more Lambda Layers to this Lambda function.

      layers - the layers to be added. This parameter is required.
    • addPermission

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

      Specified by:
      addPermission in interface IFunction
      addPermission in class FunctionBase
      name - This parameter is required.
      permission - This parameter is required.
      See Also:
    • dependOn

      @Stability(Stable) public void dependOn(@NotNull IConstruct 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.

      down - This parameter is required.
    • getArchitecture

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

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

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

      Specified by:
      getCanCreatePermissions in class FunctionBase
    • 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
      getConnections in class FunctionBase
    • getCurrentVersion

      @Stability(Stable) @NotNull public Version getCurrentVersion()
      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 the lambda.SingletonFunction.

    • getFunctionArn

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

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

      @Stability(Stable) @NotNull public IPrincipal getGrantPrincipal()
      The principal this Lambda Function is running as.
      Specified by:
      getGrantPrincipal in interface IGrantable
      Specified by:
      getGrantPrincipal in class FunctionBase
    • 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
      getIsBoundToVpc in class FunctionBase
    • getLogGroup

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

    • getPermissionsNode

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

      @Stability(Stable) @NotNull public 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
      Specified by:
      getResourceArnsForGrantInvoke in class FunctionBase
    • getRuntime

      @Stability(Stable) @NotNull public Runtime getRuntime()
      The runtime environment for the Lambda function.
    • getRole

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

      Undefined if the function was imported without a role.

      Specified by:
      getRole in interface IFunction
      Specified by:
      getRole in class FunctionBase