Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BGP related information on aws_vpn_connection #973

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions aws/resource_aws_vpn_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type XmlVpnConnectionConfig struct {

type XmlIpsecTunnel struct {
OutsideAddress string `xml:"vpn_gateway>tunnel_outside_address>ip_address"`
BGPASN string `xml:"vpn_gateway>bgp>asn"`
BGPHoldTime int `xml:"vpn_gateway>bgp>hold_time"`
PreSharedKey string `xml:"ike>pre_shared_key"`
CgwInsideAddress string `xml:"customer_gateway>tunnel_inside_address>ip_address"`
VgwInsideAddress string `xml:"vpn_gateway>tunnel_inside_address>ip_address"`
Expand All @@ -34,10 +36,14 @@ type TunnelInfo struct {
Tunnel1CgwInsideAddress string
Tunnel1VgwInsideAddress string
Tunnel1PreSharedKey string
Tunnel1BGPASN string
Tunnel1BGPHoldTime int
Tunnel2Address string
Tunnel2CgwInsideAddress string
Tunnel2VgwInsideAddress string
Tunnel2PreSharedKey string
Tunnel2BGPASN string
Tunnel2BGPHoldTime int
}

func (slice XmlVpnConnectionConfig) Len() int {
Expand Down Expand Up @@ -116,7 +122,14 @@ func resourceAwsVpnConnection() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"tunnel1_bgp_asn": {
Type: schema.TypeString,
Computed: true,
},
"tunnel1_bgp_holdtime": {
Type: schema.TypeInt,
Computed: true,
},
"tunnel2_address": {
Type: schema.TypeString,
Computed: true,
Expand All @@ -136,7 +149,14 @@ func resourceAwsVpnConnection() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"tunnel2_bgp_asn": {
Type: schema.TypeString,
Computed: true,
},
"tunnel2_bgp_holdtime": {
Type: schema.TypeInt,
Computed: true,
},
"routes": {
Type: schema.TypeSet,
Computed: true,
Expand Down Expand Up @@ -352,10 +372,14 @@ func resourceAwsVpnConnectionRead(d *schema.ResourceData, meta interface{}) erro
d.Set("tunnel1_cgw_inside_address", tunnelInfo.Tunnel1CgwInsideAddress)
d.Set("tunnel1_vgw_inside_address", tunnelInfo.Tunnel1VgwInsideAddress)
d.Set("tunnel1_preshared_key", tunnelInfo.Tunnel1PreSharedKey)
d.Set("tunnel1_bgp_asn", tunnelInfo.Tunnel1BGPASN)
d.Set("tunnel1_bgp_holdtime", tunnelInfo.Tunnel1BGPHoldTime)
d.Set("tunnel2_address", tunnelInfo.Tunnel2Address)
d.Set("tunnel2_preshared_key", tunnelInfo.Tunnel2PreSharedKey)
d.Set("tunnel2_cgw_inside_address", tunnelInfo.Tunnel2CgwInsideAddress)
d.Set("tunnel2_vgw_inside_address", tunnelInfo.Tunnel2VgwInsideAddress)
d.Set("tunnel2_bgp_asn", tunnelInfo.Tunnel2BGPASN)
d.Set("tunnel2_bgp_holdtime", tunnelInfo.Tunnel2BGPHoldTime)
}
}

Expand Down Expand Up @@ -473,11 +497,14 @@ func xmlConfigToTunnelInfo(xmlConfig string) (*TunnelInfo, error) {
Tunnel1PreSharedKey: vpnConfig.Tunnels[0].PreSharedKey,
Tunnel1CgwInsideAddress: vpnConfig.Tunnels[0].CgwInsideAddress,
Tunnel1VgwInsideAddress: vpnConfig.Tunnels[0].VgwInsideAddress,

Tunnel1BGPASN: vpnConfig.Tunnels[0].BGPASN,
Tunnel1BGPHoldTime: vpnConfig.Tunnels[0].BGPHoldTime,
Tunnel2Address: vpnConfig.Tunnels[1].OutsideAddress,
Tunnel2PreSharedKey: vpnConfig.Tunnels[1].PreSharedKey,
Tunnel2CgwInsideAddress: vpnConfig.Tunnels[1].CgwInsideAddress,
Tunnel2VgwInsideAddress: vpnConfig.Tunnels[1].VgwInsideAddress,
Tunnel2BGPASN: vpnConfig.Tunnels[1].BGPASN,
Tunnel2BGPHoldTime: vpnConfig.Tunnels[1].BGPHoldTime,
}

return &tunnelInfo, nil
Expand Down
20 changes: 20 additions & 0 deletions aws/resource_aws_vpn_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ func TestAWSVpnConnection_xmlconfig(t *testing.T) {
if tunnelInfo.Tunnel1PreSharedKey != "FIRST_KEY" {
t.Fatalf("First key from tunnel XML was incorrect.")
}
if tunnelInfo.Tunnel1BGPASN != "FIRST_BGP_ASN" {
t.Fatalf("First bgp asn from tunnel XML was incorrect.")
}
if tunnelInfo.Tunnel1BGPHoldTime != 31 {
t.Fatalf("First bgp holdtime from tunnel XML was incorrect.")
}
if tunnelInfo.Tunnel2Address != "SECOND_ADDRESS" {
t.Fatalf("Second address from tunnel XML was incorrect.")
}
Expand All @@ -258,6 +264,12 @@ func TestAWSVpnConnection_xmlconfig(t *testing.T) {
if tunnelInfo.Tunnel2PreSharedKey != "SECOND_KEY" {
t.Fatalf("Second key from tunnel XML was incorrect.")
}
if tunnelInfo.Tunnel2BGPASN != "SECOND_BGP_ASN" {
t.Fatalf("Second bgp asn from tunnel XML was incorrect.")
}
if tunnelInfo.Tunnel2BGPHoldTime != 32 {
t.Fatalf("Second bgp holdtime from tunnel XML was incorrect.")
}
}

func testAccAwsVpnConnectionConfig(rBgpAsn int) string {
Expand Down Expand Up @@ -336,6 +348,10 @@ const testAccAwsVpnTunnelInfoXML = `
<network_mask>255.255.255.252</network_mask>
<network_cidr>30</network_cidr>
</tunnel_inside_address>
<bgp>
<asn>SECOND_BGP_ASN</asn>
<hold_time>32</hold_time>
</bgp>
</vpn_gateway>
<ike>
<pre_shared_key>SECOND_KEY</pre_shared_key>
Expand All @@ -361,6 +377,10 @@ const testAccAwsVpnTunnelInfoXML = `
<network_mask>255.255.255.252</network_mask>
<network_cidr>30</network_cidr>
</tunnel_inside_address>
<bgp>
<asn>FIRST_BGP_ASN</asn>
<hold_time>31</hold_time>
</bgp>
</vpn_gateway>
<ike>
<pre_shared_key>FIRST_KEY</pre_shared_key>
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/vpn_connection.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ The following attributes are exported:
* `tunnel1_cgw_inside_address` - The RFC 6890 link-local address of the first VPN tunnel (Customer Gateway Side).
* `tunnel1_vgw_inside_address` - The RFC 6890 link-local address of the first VPN tunnel (VPN Gateway Side).
* `tunnel1_preshared_key` - The preshared key of the first VPN tunnel.
* `tunnel1_bgp_asn` - The bgp asn number of the first VPN tunnel.
* `tunnel1_bgp_holdtime` - The bgp holdtime of the first VPN tunnel.
* `tunnel2_address` - The public IP address of the second VPN tunnel.
* `tunnel2_cgw_inside_address` - The RFC 6890 link-local address of the second VPN tunnel (Customer Gateway Side).
* `tunnel2_vgw_inside_address` - The RFC 6890 link-local address of the second VPN tunnel (VPN Gateway Side).
* `tunnel2_preshared_key` - The preshared key of the second VPN tunnel.
* `tunnel2_bgp_asn` - The bgp asn number of the second VPN tunnel.
* `tunnel2_bgp_holdtime` - The bgp holdtime of the second VPN tunnel.
* `type` - The type of VPN connection.
* `vpn_gateway_id` - The ID of the virtual private gateway to which the connection is attached.

Expand Down