Class SingletonFunction
A Lambda that will only ever be added to a stack once.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.Lambda
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class SingletonFunction : FunctionBase, IFunction, IResource, IConnectable, IGrantable, IClientVpnConnectionHandler
Syntax (vb)
Public Class SingletonFunction
Inherits FunctionBase
Implements IFunction, IResource, IConnectable, IGrantable, IClientVpnConnectionHandler
Remarks
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.
Resource: AWS::Lambda::Function
ExampleMetadata: infused
Examples
var fn = new SingletonFunction(this, "MyProvider", functionProps);
new CustomResource(this, "MyResource", new CustomResourceProps {
ServiceToken = fn.FunctionArn
});
Synopsis
Constructors
SingletonFunction(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
SingletonFunction(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
SingletonFunction(Construct, String, ISingletonFunctionProps) |
Properties
Architecture | The architecture of this Lambda Function. |
CanCreatePermissions | Whether the addPermission() call adds any permissions. |
Connections | Access the Connections object. |
CurrentVersion | Returns a |
FunctionArn | The ARN fo the function. |
FunctionName | The name of the function. |
GrantPrincipal | The principal this Lambda Function is running as. |
IsBoundToVpc | Whether or not this Lambda function was bound to a VPC. |
LogGroup | The LogGroup where the Lambda function's logs are made available. |
PermissionsNode | The construct node where permissions are attached. |
ResourceArnsForGrantInvoke | The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). |
Role | The IAM role associated with this function. |
Runtime | The runtime environment for the Lambda function. |
Methods
AddDependency(IDependable[]) | 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. |
AddEnvironment(String, String, IEnvironmentOptions) | Adds an environment variable to this Lambda function. |
AddLayers(ILayerVersion[]) | Adds one or more Lambda Layers to this Lambda function. |
AddPermission(String, IPermission) | Adds a permission to the Lambda resource policy. |
DependOn(IConstruct) | 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. |
Constructors
SingletonFunction(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected SingletonFunction(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
SingletonFunction(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected SingletonFunction(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
SingletonFunction(Construct, String, ISingletonFunctionProps)
public SingletonFunction(Construct scope, string id, ISingletonFunctionProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props ISingletonFunctionProps
Properties
Architecture
The architecture of this Lambda Function.
public override Architecture Architecture { get; }
Property Value
Overrides
CanCreatePermissions
Whether the addPermission() call adds any permissions.
protected override bool CanCreatePermissions { get; }
Property Value
System.Boolean
Overrides
Remarks
True for new Lambdas, false for version $LATEST and imported Lambdas from different accounts.
Connections
Access the Connections object.
public override Connections_ Connections { get; }
Property Value
Overrides
Remarks
Will fail if not a VPC-enabled Lambda Function
Inheritdoc: true
CurrentVersion
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.
public virtual Version_ CurrentVersion { get; }
Property Value
Remarks
You can specify options for this version using the currentVersionOptions
prop when initializing the lambda.SingletonFunction
.
FunctionArn
The ARN fo the function.
public override string FunctionArn { get; }
Property Value
System.String
Overrides
FunctionName
The name of the function.
public override string FunctionName { get; }
Property Value
System.String
Overrides
GrantPrincipal
The principal this Lambda Function is running as.
public override IPrincipal GrantPrincipal { get; }
Property Value
Overrides
IsBoundToVpc
Whether or not this Lambda function was bound to a VPC.
public override bool IsBoundToVpc { get; }
Property Value
System.Boolean
Overrides
Remarks
If this is is false
, trying to access the connections
object will fail.
Inheritdoc: true
LogGroup
The LogGroup where the Lambda function's logs are made available.
public virtual ILogGroup LogGroup { get; }
Property Value
Remarks
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.
PermissionsNode
The construct node where permissions are attached.
public override Node PermissionsNode { get; }
Property Value
Constructs.Node
Overrides
ResourceArnsForGrantInvoke
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
public override string[] ResourceArnsForGrantInvoke { get; }
Property Value
System.String[]
Overrides
Role
The IAM role associated with this function.
public override IRole Role { get; }
Property Value
Overrides
Remarks
Undefined if the function was imported without a role.
Runtime
The runtime environment for the Lambda function.
public virtual Runtime Runtime { get; }
Property Value
Methods
AddDependency(IDependable[])
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.
public virtual void AddDependency(params IDependable[] up)
Parameters
- up Constructs.IDependable[]
AddEnvironment(String, String, IEnvironmentOptions)
Adds an environment variable to this Lambda function.
public virtual Function AddEnvironment(string key, string value, IEnvironmentOptions options = null)
Parameters
- key System.String
The environment variable key.
- value System.String
The environment variable's value.
- options IEnvironmentOptions
Environment variable options.
Returns
Remarks
If this is a ref to a Lambda function, this operation results in a no-op.
AddLayers(ILayerVersion[])
Adds one or more Lambda Layers to this Lambda function.
public virtual void AddLayers(params ILayerVersion[] layers)
Parameters
- layers ILayerVersion[]
the layers to be added.
Remarks
Throws: if there are already 5 layers on this function, or the layer is incompatible with this function's runtime.
AddPermission(String, IPermission)
Adds a permission to the Lambda resource policy.
public override void AddPermission(string name, IPermission permission)
Parameters
- name System.String
- permission IPermission
Overrides
DependOn(IConstruct)
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.
public virtual void DependOn(IConstruct down)
Parameters
- down Constructs.IConstruct