class Cumulus::VPC::EndpointConfig
Public: An object representing configuration for a VPC
endpoint
Attributes
policy[RW]
route_tables[R]
service_name[R]
Public Class Methods
new(json = nil)
click to toggle source
Public: Constructor
json - a hash containing the JSON configuration for the endpoint
# File lib/vpc/models/EndpointConfig.rb, line 20 def initialize(json = nil) if !json.nil? @service_name = json["service-name"] @policy = json["policy"] @route_tables = json["route-tables"] || [] end end
Public Instance Methods
diff(aws)
click to toggle source
Public: Produce an array of differences between this local configuration and the configuration in AWS
aws - the AWS resource
Returns an array of the EndpointDiffs that were found
# File lib/vpc/models/EndpointConfig.rb, line 50 def diff(aws) diffs = [] # policy aws_policy_statements = aws.parsed_policy["Statement"] local_policy_statements = Loader.policy(@policy)["Statement"] policy_diff = EndpointDiff.policy(aws_policy_statements, local_policy_statements) if policy_diff diffs << policy_diff end # routes aws_rts = aws.route_table_ids.map { |rt_id| EC2::id_route_tables[rt_id] } aws_rt_names = aws_rts.map { |rt| rt.name || rt.route_table_id } rt_diff = EndpointDiff.route_tables(aws_rt_names, @route_tables) if rt_diff diffs << rt_diff end diffs end
populate!(aws, route_table_map)
click to toggle source
# File lib/vpc/models/EndpointConfig.rb, line 36 def populate!(aws, route_table_map) @service_name = aws.service_name @policy = aws.parsed_policy["Version"] @route_tables = aws.route_table_ids.map { |rt_id| route_table_map[rt_id] || rt_id } self end
to_hash()
click to toggle source
# File lib/vpc/models/EndpointConfig.rb, line 28 def to_hash { "service-name" => @service_name, "policy" => @policy, "route-tables" => @route_tables.sort, }.reject { |k, v| v.nil? } end