Sha256: 669a9fba407c20d0994db0a4081933de0386ef8939821a8e36a70739d33b33bb
Contents?: true
Size: 1.54 KB
Versions: 5
Compression:
Stored size: 1.54 KB
Contents
module Terraforming module Resource class RouteTableAssociation include Terraforming::Util def self.tf(client: Aws::EC2::Client.new) self.new(client).tf end 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/route_table_association") end def tfstate resources = {} route_tables.each do |route_table| associations_of(route_table).each do |assoc| attributes = { "id" => assoc.route_table_association_id, "route_table_id" => assoc.route_table_id, "subnet_id" => assoc.subnet_id, } resources["aws_route_table_association.#{module_name_of(route_table, assoc)}"] = { "type" => "aws_route_table_association", "primary" => { "id" => assoc.route_table_association_id, "attributes" => attributes } } end end resources end private def associations_of(route_table) route_table.associations.reject { |association| association.subnet_id.nil? } end def module_name_of(route_table, assoc) normalize_module_name(name_from_tag(route_table, route_table.route_table_id) + '-' + assoc.route_table_association_id) end def route_tables @client.describe_route_tables.route_tables end end end end
Version data entries
5 entries across 5 versions & 1 rubygems