Class: AWSCDK::Lambda::CfnParametersCode
- Inherits:
-
Code
- Object
- Code
- AWSCDK::Lambda::CfnParametersCode
- Defined in:
- lambda/cfn_parameters_code.rb
Overview
Lambda code defined using 2 CloudFormation parameters.
Useful when you don't have access to the code of your Lambda from your CDK code, so you can't use Assets,
and you want to deploy the Lambda in a CodePipeline, using CloudFormation Actions -
you can fill the parameters using the #assign method.
Class Method Summary collapse
Instance Method Summary collapse
-
#assign(location) ⇒ Hash{String => Object}
Create a parameters map from this instance's CloudFormation parameters.
-
#bind(scope) ⇒ AWSCDK::Lambda::CodeConfig
Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.
-
#bind_to_resource(_resource, _options = nil) ⇒ void
Called after the CFN function resource has been created to allow the code class to bind to it.
- #bucket_name_param ⇒ String
-
#initialize(props = nil) ⇒ CfnParametersCode
constructor
A new instance of CfnParametersCode.
-
#is_inline ⇒ Boolean
Determines whether this Code is inline code or not.
- #object_key_param ⇒ String
Constructor Details
#initialize(props = nil) ⇒ CfnParametersCode
Returns a new instance of CfnParametersCode.
13 14 15 16 17 |
# File 'lambda/cfn_parameters_code.rb', line 13 def initialize(props = nil) props = props.is_a?(Hash) ? ::AWSCDK::Lambda::CfnParametersCodeProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLkNmblBhcmFtZXRlcnNDb2RlUHJvcHMifQ==")), "props") unless props.nil? Jsii::Object.instance_method(:initialize).bind(self).call(props) end |
Class Method Details
.jsii_overridable_methods ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lambda/cfn_parameters_code.rb', line 19 def self.jsii_overridable_methods { :bucket_name_param => { kind: :property, name: "bucketNameParam", is_optional: false }, :is_inline => { kind: :property, name: "isInline", is_optional: false }, :object_key_param => { kind: :property, name: "objectKeyParam", is_optional: false }, :bind => { kind: :method, name: "bind", is_optional: false }, :bind_to_resource => { kind: :method, name: "bindToResource", is_optional: false }, :assign => { kind: :method, name: "assign", is_optional: false }, } end |
Instance Method Details
#assign(location) ⇒ Hash{String => Object}
Create a parameters map from this instance's CloudFormation parameters.
It returns a map with 2 keys that correspond to the names of the parameters defined in this Lambda code,
and as values it contains the appropriate expressions pointing at the provided S3 location
(most likely, obtained from a CodePipeline Artifact by calling the artifact.s3Location method).
The result should be provided to the CloudFormation Action
that is deploying the Stack that the Lambda with this code is part of,
in the parameter_overrides property.
82 83 84 85 86 |
# File 'lambda/cfn_parameters_code.rb', line 82 def assign(location) location = location.is_a?(Hash) ? ::AWSCDK::S3::Location.new(**location.transform_keys(&:to_sym)) : location Jsii::Type.check_type(location, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfczMuTG9jYXRpb24ifQ==")), "location") jsii_call_method("assign", [location]) end |
#bind(scope) ⇒ AWSCDK::Lambda::CodeConfig
Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.
51 52 53 54 |
# File 'lambda/cfn_parameters_code.rb', line 51 def bind(scope) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") jsii_call_method("bind", [scope]) end |
#bind_to_resource(_resource, _options = nil) ⇒ void
This method returns an undefined value.
Called after the CFN function resource has been created to allow the code class to bind to it.
Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.
64 65 66 67 68 69 |
# File 'lambda/cfn_parameters_code.rb', line 64 def bind_to_resource(_resource, = nil) Jsii::Type.check_type(_resource, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DZm5SZXNvdXJjZSJ9")), "_resource") = .is_a?(Hash) ? ::AWSCDK::Lambda::ResourceBindOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLlJlc291cmNlQmluZE9wdGlvbnMifQ==")), "_options") unless .nil? jsii_call_method("bindToResource", [_resource, ]) end |
#bucket_name_param ⇒ String
31 32 33 |
# File 'lambda/cfn_parameters_code.rb', line 31 def bucket_name_param() jsii_get_property("bucketNameParam") end |
#is_inline ⇒ Boolean
Determines whether this Code is inline code or not.
38 39 40 |
# File 'lambda/cfn_parameters_code.rb', line 38 def is_inline() jsii_get_property("isInline") end |
#object_key_param ⇒ String
43 44 45 |
# File 'lambda/cfn_parameters_code.rb', line 43 def object_key_param() jsii_get_property("objectKeyParam") end |