Class: AWSCDK::CustomResourceProvider
- Inherits:
-
CustomResourceProviderBase
- Object
- CustomResourceProviderBase
- AWSCDK::CustomResourceProvider
- Defined in:
- custom_resource_provider.rb
Overview
An AWS-Lambda backed custom resource provider, for CDK Construct Library constructs.
This is a provider for CustomResource constructs, backed by an AWS Lambda
Function. It only supports NodeJS runtimes.
Application builders do not need to use this provider type. This is not a generic custom resource provider class. It is specifically intended to be used only by constructs in the AWS CDK Construct Library, and only exists here because of reverse dependency issues (for example, it cannot use
iam.PolicyStatementobjects, since theiamlibrary already depends on the CDKcorelibrary and we cannot have cyclic dependencies).
If you are not writing constructs for the AWS Construct Library, you should
use the Provider class in the custom-resources module instead, which has
a better API and supports all Lambda runtimes, not just Node.
N.B.: When you are writing Custom Resource Providers, there are a number of
lifecycle events you have to pay attention to. These are documented in the
README of the custom-resources module. Be sure to give the documentation
in that module a read, regardless of whether you end up using the Provider
class in there or this one.
Class Method Summary collapse
-
.get_or_create(scope, uniqueid, props) ⇒ String
Returns a stack-level singleton ARN (service token) for the custom resource provider.
-
.get_or_create_provider(scope, uniqueid, props) ⇒ AWSCDK::CustomResourceProvider
Returns a stack-level singleton for the custom resource provider.
- .jsii_overridable_methods ⇒ Object
Instance Method Summary collapse
-
#add_to_role_policy(statement) ⇒ void
Add an IAM policy statement to the inline policy of the provider's lambda function's role.
-
#code_hash ⇒ String
The hash of the lambda code backing this provider.
-
#initialize(scope, id, props) ⇒ CustomResourceProvider
constructor
A new instance of CustomResourceProvider.
-
#node ⇒ Constructs::Node
The tree node.
-
#role_arn ⇒ String
The ARN of the provider's AWS Lambda function role.
-
#service_token ⇒ String
The ARN of the provider's AWS Lambda function which should be used as the
serviceTokenwhen defining a custom resource. -
#to_string ⇒ String
Returns a string representation of this construct.
-
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Constructor Details
#initialize(scope, id, props) ⇒ CustomResourceProvider
Returns a new instance of CustomResourceProvider.
31 32 33 34 35 36 37 |
# File 'custom_resource_provider.rb', line 31 def initialize(scope, id, props) props = props.is_a?(Hash) ? ::AWSCDK::CustomResourceProviderProps.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("eyJmcW4iOiJhd3MtY2RrLWxpYi5DdXN0b21SZXNvdXJjZVByb3ZpZGVyUHJvcHMifQ==")), "props") Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props) end |
Class Method Details
.get_or_create(scope, uniqueid, props) ⇒ String
Returns a stack-level singleton ARN (service token) for the custom resource provider.
57 58 59 60 61 62 63 |
# File 'custom_resource_provider.rb', line 57 def self.get_or_create(scope, uniqueid, props) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") Jsii::Type.check_type(uniqueid, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "uniqueid") props = props.is_a?(Hash) ? ::AWSCDK::CustomResourceProviderProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DdXN0b21SZXNvdXJjZVByb3ZpZGVyUHJvcHMifQ==")), "props") Jsii::Kernel.instance.call_static("aws-cdk-lib.CustomResourceProvider", "getOrCreate", [scope, uniqueid, props]) end |
.get_or_create_provider(scope, uniqueid, props) ⇒ AWSCDK::CustomResourceProvider
Returns a stack-level singleton for the custom resource provider.
71 72 73 74 75 76 77 |
# File 'custom_resource_provider.rb', line 71 def self.get_or_create_provider(scope, uniqueid, props) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") Jsii::Type.check_type(uniqueid, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "uniqueid") props = props.is_a?(Hash) ? ::AWSCDK::CustomResourceProviderProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DdXN0b21SZXNvdXJjZVByb3ZpZGVyUHJvcHMifQ==")), "props") Jsii::Kernel.instance.call_static("aws-cdk-lib.CustomResourceProvider", "getOrCreateProvider", [scope, uniqueid, props]) end |
.jsii_overridable_methods ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'custom_resource_provider.rb', line 39 def self.jsii_overridable_methods { :node => { kind: :property, name: "node", is_optional: false }, :code_hash => { kind: :property, name: "codeHash", is_optional: false }, :role_arn => { kind: :property, name: "roleArn", is_optional: false }, :service_token => { kind: :property, name: "serviceToken", is_optional: false }, :to_string => { kind: :method, name: "toString", is_optional: false }, :with => { kind: :method, name: "with", is_optional: false }, :add_to_role_policy => { kind: :method, name: "addToRolePolicy", is_optional: false }, } end |
Instance Method Details
#add_to_role_policy(statement) ⇒ void
This method returns an undefined value.
Add an IAM policy statement to the inline policy of the provider's lambda function's role.
Please note: this is a direct IAM JSON policy blob, not a iam.PolicyStatement
object like you will see in the rest of the CDK.
149 150 151 152 |
# File 'custom_resource_provider.rb', line 149 def add_to_role_policy(statement) Jsii::Type.check_type(statement, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "statement") jsii_call_method("addToRolePolicy", [statement]) end |
#code_hash ⇒ String
The hash of the lambda code backing this provider.
Can be used to trigger updates on code changes, even when the properties of a custom resource remain unchanged.
92 93 94 |
# File 'custom_resource_provider.rb', line 92 def code_hash() jsii_get_property("codeHash") end |
#node ⇒ Constructs::Node
The tree node.
82 83 84 |
# File 'custom_resource_provider.rb', line 82 def node() jsii_get_property("node") end |
#role_arn ⇒ String
The ARN of the provider's AWS Lambda function role.
99 100 101 |
# File 'custom_resource_provider.rb', line 99 def role_arn() jsii_get_property("roleArn") end |
#service_token ⇒ String
The ARN of the provider's AWS Lambda function which should be used as the serviceToken when defining a custom resource.
106 107 108 |
# File 'custom_resource_provider.rb', line 106 def service_token() jsii_get_property("serviceToken") end |
#to_string ⇒ String
Returns a string representation of this construct.
113 114 115 |
# File 'custom_resource_provider.rb', line 113 def to_string() jsii_call_method("toString", []) 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.
126 127 128 129 130 131 |
# File 'custom_resource_provider.rb', line 126 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 |