lib/terraforming/resource/ec2.rb in terraforming-0.1.3 vs lib/terraforming/resource/ec2.rb in terraforming-0.1.4

- old
+ new

@@ -5,24 +5,24 @@ def self.tf(client: Aws::EC2::Client.new) self.new(client).tf end - def self.tfstate(client: Aws::EC2::Client.new, tfstate_base: nil) - self.new(client).tfstate(tfstate_base) + def self.tfstate(client: Aws::EC2::Client.new) + self.new(client).tfstate end def initialize(client) @client = client end def tf apply_template(@client, "tf/ec2") end - def tfstate(tfstate_base) - resources = instances.inject({}) do |result, instance| + def tfstate + instances.inject({}) do |resources, instance| in_vpc = in_vpc?(instance) block_devices = block_devices_of(instance) attributes = { "ami"=> instance.image_id, @@ -44,24 +44,22 @@ "vpc_security_group_ids.#"=> in_vpc ? instance.security_groups.length.to_s : "0", } attributes["subnet_id"] = instance.subnet_id if in_vpc?(instance) - result["aws_instance.#{module_name_of(instance)}"] = { + resources["aws_instance.#{module_name_of(instance)}"] = { "type" => "aws_instance", "primary" => { "id" => instance.instance_id, "attributes" => attributes, "meta" => { "schema_version" => "1" } } } - result + resources end - - generate_tfstate(resources, tfstate_base) end private def block_device_ids_of(instance)