class Terraforming::Resource::NetworkACL
Public Class Methods
new(client)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 14 def initialize(client) @client = client end
tf(client: Aws::EC2::Client.new)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 6 def self.tf(client: Aws::EC2::Client.new) self.new(client).tf end
tfstate(client: Aws::EC2::Client.new)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 10 def self.tfstate(client: Aws::EC2::Client.new) self.new(client).tfstate end
Public Instance Methods
tf()
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 18 def tf apply_template(@client, "tf/network_acl") end
tfstate()
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 22 def tfstate network_acls.inject({}) do |resources, network_acl| attributes = { "egress.#" => egresses_of(network_acl).length.to_s, "id" => network_acl.network_acl_id, "ingress.#" => ingresses_of(network_acl).length.to_s, "subnet_ids.#" => subnet_ids_of(network_acl).length.to_s, "tags.#" => network_acl.tags.length.to_s, "vpc_id" => network_acl.vpc_id, } resources["aws_network_acl.#{module_name_of(network_acl)}"] = { "type" => "aws_network_acl", "primary" => { "id" => network_acl.network_acl_id, "attributes" => attributes } } resources end end
Private Instance Methods
default_entry?(entry)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 46 def default_entry?(entry) entry.rule_number == default_rule_number end
default_rule_number()
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 50 def default_rule_number 32767 end
egresses_of(network_acl)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 54 def egresses_of(network_acl) network_acl.entries.select { |entry| entry.egress && !default_entry?(entry) } end
from_port_of(entry)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 58 def from_port_of(entry) entry.port_range ? entry.port_range.from : 0 end
ingresses_of(network_acl)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 62 def ingresses_of(network_acl) network_acl.entries.select { |entry| !entry.egress && !default_entry?(entry) } end
module_name_of(network_acl)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 66 def module_name_of(network_acl) normalize_module_name(name_from_tag(network_acl, network_acl.network_acl_id)) end
network_acls()
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 70 def network_acls @client.describe_network_acls.map(&:network_acls).flatten end
subnet_ids_of(network_acl)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 74 def subnet_ids_of(network_acl) network_acl.associations.map { |association| association.subnet_id } end
to_port_of(entry)
click to toggle source
# File lib/terraforming/resource/network_acl.rb, line 78 def to_port_of(entry) entry.port_range ? entry.port_range.to : 0 end