Class: Terraforming::Resource::LaunchConfiguration
- Inherits:
-
Object
- Object
- Terraforming::Resource::LaunchConfiguration
- Includes:
- Util
- Defined in:
- lib/terraforming/resource/launch_configuration.rb
Class Method Summary collapse
- .tf(client: Aws::AutoScaling::Client.new) ⇒ Object
- .tfstate(client: Aws::AutoScaling::Client.new) ⇒ Object
Instance Method Summary collapse
-
#initialize(client) ⇒ LaunchConfiguration
constructor
A new instance of LaunchConfiguration.
- #tf ⇒ Object
- #tfstate ⇒ Object
Methods included from Util
#apply_template, #name_from_tag, #normalize_module_name, #prettify_policy, #template_path
Constructor Details
#initialize(client) ⇒ LaunchConfiguration
Returns a new instance of LaunchConfiguration.
14 15 16 |
# File 'lib/terraforming/resource/launch_configuration.rb', line 14 def initialize(client) @client = client end |
Class Method Details
.tf(client: Aws::AutoScaling::Client.new) ⇒ Object
6 7 8 |
# File 'lib/terraforming/resource/launch_configuration.rb', line 6 def self.tf(client: Aws::AutoScaling::Client.new) self.new(client).tf end |
.tfstate(client: Aws::AutoScaling::Client.new) ⇒ Object
10 11 12 |
# File 'lib/terraforming/resource/launch_configuration.rb', line 10 def self.tfstate(client: Aws::AutoScaling::Client.new) self.new(client).tfstate end |
Instance Method Details
#tf ⇒ Object
18 19 20 |
# File 'lib/terraforming/resource/launch_configuration.rb', line 18 def tf apply_template(@client, "tf/launch_configuration") end |
#tfstate ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/terraforming/resource/launch_configuration.rb', line 22 def tfstate launch_configurations.inject({}) do |resources, lc| attributes = { "name" => lc.launch_configuration_name, "image_id" => lc.image_id, "instance_type" => lc.instance_type, "key_name" => lc.key_name, "security_groups.#" => lc.security_groups.length.to_s, "associate_public_ip_address" => lc.associate_public_ip_address.to_s, "user_data" => lc.user_data, "enable_monitoring" => lc.instance_monitoring.enabled.to_s, "ebs_optimized" => lc.ebs_optimized.to_s, "root_block_device.#" => root_block_device_count(lc).to_s, "ebs_block_device.#" => ebs_block_device_count(lc).to_s, "ephemeral_block_device.#" => ephemeral_block_device_count(lc).to_s } lc.security_groups.each do |sg| hash = hash_security_group(sg) attributes["security_groups.#{hash}"] = sg end attributes["iam_instance_profile"] = lc.iam_instance_profile if lc.iam_instance_profile attributes["spot_price"] = lc.spot_price if lc.spot_price attributes["placement_tenancy"] = lc.placement_tenancy if lc.placement_tenancy resources["aws_launch_configuration.#{module_name_of(lc)}"] = { "type" => "aws_launch_configuration", "primary" => { "id" => lc.launch_configuration_name, "attributes" => attributes } } resources end end |