Class: AWSCDK::EC2::AttachInitOptions

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

Overview

Options for attaching a CloudFormationInit to a resource.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance_role:, platform:, user_data:, config_sets: nil, embed_fingerprint: nil, ignore_failures: nil, include_role: nil, include_url: nil, print_log: nil, signal_resource: nil) ⇒ AttachInitOptions

Returns a new instance of AttachInitOptions.

Parameters:

  • instance_role (AWSCDK::IAM::IRole)

    Instance role of the consuming instance or fleet.

  • platform (AWSCDK::EC2::OperatingSystemType)

    OS Platform the init config will be used for.

  • user_data (AWSCDK::EC2::UserData)

    UserData to add commands to.

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

    ConfigSet to activate.

  • embed_fingerprint (Boolean, nil) (defaults to: nil)

    Whether to embed a hash into the userData.

  • ignore_failures (Boolean, nil) (defaults to: nil)

    Don't fail the instance creation when cfn-init fails.

  • include_role (Boolean, nil) (defaults to: nil)

    Include --role argument when running cfn-init and cfn-signal commands.

  • include_url (Boolean, nil) (defaults to: nil)

    Include --url argument when running cfn-init and cfn-signal commands.

  • print_log (Boolean, nil) (defaults to: nil)

    Print the results of running cfn-init to the Instance System Log.

  • signal_resource (AWSCDK::CfnResource, nil) (defaults to: nil)

    When provided, signals this resource instead of the attached resource.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'ec2/attach_init_options.rb', line 17

def initialize(instance_role:, platform:, user_data:, config_sets: nil, embed_fingerprint: nil, ignore_failures: nil, include_role: nil, include_url: nil, print_log: nil, signal_resource: nil)
  @instance_role = instance_role
  Jsii::Type.check_type(@instance_role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "instanceRole")
  @platform = platform
  Jsii::Type.check_type(@platform, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLk9wZXJhdGluZ1N5c3RlbVR5cGUifQ==")), "platform")
  @user_data = user_data
  Jsii::Type.check_type(@user_data, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlVzZXJEYXRhIn0=")), "userData")
  @config_sets = config_sets
  Jsii::Type.check_type(@config_sets, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "configSets") unless @config_sets.nil?
  @embed_fingerprint = embed_fingerprint
  Jsii::Type.check_type(@embed_fingerprint, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "embedFingerprint") unless @embed_fingerprint.nil?
  @ignore_failures = ignore_failures
  Jsii::Type.check_type(@ignore_failures, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "ignoreFailures") unless @ignore_failures.nil?
  @include_role = include_role
  Jsii::Type.check_type(@include_role, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "includeRole") unless @include_role.nil?
  @include_url = include_url
  Jsii::Type.check_type(@include_url, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "includeUrl") unless @include_url.nil?
  @print_log = print_log
  Jsii::Type.check_type(@print_log, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "printLog") unless @print_log.nil?
  @signal_resource = signal_resource
  Jsii::Type.check_type(@signal_resource, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DZm5SZXNvdXJjZSJ9")), "signalResource") unless @signal_resource.nil?
end

Instance Attribute Details

#config_setsArray<String>? (readonly)

Note:

Default: ['default']

ConfigSet to activate.

Returns:

  • (Array<String>, nil)


56
57
58
# File 'ec2/attach_init_options.rb', line 56

def config_sets
  @config_sets
end

#embed_fingerprintBoolean? (readonly)

Note:

Default: true

Whether to embed a hash into the userData.

If true (the default), a hash of the config will be embedded into the UserData, so that if the config changes, the UserData changes and the instance will be replaced.

If false, no such hash will be embedded, and if the CloudFormation Init config changes nothing will happen to the running instance.

Returns:

  • (Boolean, nil)


68
69
70
# File 'ec2/attach_init_options.rb', line 68

def embed_fingerprint
  @embed_fingerprint
end

#ignore_failuresBoolean? (readonly)

Note:

Default: false

Don't fail the instance creation when cfn-init fails.

You can use this to prevent CloudFormation from rolling back when instances fail to start up, to help in debugging.

Returns:

  • (Boolean, nil)


76
77
78
# File 'ec2/attach_init_options.rb', line 76

def ignore_failures
  @ignore_failures
end

#include_roleBoolean? (readonly)

Note:

Default: false

Include --role argument when running cfn-init and cfn-signal commands.

This will be the IAM instance profile attached to the EC2 instance

Returns:

  • (Boolean, nil)


83
84
85
# File 'ec2/attach_init_options.rb', line 83

def include_role
  @include_role
end

#include_urlBoolean? (readonly)

Note:

Default: false

Include --url argument when running cfn-init and cfn-signal commands.

This will be the cloudformation endpoint in the deployed region e.g. https://cloudformation.us-east-1.amazonaws.com

Returns:

  • (Boolean, nil)


91
92
93
# File 'ec2/attach_init_options.rb', line 91

def include_url
  @include_url
end

#instance_roleAWSCDK::IAM::IRole (readonly)

Instance role of the consuming instance or fleet.

Returns:



43
44
45
# File 'ec2/attach_init_options.rb', line 43

def instance_role
  @instance_role
end

#platformAWSCDK::EC2::OperatingSystemType (readonly)

OS Platform the init config will be used for.



47
48
49
# File 'ec2/attach_init_options.rb', line 47

def platform
  @platform
end
Note:

Default: true

Print the results of running cfn-init to the Instance System Log.

By default, the output of running cfn-init is written to a log file on the instance. Set this to true to print it to the System Log (visible from the EC2 Console), false to not print it.

(Be aware that the system log is refreshed at certain points in time of the instance life cycle, and successful execution may not always show up).

Returns:

  • (Boolean, nil)


104
105
106
# File 'ec2/attach_init_options.rb', line 104

def print_log
  @print_log
end

#signal_resourceAWSCDK::CfnResource? (readonly)

Note:

Default: - if this property is undefined cfn-signal signals the attached resource

When provided, signals this resource instead of the attached resource.

You can use this to support signaling LaunchTemplate while attaching AutoScalingGroup

Returns:



111
112
113
# File 'ec2/attach_init_options.rb', line 111

def signal_resource
  @signal_resource
end

#user_dataAWSCDK::EC2::UserData (readonly)

UserData to add commands to.



51
52
53
# File 'ec2/attach_init_options.rb', line 51

def user_data
  @user_data
end

Class Method Details

.jsii_propertiesObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'ec2/attach_init_options.rb', line 113

def self.jsii_properties
  {
    :instance_role => "instanceRole",
    :platform => "platform",
    :user_data => "userData",
    :config_sets => "configSets",
    :embed_fingerprint => "embedFingerprint",
    :ignore_failures => "ignoreFailures",
    :include_role => "includeRole",
    :include_url => "includeUrl",
    :print_log => "printLog",
    :signal_resource => "signalResource",
  }
end

Instance Method Details

#to_jsiiObject



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'ec2/attach_init_options.rb', line 128

def to_jsii
  result = {}
  result.merge!({
    "instanceRole" => @instance_role,
    "platform" => @platform,
    "userData" => @user_data,
    "configSets" => @config_sets,
    "embedFingerprint" => @embed_fingerprint,
    "ignoreFailures" => @ignore_failures,
    "includeRole" => @include_role,
    "includeUrl" => @include_url,
    "printLog" => @print_log,
    "signalResource" => @signal_resource,
  })
  result.compact
end