Skip to content

Commit 8eda172

Browse files
authored
Fix vgw bug (#4)
* correct typo in first interface * use try instead or this fails when vgw is specified
1 parent 3f2f542 commit 8eda172

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

README.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,40 @@
33
Creates a site-to-site VPN connection intended to terminate to a FortiGate firewall. Creates a template configuration file that can be used to easily configure the connection.
44

55
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6+
## Requirements
7+
8+
| Name | Version |
9+
|------|---------|
10+
| terraform | >= 0.12 |
11+
12+
## Providers
13+
14+
| Name | Version |
15+
|------|---------|
16+
| aws | n/a |
17+
| local | n/a |
18+
619
## Inputs
720

821
| Name | Description | Type | Default | Required |
9-
|------|-------------|:----:|:-----:|:-----:|
10-
| account\_name | Name for AWS account side of tunnel | string | n/a | yes |
11-
| customer\_bgp\_asn | BGP for customer side of tunnel | number | n/a | yes |
12-
| customer\_gateway\_type | Type for customer gateway | string | `"ipsec.1"` | no |
13-
| customer\_ip\_address | IP address for customer side | string | n/a | yes |
14-
| customer\_name | Name for customer side of tunnel | string | n/a | yes |
15-
| generate\_fortigate\_config | Generate a FortiGate config template \(does not include PSKs\) | bool | `"true"` | no |
16-
| tags | Tags to add to supported resources | string | n/a | yes |
17-
| transit\_gateway\_id | Transit gateway to attach VPN to \(required if `vpn\_gateway\_id` not set\) | string | `"null"` | no |
18-
| tunnel1\_inside\_cidr | Specify a Tunnel 1 inside CIDR \(optional\) | string | `""` | no |
19-
| tunnel1\_psk | Specify a Tunnel 1 PSK explicitly \(optional\) | string | `""` | no |
20-
| tunnel1\_psk\_version | Version to use for PSK \(increment to generate a new PSK\) | number | `"1"` | no |
21-
| tunnel2\_inside\_cidr | Specify a Tunnel 2 inside CIDR \(optional\) | string | `""` | no |
22-
| tunnel2\_psk | Specify a Tunnel 2 PSK explicitly \(optional\) | string | `""` | no |
23-
| tunnel2\_psk\_version | Version to use for PSK \(increment to generate a new PSK\) | number | `"1"` | no |
24-
| use\_secrets\_manager | Use Secrets Manager to store/manage PSKs | bool | `"true"` | no |
25-
| vgw\_id | Virtual Private Gateway to attach VPN to \(required if `transit\_gateway\_id` not set\) | string | `"null"` | no |
26-
| wan\_interface | WAN interface to use in fortigate config template | string | `"wan1"` | no |
22+
|------|-------------|------|---------|:--------:|
23+
| account\_name | Name for AWS account side of tunnel | `string` | n/a | yes |
24+
| customer\_bgp\_asn | BGP for customer side of tunnel | `number` | n/a | yes |
25+
| customer\_gateway\_type | Type for customer gateway | `string` | `"ipsec.1"` | no |
26+
| customer\_ip\_address | IP address for customer side | `string` | n/a | yes |
27+
| customer\_name | Name for customer side of tunnel | `string` | n/a | yes |
28+
| generate\_fortigate\_config | Generate a FortiGate config template (does not include PSKs) | `bool` | `true` | no |
29+
| tags | Tags to add to supported resources | `any` | n/a | yes |
30+
| transit\_gateway\_id | Transit gateway to attach VPN to (required if `vpn_gateway_id` not set) | `string` | `null` | no |
31+
| tunnel1\_inside\_cidr | Specify a Tunnel 1 inside CIDR (optional) | `string` | `""` | no |
32+
| tunnel1\_psk | Specify a Tunnel 1 PSK explicitly (optional) | `string` | `""` | no |
33+
| tunnel1\_psk\_version | Version to use for PSK (increment to generate a new PSK) | `number` | `1` | no |
34+
| tunnel2\_inside\_cidr | Specify a Tunnel 2 inside CIDR (optional) | `string` | `""` | no |
35+
| tunnel2\_psk | Specify a Tunnel 2 PSK explicitly (optional) | `string` | `""` | no |
36+
| tunnel2\_psk\_version | Version to use for PSK (increment to generate a new PSK) | `number` | `1` | no |
37+
| use\_secrets\_manager | Use Secrets Manager to store/manage PSKs | `bool` | `true` | no |
38+
| vgw\_id | Virtual Private Gateway to attach VPN to (required if `transit_gateway_id` not set) | `string` | `null` | no |
39+
| wan\_interface | WAN interface to use in fortigate config template | `string` | `"wan1"` | no |
2740

2841
## Outputs
2942

fortigate_config.txt.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ config system interface
3131
set type tunnel
3232
set tcp-mss 1379
3333
set remote-ip ${tunnel1_inside_address_amazon} 255.255.255.255
34-
set comments "${account_name}<->${customer_name}1"
34+
set description "${account_name}<->${customer_name}1"
3535
set interface "${wan_interface}"
3636
next
3737
end

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ locals {
4242
tunnel2_psk = var.use_secrets_manager ? module.psk2.secret : var.tunnel2_psk
4343

4444
# compute aws bgp asn
45-
amazon_bgp_asn = var.vgw_id == null ? data.aws_ec2_transit_gateway.this[0].amazon_side_asn : data.aws_vpn_gateway.this[0].amazon_side_asn
45+
amazon_bgp_asn = try(data.aws_ec2_transit_gateway.this[0].amazon_side_asn, data.aws_vpn_gateway.this[0].amazon_side_asn)
4646
}
4747

4848
resource "aws_customer_gateway" "this" {

0 commit comments

Comments
 (0)