Class: AWSCDK::EC2::CloudFormationInit

Inherits:
Jsii::Object
  • Object
show all
Defined in:
ec2/cloud_formation_init.rb

Overview

A CloudFormation-init configuration.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CloudFormationInit

Returns a new instance of CloudFormationInit.

Raises:

  • (NoMethodError)


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.

Parameters:

Returns:

  • (AWSCDK::EC2::CloudFormationInit)


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.

Parameters:

Returns:

  • (AWSCDK::EC2::CloudFormationInit)


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.

Parameters:

Returns:

  • (AWSCDK::EC2::CloudFormationInit)


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_methodsObject



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.

Parameters:



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.

Parameters:

  • config_set_name (String)
  • config_names (Array<String>, nil) (defaults to: nil)


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::Init object to the given resource's metadata, potentially adding a AWS::CloudFormation::Authentication object next to it if required.
  • Updates the instance role policy to be able to call the APIs required for cfn-init and cfn-signal to work, and potentially add permissions to download referenced asset and bucket resources.
  • Updates the given UserData with commands to execute the cfn-init script.

Parameters:



92
93
94
95
96
97
# File 'ec2/cloud_formation_init.rb', line 92

def attach(attached_resource, attach_options)
  Jsii::Type.check_type(attached_resource, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DZm5SZXNvdXJjZSJ9")), "attachedResource")
  attach_options = attach_options.is_a?(Hash) ? ::AWSCDK::EC2::AttachInitOptions.new(**attach_options.transform_keys(&:to_sym)) : attach_options
  Jsii::Type.check_type(attach_options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkF0dGFjaEluaXRPcHRpb25zIn0=")), "attachOptions")
  jsii_call_method("attach", [attached_resource, attach_options])
end