class GeoEngineer::Resources::AwsVpnGatewayAttachment

AwsVpnGatewayAttachment is the aws_vpn_gateway_attachment terrform resource,

{www.terraform.io/docs/providers/aws/r/vpn_gateway_attachment.html Terraform Docs}

Public Class Methods

_fetch_remote_resources(provider) click to toggle source
# File lib/geoengineer/resources/aws_vpn_gateway_attachment.rb, line 26
def self._fetch_remote_resources(provider)
  AwsClients
    .ec2(provider)
    .describe_vpn_gateways['vpn_gateways']
    .map(&:to_h)
    .select { |gateway| !gateway[:vpc_attachments].empty? }
    .map { |gateway| _generate_attachment(gateway) }
end
_generate_attachment(gateway) click to toggle source
# File lib/geoengineer/resources/aws_vpn_gateway_attachment.rb, line 35
def self._generate_attachment(gateway)
  # Terraform ID generation via:
  # https://github.com/hashicorp/terraform/blob/master/builtin/providers/aws/resource_aws_vpn_gateway_attachment.go#L209
  vpc_id = gateway[:vpc_attachments].first[:vpc_id]
  id_string = "#{vpc_id}-#{gateway[:vpn_gateway_id]}"
  terraform_id = "vpn-attachment-#{Crc32.hashcode(id_string)}"

  {
    _terraform_id: terraform_id,
    _geo_id: "#{vpc_id}::#{gateway[:vpn_gateway_id]}",
    vpn_gateway_id: gateway[:vpn_gateway_id],
    vpc_id: vpc_id
  }
end

Public Instance Methods

support_tags?() click to toggle source
# File lib/geoengineer/resources/aws_vpn_gateway_attachment.rb, line 22
def support_tags?
  false
end
to_terraform_state() click to toggle source
# File lib/geoengineer/resources/aws_vpn_gateway_attachment.rb, line 14
def to_terraform_state
  tfstate = super
  tfstate[:primary][:attributes] = {
    'vpn_gateway_id' => vpn_gateway_id
  }
  tfstate
end