Skip to content

Commit

Permalink
feat: Adding Output for AWS Transit Gateway Attachement IDs (#4)
Browse files Browse the repository at this point in the history
Added a output which returns a set of AWS Transit Gateway Attachement IDs
  • Loading branch information
tfhartmann authored Feb 12, 2021
1 parent 89bde08 commit 1c5896c
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Hi! :wave: Thanks for the PR! Here's a quick checklist to make this PR easier to
##### PR Checklist

- [ ] Have you run `terraform fmt` on the files in this repo?
- [ ] Have you updated the README.md by running `terraform-docs --sort-by-required markdown --header-from HEADER . > README.md`?
- [ ] Have you updated the README.md by running ` terraform-docs --sort-by-required markdown --header-from HEADER.md . > README.md`?
---
43 changes: 0 additions & 43 deletions HEADER

This file was deleted.

41 changes: 41 additions & 0 deletions HEADER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Overview of high-level configurations steps to set up HA VPN with Amazon Web Services (AWS):

![lifecycle: alpha](https://img.shields.io/badge/lifecycle-alpha-a0c3d2.svg)
* Create the HA VPN gateway and a Cloud Router. This creates 2 public IP addresses on the GCP side.
* Create two AWS Virtual Private Gateways. This creates 4 public addresses on the AWS side.
* Create two AWS Site-to-Site VPN connections and customer gateways, one for each AWS Virtual Private Gateway. Specify a non-overlapping link-local Tunnel IP Range for each tunnel, 4 total. For example, 169.254.1.4/30.
* Download the AWS configuration files for the generic device type.
* Create four VPN tunnels on the HA VPN gateway.
* Configure BGP sessions on the Cloud Router using the BGP IP addresses from the downloaded AWS configuration files.


### Single Region Example
```hcl
module "tgw-us-east-1" {
source = "terraform-aws-modules/transit-gateway/aws"
version = "1.1.0"
name = "tgw-example-us-east-1"
description = "TGW example shared with several other AWS accounts"
amazon_side_asn = "64512"
enable_auto_accept_shared_attachments = true
ram_allow_external_principals = true
tags = {
Purpose = "tgw example"
}
}
module "cb-us-east-1" {
source = "github.com/spotify/terraform-google-aws-hybrid-cloud-vpn"
transit_gateway_id = module.tgw-us-east-1.this_ec2_transit_gateway_id
google_network = default
amazon_side_asn = 64512
google_side_asn = 65534
}
```

### Refrence Docs
https://cloud.google.com/files/CloudVPNGuide-UsingCloudVPNwithAmazonWebServices.pdf
https://cloud.google.com/vpn/docs/how-to/creating-ha-vpn

21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ module "tgw-us-east-1" {
tags = {
Purpose = "tgw example"
}
}
}
module "cb-us-east-1" {
source = "github.com/spotify/terraform-google-aws-hybrid-cloud-vpn"
transit_gateway_id = module.tgw-us-east-1.this_ec2_transit_gateway_id
google_network = default
amazon_side_asn = 64512
google_side_asn = 65534
}
module "cb-us-east-1" {
source = "github.com/spotify/terraform-google-aws-hybrid-cloud-vpn"
transit_gateway_id = module.tgw-us-east-1.this_ec2_transit_gateway_id
google_network = default
amazon_side_asn = 64512
google_side_asn = 65534
}
```

### Refrence Docs
Expand All @@ -42,15 +42,15 @@ https://cloud.google.com/vpn/docs/how-to/creating-ha-vpn

| Name | Version |
|------|---------|
| aws | <4.0,>= 2.51.0 |
| aws | <4.0,>= 3.22.0 |
| google | <4.0,>= 3.11.0 |
| google-beta | <4.0,>= 3.11.0 |

## Providers

| Name | Version |
|------|---------|
| aws | <4.0,>= 2.51.0 |
| aws | <4.0,>= 3.22.0 |
| google | <4.0,>= 3.11.0 |
| google-beta | <4.0,>= 3.11.0 |
| random | n/a |
Expand All @@ -72,4 +72,5 @@ https://cloud.google.com/vpn/docs/how-to/creating-ha-vpn
|------|-------------|
| cloud\_router | Map of cloud router attributes. Map should match the exported resources described in the docs https://www.terraform.io/docs/providers/google/r/compute_router.html |
| ha\_vpn\_gateway\_interfaces | List of objects with interface ID and IP addresses |
| transit\_gateway\_attachment\_ids | Set of AWS Transit Gateway Attachement IDs |

4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ resource "google_compute_router" "router" {
: var.router_advertise_config.groups
)
)
dynamic advertised_ip_ranges {
dynamic "advertised_ip_ranges" {
for_each = (
var.router_advertise_config == null ? {} : (
var.router_advertise_config.mode != "CUSTOM"
Expand All @@ -158,7 +158,7 @@ resource "google_compute_external_vpn_gateway" "external_gateway" {
redundancy_type = "FOUR_IPS_REDUNDANCY"
description = "AWS Transit GW: ${var.transit_gateway_id} in AWS region ${data.aws_region.current.name}"

dynamic interface {
dynamic "interface" {
for_each = local.external_vpn_gateway_interfaces
content {
id = interface.key
Expand Down
8 changes: 8 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ output "ha_vpn_gateway_interfaces" {
output "cloud_router" {
value = google_compute_router.router
description = "Map of cloud router attributes. Map should match the exported resources described in the docs https://www.terraform.io/docs/providers/google/r/compute_router.html"
}

output "transit_gateway_attachment_ids" {
description = "Set of AWS Transit Gateway Attachement IDs"
value = toset([
aws_vpn_connection.vpn-alpha.transit_gateway_attachment_id,
aws_vpn_connection.vpn-beta.transit_gateway_attachment_id
])
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ terraform {
required_providers {
google = "<4.0,>= 3.11.0"
google-beta = "<4.0,>= 3.11.0"
aws = "<4.0,>= 2.51.0"
aws = "<4.0,>= 3.22.0"
}
}

0 comments on commit 1c5896c

Please sign in to comment.