Class: AWSCDK::EC2::ApplyCloudFormationInitOptions

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

Overview

Options for applying CloudFormation init to an instance or instance group.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_sets: nil, embed_fingerprint: nil, ignore_failures: nil, include_role: nil, include_url: nil, print_log: nil, timeout: nil) ⇒ ApplyCloudFormationInitOptions

Returns a new instance of ApplyCloudFormationInitOptions.

Parameters:

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

    ConfigSet to activate.

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

    Force instance replacement by embedding a config fingerprint.

  • 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.

  • timeout (AWSCDK::Duration, nil) (defaults to: nil)

    Timeout waiting for the configuration to be applied.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'ec2/apply_cloud_formation_init_options.rb', line 14

def initialize(config_sets: nil, embed_fingerprint: nil, ignore_failures: nil, include_role: nil, include_url: nil, print_log: nil, timeout: nil)
  @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?
  @timeout = timeout
  Jsii::Type.check_type(@timeout, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "timeout") unless @timeout.nil?
end

Instance Attribute Details

#config_setsArray<String>? (readonly)

Note:

Default: ['default']

ConfigSet to activate.

Returns:

  • (Array<String>, nil)


35
36
37
# File 'ec2/apply_cloud_formation_init_options.rb', line 35

def config_sets
  @config_sets
end

#embed_fingerprintBoolean? (readonly)

Note:

Default: true

Force instance replacement by embedding a config fingerprint.

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

  • If the EC2 instance is instance-store backed or user_data_causes_replacement is set, this will cause the instance to be replaced and the new configuration to be applied.
  • If the instance is EBS-backed and user_data_causes_replacement is not set, the change of UserData will make the instance restart but not be replaced, and the configuration will not be applied automatically.

If false, no hash will be embedded, and if the CloudFormation Init config changes nothing will happen to the running instance. If a config update introduces errors, you will not notice until after the CloudFormation deployment successfully finishes and the next instance fails to launch.

Returns:

  • (Boolean, nil)


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

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)


64
65
66
# File 'ec2/apply_cloud_formation_init_options.rb', line 64

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)


71
72
73
# File 'ec2/apply_cloud_formation_init_options.rb', line 71

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)


79
80
81
# File 'ec2/apply_cloud_formation_init_options.rb', line 79

def include_url
  @include_url
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)


92
93
94
# File 'ec2/apply_cloud_formation_init_options.rb', line 92

def print_log
  @print_log
end

#timeoutAWSCDK::Duration? (readonly)

Note:

Default: Duration.minutes(5)

Timeout waiting for the configuration to be applied.

Returns:



97
98
99
# File 'ec2/apply_cloud_formation_init_options.rb', line 97

def timeout
  @timeout
end

Class Method Details

.jsii_propertiesObject



99
100
101
102
103
104
105
106
107
108
109
# File 'ec2/apply_cloud_formation_init_options.rb', line 99

def self.jsii_properties
  {
    :config_sets => "configSets",
    :embed_fingerprint => "embedFingerprint",
    :ignore_failures => "ignoreFailures",
    :include_role => "includeRole",
    :include_url => "includeUrl",
    :print_log => "printLog",
    :timeout => "timeout",
  }
end

Instance Method Details

#to_jsiiObject



111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'ec2/apply_cloud_formation_init_options.rb', line 111

def to_jsii
  result = {}
  result.merge!({
    "configSets" => @config_sets,
    "embedFingerprint" => @embed_fingerprint,
    "ignoreFailures" => @ignore_failures,
    "includeRole" => @include_role,
    "includeUrl" => @include_url,
    "printLog" => @print_log,
    "timeout" => @timeout,
  })
  result.compact
end