Class: AWSCDK::EC2::CloudFormationInit
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::EC2::CloudFormationInit
- Defined in:
- ec2/cloud_formation_init.rb
Overview
A CloudFormation-init configuration.
Class Method Summary collapse
-
.from_config(config) ⇒ AWSCDK::EC2::CloudFormationInit
Use an existing InitConfig object as the default and only config.
-
.from_config_sets(props) ⇒ AWSCDK::EC2::CloudFormationInit
Build a CloudFormationInit from config sets.
-
.from_elements(*elements) ⇒ AWSCDK::EC2::CloudFormationInit
Build a new config from a set of Init Elements.
- .jsii_overridable_methods ⇒ Object
Instance Method Summary collapse
-
#add_config(config_name, config) ⇒ void
Add a config with the given name to this CloudFormationInit object.
-
#add_config_set(config_set_name, config_names = nil) ⇒ void
Add a config set with the given name to this CloudFormationInit object.
-
#attach(attached_resource, attach_options) ⇒ void
Attach the CloudFormation Init config to the given resource.
-
#initialize(*args) ⇒ CloudFormationInit
constructor
A new instance of CloudFormationInit.
Constructor Details
#initialize(*args) ⇒ CloudFormationInit
Returns a new instance of CloudFormationInit.
8 9 10 |
# File 'ec2/cloud_formation_init.rb', line 8 def initialize(*args) raise NoMethodError, "aws-cdk-lib.aws_ec2.CloudFormationInit does not have a visible constructor; use the provided factory methods" end |
Class Method Details
.from_config(config) ⇒ AWSCDK::EC2::CloudFormationInit
Use an existing InitConfig object as the default and only config.
24 25 26 27 |
# File 'ec2/cloud_formation_init.rb', line 24 def self.from_config(config) Jsii::Type.check_type(config, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRDb25maWcifQ==")), "config") Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.CloudFormationInit", "fromConfig", [config]) end |
.from_config_sets(props) ⇒ AWSCDK::EC2::CloudFormationInit
Build a CloudFormationInit from config sets.
33 34 35 36 37 |
# File 'ec2/cloud_formation_init.rb', line 33 def self.from_config_sets(props) props = props.is_a?(Hash) ? ::AWSCDK::EC2::ConfigSetProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkNvbmZpZ1NldFByb3BzIn0=")), "props") Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.CloudFormationInit", "fromConfigSets", [props]) end |
.from_elements(*elements) ⇒ AWSCDK::EC2::CloudFormationInit
Build a new config from a set of Init Elements.
43 44 45 46 47 48 |
# File 'ec2/cloud_formation_init.rb', line 43 def self.from_elements(*elements) elements.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRFbGVtZW50In0=")), "elements[#{index}]") end Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.CloudFormationInit", "fromElements", [*elements]) end |
.jsii_overridable_methods ⇒ Object
12 13 14 15 16 17 18 |
# File 'ec2/cloud_formation_init.rb', line 12 def self.jsii_overridable_methods { :add_config => { kind: :method, name: "addConfig", is_optional: false }, :add_config_set => { kind: :method, name: "addConfigSet", is_optional: false }, :attach => { kind: :method, name: "attach", is_optional: false }, } end |
Instance Method Details
#add_config(config_name, config) ⇒ void
This method returns an undefined value.
Add a config with the given name to this CloudFormationInit object.
55 56 57 58 59 |
# File 'ec2/cloud_formation_init.rb', line 55 def add_config(config_name, config) Jsii::Type.check_type(config_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "configName") Jsii::Type.check_type(config, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluaXRDb25maWcifQ==")), "config") jsii_call_method("addConfig", [config_name, config]) end |
#add_config_set(config_set_name, config_names = nil) ⇒ void
This method returns an undefined value.
Add a config set with the given name to this CloudFormationInit object.
The new configset will reference the given configs in the given order.
68 69 70 71 72 |
# File 'ec2/cloud_formation_init.rb', line 68 def add_config_set(config_set_name, config_names = nil) Jsii::Type.check_type(config_set_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "configSetName") Jsii::Type.check_type(config_names, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "configNames") unless config_names.nil? jsii_call_method("addConfigSet", [config_set_name, config_names]) end |
#attach(attached_resource, attach_options) ⇒ void
This method returns an undefined value.
Attach the CloudFormation Init config to the given resource.
As an app builder, use instance.applyCloudFormationInit() or
autoScalingGroup.applyCloudFormationInit() to trigger this method.
This method does the following:
- Renders the
AWS::CloudFormation::Initobject to the given resource's metadata, potentially adding aAWS::CloudFormation::Authenticationobject next to it if required. - Updates the instance role policy to be able to call the APIs required for
cfn-initandcfn-signalto work, and potentially add permissions to download referenced asset and bucket resources. - Updates the given UserData with commands to execute the
cfn-initscript.
92 93 94 95 96 97 |
# File 'ec2/cloud_formation_init.rb', line 92 def attach(attached_resource, ) Jsii::Type.check_type(attached_resource, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DZm5SZXNvdXJjZSJ9")), "attachedResource") = .is_a?(Hash) ? ::AWSCDK::EC2::AttachInitOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkF0dGFjaEluaXRPcHRpb25zIn0=")), "attachOptions") jsii_call_method("attach", [attached_resource, ]) end |