Class: AWSCDK::Lambda::SingletonFunction
- Inherits:
-
FunctionBase
- Object
- FunctionBase
- AWSCDK::Lambda::SingletonFunction
- Defined in:
- lambda/singleton_function.rb
Overview
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 lambda_purpose property stay the same
whenever they're declared into the stack.
Class Method Summary collapse
- .jsii_overridable_methods ⇒ Object
-
.PROPERTY_INJECTION_ID ⇒ String
Uniquely identifies this class.
Instance Method Summary collapse
-
#add_dependency(*up) ⇒ void
Using node.addDependency() does not work on this method as the underlying lambda function is modeled as a singleton across the stack.
-
#add_environment(key, value, options = nil) ⇒ AWSCDK::Lambda::Function
Adds an environment variable to this Lambda function.
-
#add_event_source(source) ⇒ void
Adds an event source to this function.
-
#add_event_source_mapping(id, options) ⇒ AWSCDK::Lambda::EventSourceMapping
Adds an event source that maps to this AWS Lambda function.
-
#add_function_url(options = nil) ⇒ AWSCDK::Lambda::FunctionURL
Adds a url to this lambda function.
-
#add_layers(*layers) ⇒ void
Adds one or more Lambda Layers to this Lambda function.
-
#add_metadata(type, data, options = nil) ⇒ void
Use this method to write to the construct tree.
-
#add_permission(name, permission) ⇒ void
Adds a permission to the Lambda resource policy.
-
#add_to_role_policy(statement) ⇒ void
Adds a statement to the IAM role assumed by the instance.
-
#apply_cross_stack_reference_strength(strength) ⇒ void
Override the cross-stack reference strength for this resource.
-
#apply_removal_policy(policy) ⇒ void
Apply the given removal policy to this resource.
-
#architecture ⇒ AWSCDK::Lambda::Architecture
The architecture of this Lambda Function.
-
#can_create_permissions ⇒ Boolean
Whether the addPermission() call adds any permissions.
-
#configure_async_invoke(options) ⇒ void
Configures options for asynchronous invocation.
-
#connections ⇒ AWSCDK::EC2::Connections
Access the Connections object.
-
#consider_warning_on_invoke_function_permissions(scope, action) ⇒ void
A warning will be added to functions under the following conditions: - permissions that include
lambda:InvokeFunctionare added to the unqualified function. -
#construct_name ⇒ String
The name of the singleton function.
-
#current_version ⇒ AWSCDK::Lambda::Version
Returns a
lambda.Versionwhich represents the current version of this singleton Lambda function. -
#depend_on(down) ⇒ void
The SingletonFunction construct cannot be added as a dependency of another construct using node.addDependency().
-
#env ⇒ AWSCDK::Interfaces::ResourceEnvironment
The environment this resource belongs to.
-
#function_arn ⇒ String
The ARN fo the function.
-
#function_name ⇒ String
The name of the function.
-
#function_ref ⇒ AWSCDK::Interfaces::AWSLambda::FunctionReference
A reference to a Function resource.
- #generate_physical_name ⇒ String
-
#get_resource_arn_attribute(arn_attr, arn_components) ⇒ String
Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g.
bucket.bucketArn). -
#get_resource_name_attribute(name_attr) ⇒ String
Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g.
bucket.bucketName). -
#grant_invoke(grantee) ⇒ AWSCDK::IAM::Grant
Grant the given identity permissions to invoke this Lambda.
-
#grant_invoke_composite_principal(composite_principal) ⇒ Array<AWSCDK::IAM::Grant>
Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.
-
#grant_invoke_latest_version(grantee) ⇒ AWSCDK::IAM::Grant
Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.
-
#grant_invoke_url(grantee) ⇒ AWSCDK::IAM::Grant
Grant the given identity permissions to invoke this Lambda Function URL.
-
#grant_invoke_version(grantee, version) ⇒ AWSCDK::IAM::Grant
Grant the given identity permissions to invoke the given version of this Lambda.
-
#grant_principal ⇒ AWSCDK::IAM::IPrincipal
The principal this Lambda Function is running as.
-
#initialize(scope, id, props) ⇒ SingletonFunction
constructor
A new instance of SingletonFunction.
-
#is_bound_to_vpc ⇒ Boolean
Whether or not this Lambda function was bound to a VPC.
-
#latest_version ⇒ AWSCDK::Lambda::IVersion
The
$LATESTversion of this function. -
#log_group ⇒ AWSCDK::Logs::ILogGroup
The LogGroup where the Lambda function's logs are made available.
-
#metric(metric_name, props = nil) ⇒ AWSCDK::CloudWatch::Metric
Return the given named metric for this Function.
-
#metric_duration(props = nil) ⇒ AWSCDK::CloudWatch::Metric
How long execution of this Lambda takes.
-
#metric_errors(props = nil) ⇒ AWSCDK::CloudWatch::Metric
How many invocations of this Lambda fail.
-
#metric_invocations(props = nil) ⇒ AWSCDK::CloudWatch::Metric
How often this Lambda is invoked.
-
#metric_throttles(props = nil) ⇒ AWSCDK::CloudWatch::Metric
How often this Lambda is throttled.
-
#node ⇒ Constructs::Node
The tree node.
-
#permissions_node ⇒ Constructs::Node
The construct node where permissions are attached.
-
#physical_name ⇒ String
Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
-
#resource_arns_for_grant_invoke ⇒ Array<String>
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
-
#role ⇒ AWSCDK::IAM::IRole?
The IAM role associated with this function.
-
#runtime ⇒ AWSCDK::Lambda::Runtime
The runtime environment for the Lambda function.
-
#stack ⇒ AWSCDK::Stack
The stack in which this resource is defined.
-
#tenancy_config ⇒ AWSCDK::Lambda::TenancyConfig?
The tenancy configuration for this function.
-
#to_string ⇒ String
Returns a string representation of this construct.
- #warn_invoke_function_permissions(scope) ⇒ void
-
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Constructor Details
#initialize(scope, id, props) ⇒ SingletonFunction
Returns a new instance of SingletonFunction.
16 17 18 19 20 21 22 |
# File 'lambda/singleton_function.rb', line 16 def initialize(scope, id, props) props = props.is_a?(Hash) ? ::AWSCDK::Lambda::SingletonFunctionProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id") Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLlNpbmdsZXRvbkZ1bmN0aW9uUHJvcHMifQ==")), "props") Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props) end |
Class Method Details
.jsii_overridable_methods ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lambda/singleton_function.rb', line 24 def self.jsii_overridable_methods { :node => { kind: :property, name: "node", is_optional: false }, :env => { kind: :property, name: "env", is_optional: false }, :physical_name => { kind: :property, name: "physicalName", is_optional: false }, :stack => { kind: :property, name: "stack", is_optional: false }, :architecture => { kind: :property, name: "architecture", is_optional: false }, :can_create_permissions => { kind: :property, name: "canCreatePermissions", is_optional: false }, :connections => { kind: :property, name: "connections", is_optional: false }, :function_arn => { kind: :property, name: "functionArn", is_optional: false }, :function_name => { kind: :property, name: "functionName", is_optional: false }, :function_ref => { kind: :property, name: "functionRef", is_optional: false }, :grant_principal => { kind: :property, name: "grantPrincipal", is_optional: false }, :is_bound_to_vpc => { kind: :property, name: "isBoundToVpc", is_optional: false }, :latest_version => { kind: :property, name: "latestVersion", is_optional: false }, :permissions_node => { kind: :property, name: "permissionsNode", is_optional: false }, :resource_arns_for_grant_invoke => { kind: :property, name: "resourceArnsForGrantInvoke", is_optional: false }, :role => { kind: :property, name: "role", is_optional: true }, :tenancy_config => { kind: :property, name: "tenancyConfig", is_optional: true }, :construct_name => { kind: :property, name: "constructName", is_optional: false }, :current_version => { kind: :property, name: "currentVersion", is_optional: false }, :log_group => { kind: :property, name: "logGroup", is_optional: false }, :runtime => { kind: :property, name: "runtime", is_optional: false }, :to_string => { kind: :method, name: "toString", is_optional: false }, :with => { kind: :method, name: "with", is_optional: false }, :apply_cross_stack_reference_strength => { kind: :method, name: "applyCrossStackReferenceStrength", is_optional: false }, :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false }, :generate_physical_name => { kind: :method, name: "generatePhysicalName", is_optional: false }, :get_resource_arn_attribute => { kind: :method, name: "getResourceArnAttribute", is_optional: false }, :get_resource_name_attribute => { kind: :method, name: "getResourceNameAttribute", is_optional: false }, :add_event_source => { kind: :method, name: "addEventSource", is_optional: false }, :add_event_source_mapping => { kind: :method, name: "addEventSourceMapping", is_optional: false }, :add_function_url => { kind: :method, name: "addFunctionUrl", is_optional: false }, :add_permission => { kind: :method, name: "addPermission", is_optional: false }, :add_to_role_policy => { kind: :method, name: "addToRolePolicy", is_optional: false }, :configure_async_invoke => { kind: :method, name: "configureAsyncInvoke", is_optional: false }, :consider_warning_on_invoke_function_permissions => { kind: :method, name: "considerWarningOnInvokeFunctionPermissions", is_optional: false }, :grant_invoke => { kind: :method, name: "grantInvoke", is_optional: false }, :grant_invoke_composite_principal => { kind: :method, name: "grantInvokeCompositePrincipal", is_optional: false }, :grant_invoke_latest_version => { kind: :method, name: "grantInvokeLatestVersion", is_optional: false }, :grant_invoke_url => { kind: :method, name: "grantInvokeUrl", is_optional: false }, :grant_invoke_version => { kind: :method, name: "grantInvokeVersion", is_optional: false }, :metric => { kind: :method, name: "metric", is_optional: false }, :metric_duration => { kind: :method, name: "metricDuration", is_optional: false }, :metric_errors => { kind: :method, name: "metricErrors", is_optional: false }, :metric_invocations => { kind: :method, name: "metricInvocations", is_optional: false }, :metric_throttles => { kind: :method, name: "metricThrottles", is_optional: false }, :warn_invoke_function_permissions => { kind: :method, name: "warnInvokeFunctionPermissions", is_optional: false }, :add_dependency => { kind: :method, name: "addDependency", is_optional: false }, :add_environment => { kind: :method, name: "addEnvironment", is_optional: false }, :add_layers => { kind: :method, name: "addLayers", is_optional: false }, :add_metadata => { kind: :method, name: "addMetadata", is_optional: false }, :depend_on => { kind: :method, name: "dependOn", is_optional: false }, } end |
.PROPERTY_INJECTION_ID ⇒ String
Uniquely identifies this class.
233 234 235 |
# File 'lambda/singleton_function.rb', line 233 def self.PROPERTY_INJECTION_ID() Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_lambda.SingletonFunction", "PROPERTY_INJECTION_ID") end |
Instance Method Details
#add_dependency(*up) ⇒ void
This method returns an undefined value.
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.
582 583 584 585 586 587 |
# File 'lambda/singleton_function.rb', line 582 def add_dependency(*up) up.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklEZXBlbmRhYmxlIn0=")), "up[#{index}]") end jsii_call_method("addDependency", [*up]) end |
#add_environment(key, value, options = nil) ⇒ AWSCDK::Lambda::Function
Adds an environment variable to this Lambda function.
If this is a ref to a Lambda function, this operation results in a no-op.
597 598 599 600 601 602 603 |
# File 'lambda/singleton_function.rb', line 597 def add_environment(key, value, = nil) Jsii::Type.check_type(key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "key") Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "value") = .is_a?(Hash) ? ::AWSCDK::Lambda::EnvironmentOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLkVudmlyb25tZW50T3B0aW9ucyJ9")), "options") unless .nil? jsii_call_method("addEnvironment", [key, value, ]) end |
#add_event_source(source) ⇒ void
This method returns an undefined value.
Adds an event source to this function.
Event sources are implemented in the aws-cdk-lib/aws-lambda-event-sources module.
The following example adds an SQS Queue as an event source:
import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';
myFunction.addEventSource(new SqsEventSource(myQueue));
380 381 382 383 |
# File 'lambda/singleton_function.rb', line 380 def add_event_source(source) Jsii::Type.check_type(source, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklFdmVudFNvdXJjZSJ9")), "source") jsii_call_method("addEventSource", [source]) end |
#add_event_source_mapping(id, options) ⇒ AWSCDK::Lambda::EventSourceMapping
Adds an event source that maps to this AWS Lambda function.
390 391 392 393 394 395 |
# File 'lambda/singleton_function.rb', line 390 def add_event_source_mapping(id, ) Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id") = .is_a?(Hash) ? ::AWSCDK::Lambda::EventSourceMappingOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLkV2ZW50U291cmNlTWFwcGluZ09wdGlvbnMifQ==")), "options") jsii_call_method("addEventSourceMapping", [id, ]) end |
#add_function_url(options = nil) ⇒ AWSCDK::Lambda::FunctionURL
Adds a url to this lambda function.
401 402 403 404 405 |
# File 'lambda/singleton_function.rb', line 401 def add_function_url( = nil) = .is_a?(Hash) ? ::AWSCDK::Lambda::FunctionURLOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLkZ1bmN0aW9uVXJsT3B0aW9ucyJ9")), "options") unless .nil? jsii_call_method("addFunctionUrl", []) end |
#add_layers(*layers) ⇒ void
This method returns an undefined value.
Adds one or more Lambda Layers to this Lambda function.
609 610 611 612 613 614 |
# File 'lambda/singleton_function.rb', line 609 def add_layers(*layers) layers.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklMYXllclZlcnNpb24ifQ==")), "layers[#{index}]") end jsii_call_method("addLayers", [*layers]) end |
#add_metadata(type, data, options = nil) ⇒ void
This method returns an undefined value.
Use this method to write to the construct tree.
The metadata entries are written to the Cloud Assembly Manifest if the tree_metadata property is specified in the props of the App that contains this Construct.
624 625 626 627 628 629 630 |
# File 'lambda/singleton_function.rb', line 624 def (type, data, = nil) Jsii::Type.check_type(type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "type") Jsii::Type.check_type(data, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "data") = .is_a?(Hash) ? ::Constructs::MetadataOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLk1ldGFkYXRhT3B0aW9ucyJ9")), "options") unless .nil? jsii_call_method("addMetadata", [type, data, ]) end |
#add_permission(name, permission) ⇒ void
This method returns an undefined value.
Adds a permission to the Lambda resource policy.
412 413 414 415 416 417 |
# File 'lambda/singleton_function.rb', line 412 def (name, ) Jsii::Type.check_type(name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "name") = .is_a?(Hash) ? ::AWSCDK::Lambda::Permission.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLlBlcm1pc3Npb24ifQ==")), "permission") jsii_call_method("addPermission", [name, ]) end |
#add_to_role_policy(statement) ⇒ void
This method returns an undefined value.
Adds a statement to the IAM role assumed by the instance.
423 424 425 426 |
# File 'lambda/singleton_function.rb', line 423 def add_to_role_policy(statement) Jsii::Type.check_type(statement, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeVN0YXRlbWVudCJ9")), "statement") jsii_call_method("addToRolePolicy", [statement]) end |
#apply_cross_stack_reference_strength(strength) ⇒ void
This method returns an undefined value.
Override the cross-stack reference strength for this resource.
When set, any cross-stack reference to this resource will use the specified
mechanism instead of the global default determined by the
@aws-cdk/core:defaultCrossStackReferences context key. This is useful for
selectively weakening specific references to avoid the "deadly embrace" problem
without changing the app-wide default.
310 311 312 313 |
# File 'lambda/singleton_function.rb', line 310 def apply_cross_stack_reference_strength(strength) Jsii::Type.check_type(strength, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZWZlcmVuY2VTdHJlbmd0aCJ9")), "strength") jsii_call_method("applyCrossStackReferenceStrength", [strength]) end |
#apply_removal_policy(policy) ⇒ void
This method returns an undefined value.
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).
327 328 329 330 |
# File 'lambda/singleton_function.rb', line 327 def apply_removal_policy(policy) Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy") jsii_call_method("applyRemovalPolicy", [policy]) end |
#architecture ⇒ AWSCDK::Lambda::Architecture
The architecture of this Lambda Function.
126 127 128 |
# File 'lambda/singleton_function.rb', line 126 def architecture() jsii_get_property("architecture") end |
#can_create_permissions ⇒ Boolean
Whether the addPermission() call adds any permissions.
True for new Lambdas, false for version $LATEST and imported Lambdas from different accounts.
136 137 138 |
# File 'lambda/singleton_function.rb', line 136 def () jsii_get_property("canCreatePermissions") end |
#configure_async_invoke(options) ⇒ void
This method returns an undefined value.
Configures options for asynchronous invocation.
432 433 434 435 436 |
# File 'lambda/singleton_function.rb', line 432 def configure_async_invoke() = .is_a?(Hash) ? ::AWSCDK::Lambda::EventInvokeConfigOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLkV2ZW50SW52b2tlQ29uZmlnT3B0aW9ucyJ9")), "options") jsii_call_method("configureAsyncInvoke", []) end |
#connections ⇒ AWSCDK::EC2::Connections
Access the Connections object.
Will fail if not a VPC-enabled Lambda Function
145 146 147 |
# File 'lambda/singleton_function.rb', line 145 def connections() jsii_get_property("connections") end |
#consider_warning_on_invoke_function_permissions(scope, action) ⇒ void
This method returns an undefined value.
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.
448 449 450 451 452 |
# File 'lambda/singleton_function.rb', line 448 def (scope, action) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") Jsii::Type.check_type(action, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "action") jsii_call_method("considerWarningOnInvokeFunctionPermissions", [scope, action]) end |
#construct_name ⇒ String
The name of the singleton function.
It acts as a unique ID within its CDK stack.
242 243 244 |
# File 'lambda/singleton_function.rb', line 242 def construct_name() jsii_get_property("constructName") end |
#current_version ⇒ AWSCDK::Lambda::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 current_version_options
prop when initializing the lambda.SingletonFunction.
252 253 254 |
# File 'lambda/singleton_function.rb', line 252 def current_version() jsii_get_property("currentVersion") end |
#depend_on(down) ⇒ void
This method returns an undefined value.
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.
636 637 638 639 |
# File 'lambda/singleton_function.rb', line 636 def depend_on(down) Jsii::Type.check_type(down, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "down") jsii_call_method("dependOn", [down]) end |
#env ⇒ AWSCDK::Interfaces::ResourceEnvironment
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
98 99 100 |
# File 'lambda/singleton_function.rb', line 98 def env() jsii_get_property("env") end |
#function_arn ⇒ String
The ARN fo the function.
152 153 154 |
# File 'lambda/singleton_function.rb', line 152 def function_arn() jsii_get_property("functionArn") end |
#function_name ⇒ String
The name of the function.
159 160 161 |
# File 'lambda/singleton_function.rb', line 159 def function_name() jsii_get_property("functionName") end |
#function_ref ⇒ AWSCDK::Interfaces::AWSLambda::FunctionReference
A reference to a Function resource.
166 167 168 |
# File 'lambda/singleton_function.rb', line 166 def function_ref() jsii_get_property("functionRef") end |
#generate_physical_name ⇒ String
333 334 335 |
# File 'lambda/singleton_function.rb', line 333 def generate_physical_name() jsii_call_method("generatePhysicalName", []) end |
#get_resource_arn_attribute(arn_attr, arn_components) ⇒ String
Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. bucket.bucketArn).
Normally, this token will resolve to arn_attr, but if the resource is
referenced across environments, arn_components will be used to synthesize
a concrete ARN with the resource's physical name. Make sure to reference
this.physicalName in arn_components.
347 348 349 350 351 352 |
# File 'lambda/singleton_function.rb', line 347 def get_resource_arn_attribute(arn_attr, arn_components) Jsii::Type.check_type(arn_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "arnAttr") arn_components = arn_components.is_a?(Hash) ? ::AWSCDK::ARNComponents.new(**arn_components.transform_keys(&:to_sym)) : arn_components Jsii::Type.check_type(arn_components, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Bcm5Db21wb25lbnRzIn0=")), "arnComponents") jsii_call_method("getResourceArnAttribute", [arn_attr, arn_components]) end |
#get_resource_name_attribute(name_attr) ⇒ String
Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. bucket.bucketName).
Normally, this token will resolve to name_attr, but if the resource is
referenced across environments, it will be resolved to this.physicalName,
which will be a concrete name.
362 363 364 365 |
# File 'lambda/singleton_function.rb', line 362 def get_resource_name_attribute(name_attr) Jsii::Type.check_type(name_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "nameAttr") jsii_call_method("getResourceNameAttribute", [name_attr]) end |
#grant_invoke(grantee) ⇒ AWSCDK::IAM::Grant
Grant the given identity permissions to invoke this Lambda.
[disable-awslint:no-grants]
460 461 462 463 |
# File 'lambda/singleton_function.rb', line 460 def grant_invoke(grantee) Jsii::Type.check_type(grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee") jsii_call_method("grantInvoke", [grantee]) end |
#grant_invoke_composite_principal(composite_principal) ⇒ Array<AWSCDK::IAM::Grant>
Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.
[disable-awslint:no-grants]
471 472 473 474 |
# File 'lambda/singleton_function.rb', line 471 def grant_invoke_composite_principal(composite_principal) Jsii::Type.check_type(composite_principal, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLkNvbXBvc2l0ZVByaW5jaXBhbCJ9")), "compositePrincipal") jsii_call_method("grantInvokeCompositePrincipal", [composite_principal]) end |
#grant_invoke_latest_version(grantee) ⇒ AWSCDK::IAM::Grant
Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.
[disable-awslint:no-grants]
482 483 484 485 |
# File 'lambda/singleton_function.rb', line 482 def grant_invoke_latest_version(grantee) Jsii::Type.check_type(grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee") jsii_call_method("grantInvokeLatestVersion", [grantee]) end |
#grant_invoke_url(grantee) ⇒ AWSCDK::IAM::Grant
Grant the given identity permissions to invoke this Lambda Function URL.
[disable-awslint:no-grants]
493 494 495 496 |
# File 'lambda/singleton_function.rb', line 493 def grant_invoke_url(grantee) Jsii::Type.check_type(grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee") jsii_call_method("grantInvokeUrl", [grantee]) end |
#grant_invoke_version(grantee, version) ⇒ AWSCDK::IAM::Grant
Grant the given identity permissions to invoke the given version of this Lambda.
[disable-awslint:no-grants]
505 506 507 508 509 |
# File 'lambda/singleton_function.rb', line 505 def grant_invoke_version(grantee, version) Jsii::Type.check_type(grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee") Jsii::Type.check_type(version, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklWZXJzaW9uIn0=")), "version") jsii_call_method("grantInvokeVersion", [grantee, version]) end |
#grant_principal ⇒ AWSCDK::IAM::IPrincipal
The principal this Lambda Function is running as.
173 174 175 |
# File 'lambda/singleton_function.rb', line 173 def grant_principal() jsii_get_property("grantPrincipal") end |
#is_bound_to_vpc ⇒ Boolean
Whether or not this Lambda function was bound to a VPC.
If this is false, trying to access the connections object will fail.
182 183 184 |
# File 'lambda/singleton_function.rb', line 182 def is_bound_to_vpc() jsii_get_property("isBoundToVpc") end |
#latest_version ⇒ AWSCDK::Lambda::IVersion
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.
196 197 198 |
# File 'lambda/singleton_function.rb', line 196 def latest_version() jsii_get_property("latestVersion") end |
#log_group ⇒ AWSCDK::Logs::ILogGroup
The LogGroup where the Lambda function's logs are made available.
If either log_retention 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 log_retention is not set, the custom resource will reset the log retention
to never expire even if it was configured with a different value.
266 267 268 |
# File 'lambda/singleton_function.rb', line 266 def log_group() jsii_get_property("logGroup") end |
#metric(metric_name, props = nil) ⇒ AWSCDK::CloudWatch::Metric
Return the given named metric for this Function.
516 517 518 519 520 521 |
# File 'lambda/singleton_function.rb', line 516 def metric(metric_name, props = nil) Jsii::Type.check_type(metric_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "metricName") props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil? jsii_call_method("metric", [metric_name, props]) end |
#metric_duration(props = nil) ⇒ AWSCDK::CloudWatch::Metric
How long execution of this Lambda takes.
Average over 5 minutes
529 530 531 532 533 |
# File 'lambda/singleton_function.rb', line 529 def metric_duration(props = nil) props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil? jsii_call_method("metricDuration", [props]) end |
#metric_errors(props = nil) ⇒ AWSCDK::CloudWatch::Metric
How many invocations of this Lambda fail.
Sum over 5 minutes
541 542 543 544 545 |
# File 'lambda/singleton_function.rb', line 541 def metric_errors(props = nil) props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil? jsii_call_method("metricErrors", [props]) end |
#metric_invocations(props = nil) ⇒ AWSCDK::CloudWatch::Metric
How often this Lambda is invoked.
Sum over 5 minutes
553 554 555 556 557 |
# File 'lambda/singleton_function.rb', line 553 def metric_invocations(props = nil) props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil? jsii_call_method("metricInvocations", [props]) end |
#metric_throttles(props = nil) ⇒ AWSCDK::CloudWatch::Metric
How often this Lambda is throttled.
Sum over 5 minutes
565 566 567 568 569 |
# File 'lambda/singleton_function.rb', line 565 def metric_throttles(props = nil) props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil? jsii_call_method("metricThrottles", [props]) end |
#node ⇒ Constructs::Node
The tree node.
83 84 85 |
# File 'lambda/singleton_function.rb', line 83 def node() jsii_get_property("node") end |
#permissions_node ⇒ Constructs::Node
The construct node where permissions are attached.
203 204 205 |
# File 'lambda/singleton_function.rb', line 203 def () jsii_get_property("permissionsNode") end |
#physical_name ⇒ String
Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
This value will resolve to one of the following:
- a concrete value (e.g.
"my-awesome-bucket") undefined, when a name should be generated by CloudFormation- a concrete name generated automatically during synthesis, in cross-environment scenarios.
112 113 114 |
# File 'lambda/singleton_function.rb', line 112 def physical_name() jsii_get_property("physicalName") end |
#resource_arns_for_grant_invoke ⇒ Array<String>
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
210 211 212 |
# File 'lambda/singleton_function.rb', line 210 def resource_arns_for_grant_invoke() jsii_get_property("resourceArnsForGrantInvoke") end |
#role ⇒ AWSCDK::IAM::IRole?
The IAM role associated with this function.
Undefined if the function was imported without a role.
219 220 221 |
# File 'lambda/singleton_function.rb', line 219 def role() jsii_get_property("role") end |
#runtime ⇒ AWSCDK::Lambda::Runtime
The runtime environment for the Lambda function.
273 274 275 |
# File 'lambda/singleton_function.rb', line 273 def runtime() jsii_get_property("runtime") end |
#stack ⇒ AWSCDK::Stack
The stack in which this resource is defined.
119 120 121 |
# File 'lambda/singleton_function.rb', line 119 def stack() jsii_get_property("stack") end |
#tenancy_config ⇒ AWSCDK::Lambda::TenancyConfig?
The tenancy configuration for this function.
226 227 228 |
# File 'lambda/singleton_function.rb', line 226 def tenancy_config() jsii_get_property("tenancyConfig") end |
#to_string ⇒ String
Returns a string representation of this construct.
280 281 282 |
# File 'lambda/singleton_function.rb', line 280 def to_string() jsii_call_method("toString", []) end |
#warn_invoke_function_permissions(scope) ⇒ void
This method returns an undefined value.
573 574 575 576 |
# File 'lambda/singleton_function.rb', line 573 def (scope) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") jsii_call_method("warnInvokeFunctionPermissions", [scope]) end |
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
293 294 295 296 297 298 |
# File 'lambda/singleton_function.rb', line 293 def with(*mixins) mixins.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]") end jsii_call_method("with", [*mixins]) end |