From 9a00c59926ba6d59ac37ed606847ed6502f2ec72 Mon Sep 17 00:00:00 2001 From: Matt Gowie Date: Mon, 19 Feb 2024 18:34:12 -0700 Subject: [PATCH 1/9] fix: uses correct type with var.vpn_connection_static_routes_only (bool > string) I could not find why this was originally implemented this way... Maybe a 0.11 holdover? It was bugging me. --- main.tf | 2 +- variables.tf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 8a5ef62..2bf4979 100644 --- a/main.tf +++ b/main.tf @@ -68,7 +68,7 @@ resource "aws_vpn_gateway_route_propagation" "default" { # https://www.terraform.io/docs/providers/aws/r/vpn_connection_route.html resource "aws_vpn_connection_route" "default" { - count = local.enabled && var.vpn_connection_static_routes_only == "true" ? length(var.vpn_connection_static_routes_destinations) : 0 + count = local.enabled && var.vpn_connection_static_routes_only ? length(var.vpn_connection_static_routes_destinations) : 0 vpn_connection_id = join("", aws_vpn_connection.default.*.id) destination_cidr_block = element(var.vpn_connection_static_routes_destinations, count.index) } diff --git a/variables.tf b/variables.tf index d32f975..780a725 100644 --- a/variables.tf +++ b/variables.tf @@ -25,9 +25,9 @@ variable "route_table_ids" { } variable "vpn_connection_static_routes_only" { - type = string + type = bool description = "If set to `true`, the VPN connection will use static routes exclusively. Static routes must be used for devices that don't support BGP" - default = "true" + default = false } variable "vpn_connection_static_routes_destinations" { From f89dd6e55efabac30214966761feea7d19829995 Mon Sep 17 00:00:00 2001 From: Matt Gowie Date: Mon, 19 Feb 2024 18:35:05 -0700 Subject: [PATCH 2/9] fix: vpc_id should not be required (not required if doing a TGW <> VPN connection) --- variables.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/variables.tf b/variables.tf index 780a725..653edf0 100644 --- a/variables.tf +++ b/variables.tf @@ -1,6 +1,7 @@ variable "vpc_id" { type = string description = "The ID of the VPC to which the Virtual Private Gateway will be attached" + default = null } variable "vpn_gateway_amazon_side_asn" { From 6849c21372a337015a187a42e712fc25cad5f2d6 Mon Sep 17 00:00:00 2001 From: Matt Gowie Date: Mon, 19 Feb 2024 18:40:30 -0700 Subject: [PATCH 3/9] feat: adds tagging the TGW attachment + associating / propagating TGW RTB + creating TGW routes --- main.tf | 56 +++++++++++++++++++++++++++++++++++++++++++++++----- outputs.tf | 11 ++++++++--- variables.tf | 15 ++++++++++++++ versions.tf | 6 +----- 4 files changed, 75 insertions(+), 13 deletions(-) diff --git a/main.tf b/main.tf index 2bf4979..5d9b7da 100644 --- a/main.tf +++ b/main.tf @@ -1,5 +1,12 @@ locals { enabled = module.this.enabled + + transit_gateway_enabled = local.enabled && var.transit_gateway_enabled + + transit_gateway_attachment_id = join("", aws_vpn_connection.default[*].transit_gateway_attachment_id) + vpn_gateway_id = join("", aws_vpn_gateway.default[*].id) + customer_gateway_id = join("", aws_customer_gateway.default[*].id) + vpn_connection_id = join("", aws_vpn_connection.default[*].id) } # https://www.terraform.io/docs/providers/aws/r/vpn_gateway.html @@ -22,9 +29,9 @@ resource "aws_customer_gateway" "default" { # https://www.terraform.io/docs/providers/aws/r/vpn_connection.html resource "aws_vpn_connection" "default" { count = local.enabled ? 1 : 0 - vpn_gateway_id = var.transit_gateway_enabled == false ? join("", aws_vpn_gateway.default.*.id) : null - customer_gateway_id = join("", aws_customer_gateway.default.*.id) - transit_gateway_id = var.transit_gateway_enabled ? var.existing_transit_gateway_id : null + vpn_gateway_id = local.transit_gateway_enabled == false ? local.vpn_gateway_id : null + customer_gateway_id = local.customer_gateway_id + transit_gateway_id = local.transit_gateway_enabled ? var.existing_transit_gateway_id : null type = "ipsec.1" static_routes_only = var.vpn_connection_static_routes_only local_ipv4_network_cidr = var.vpn_connection_local_ipv4_network_cidr @@ -62,13 +69,52 @@ resource "aws_vpn_connection" "default" { # https://www.terraform.io/docs/providers/aws/r/vpn_gateway_route_propagation.html resource "aws_vpn_gateway_route_propagation" "default" { count = local.enabled ? length(var.route_table_ids) : 0 - vpn_gateway_id = join("", aws_vpn_gateway.default.*.id) + vpn_gateway_id = local.vpn_gateway_id route_table_id = element(var.route_table_ids, count.index) } # https://www.terraform.io/docs/providers/aws/r/vpn_connection_route.html resource "aws_vpn_connection_route" "default" { count = local.enabled && var.vpn_connection_static_routes_only ? length(var.vpn_connection_static_routes_destinations) : 0 - vpn_connection_id = join("", aws_vpn_connection.default.*.id) + vpn_connection_id = local.vpn_connection_id destination_cidr_block = element(var.vpn_connection_static_routes_destinations, count.index) } + +## Transit Gateway VPN Connection Attachments + +# Required to tag VPN Connection TGW Attachments out of bound of the VPN Connection resource +# If we do not do this, the TGW Attachment will not have a name tag or any tags, which makes it difficult to identify in the console. +# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_tag +resource "aws_ec2_tag" "default" { + for_each = local.transit_gateway_enabled ? module.this.tags : {} + + resource_id = local.transit_gateway_attachment_id + key = each.key + value = each.value +} + +# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_association +resource "aws_ec2_transit_gateway_route_table_association" "default" { + count = local.transit_gateway_enabled && var.transit_gateway_route_table_id != null ? 1 : 0 + + transit_gateway_attachment_id = local.transit_gateway_attachment_id + transit_gateway_route_table_id = var.transit_gateway_route_table_id +} + +# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_propagation +resource "aws_ec2_transit_gateway_route_table_propagation" "default" { + count = local.transit_gateway_enabled && var.transit_gateway_route_table_id != null ? 1 : 0 + + transit_gateway_attachment_id = local.transit_gateway_attachment_id + transit_gateway_route_table_id = var.transit_gateway_route_table_id +} + +# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route +resource "aws_ec2_transit_gateway_route" "default" { + for_each = local.transit_gateway_enabled && var.transit_gateway_route_table_id != null ? var.transit_gateway_routes : {} + + blackhole = each.value.blackhole + destination_cidr_block = each.value.destination_cidr_block + transit_gateway_attachment_id = local.transit_gateway_attachment_id + transit_gateway_route_table_id = var.transit_gateway_route_table_id +} diff --git a/outputs.tf b/outputs.tf index c1960be..3e8d60f 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,16 +1,16 @@ output "vpn_gateway_id" { description = "Virtual Private Gateway ID" - value = join("", aws_vpn_gateway.default.*.id) + value = local.vpn_gateway_id } output "customer_gateway_id" { description = "Customer Gateway ID" - value = join("", aws_customer_gateway.default.*.id) + value = local.customer_gateway_id } output "vpn_connection_id" { description = "VPN Connection ID" - value = join("", aws_vpn_connection.default.*.id) + value = local.vpn_connection_id } output "vpn_connection_customer_gateway_configuration" { @@ -51,3 +51,8 @@ output "vpn_connection_tunnel2_vgw_inside_address" { value = join("", aws_vpn_connection.default.*.tunnel2_vgw_inside_address) } +output "transit_gateway_attachment_id" { + description = "The ID of the transit gateway attachment for the VPN connection (if a TGW connection)" + value = local.transit_gateway_attachment_id +} + diff --git a/variables.tf b/variables.tf index 653edf0..9639297 100644 --- a/variables.tf +++ b/variables.tf @@ -192,3 +192,18 @@ variable "transit_gateway_enabled" { default = false description = "Set to true to enable VPN connection to transit gateway and then pass in the existing_transit_gateway_id" } + +variable "transit_gateway_route_table_id" { + type = string + default = null + description = "The ID of the route table for the transit gateway that you want to associate + propogate the VPN connection's TGW attachment" +} + +variable "transit_gateway_routes" { + type = map(object({ + blackhole = optional(bool, false) + destination_cidr_block = string + })) + description = "A map of transit gateway routes to create on the given TGW route table (via `transit_gateway_route_table_id`) for the created VPN Attachment. Use the key in the map to describe the route." + default = {} +} diff --git a/versions.tf b/versions.tf index 971ae24..f80ee09 100644 --- a/versions.tf +++ b/versions.tf @@ -1,14 +1,10 @@ terraform { - required_version = ">= 0.13.0" + required_version = ">= 1.3.0" required_providers { aws = { source = "hashicorp/aws" version = ">= 2.0" } - null = { - source = "hashicorp/null" - version = ">= 2.0" - } } } From 586f5e0a26a9537a2514e0b5f15995deed7fdcdf Mon Sep 17 00:00:00 2001 From: Matt Gowie Date: Mon, 19 Feb 2024 18:41:38 -0700 Subject: [PATCH 4/9] chore: readme updates --- README.md | 290 ++++++++++++++++------------------------------ docs/terraform.md | 14 ++- 2 files changed, 109 insertions(+), 195 deletions(-) diff --git a/README.md b/README.md index 6d77c10..4c8cdc3 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,8 @@ - -# terraform-aws-vpn-connection [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-vpn-connection.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-vpn-connection) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-vpn-connection.svg)](https://github.com/cloudposse/terraform-aws-vpn-connection/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) +# terraform-aws-vpn-connection +Build StatusLatest ReleaseSlack Community -[![README Header][readme_header_img]][readme_header_link] - -[![Cloud Posse][logo]](https://cpco.io/homepage) - - -## Share the Love - -Like this project? Please give it a β˜… on [our GitHub](https://github.com/cloudposse/terraform-aws-vpn-connection)! (it helps us **a lot**) - -Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =) - - - ## Related Projects Check out these related projects. @@ -257,86 +227,89 @@ Check out these related projects. - [terraform-aws-multi-az-subnets](https://github.com/cloudposse/terraform-aws-multi-az-subnets) - Terraform module for multi-AZ public and private subnets provisioning - [terraform-aws-named-subnets](https://github.com/cloudposse/terraform-aws-named-subnets) - Terraform module for named subnets provisioning -## Help - -**Got a question?** We got answers. - -File a GitHub [issue](https://github.com/cloudposse/terraform-aws-vpn-connection/issues), send us an [email][email] or join our [Slack Community][slack]. - -[![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link] - -## DevOps Accelerator for Startups +## ✨ Contributing +This project is under active development, and we encourage contributions from our community. +Many thanks to our outstanding contributors: -We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us. + + + -[![Learn More](https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge)][commercial_support] +### πŸ› Bug Reports & Feature Requests -Work directly with our team of DevOps experts via email, slack, and video conferencing. - -We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet. - -- **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code. -- **Release Engineering.** You'll have end-to-end CI/CD with unlimited staging environments. -- **Site Reliability Engineering.** You'll have total visibility into your apps and microservices. -- **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes. -- **GitOps.** You'll be able to operate your infrastructure via Pull Requests. -- **Training.** You'll receive hands-on training so your team can operate what we build. -- **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel. -- **Troubleshooting.** You'll get help to triage when things aren't working. -- **Code Reviews.** You'll receive constructive feedback on Pull Requests. -- **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects. - -## Slack Community - -Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. - -## Discourse Forums - -Participate in our [Discourse Forums][discourse]. Here you'll find answers to commonly asked questions. Most questions will be related to the enormous number of projects we support on our GitHub. Come here to collaborate on answers, find solutions, and get ideas about the products and services we value. It only takes a minute to get started! Just sign in with SSO using your GitHub account. +Please use the [issue tracker](https://github.com/cloudposse/terraform-aws-vpn-connection/issues) to report any bugs or file feature requests. -## Newsletter +### πŸ’» Developing -Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover. +If you are interested in being a contributor and want to get involved in developing this project or help out with Cloud Posse's other projects, we would love to hear from you! +Hit us up in [Slack](https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=slack), in the `#cloudposse` channel. -## Office Hours +In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. + 1. Review our [Code of Conduct](https://github.com/cloudposse/terraform-aws-vpn-connection/?tab=coc-ov-file#code-of-conduct) and [Contributor Guidelines](https://github.com/cloudposse/.github/blob/main/CONTRIBUTING.md). + 2. **Fork** the repo on GitHub + 3. **Clone** the project to your own machine + 4. **Commit** changes to your own branch + 5. **Push** your work back up to your fork + 6. Submit a **Pull Request** so that we can review your changes -[Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone! +**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! -[![zoom](https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png")][office_hours] +### 🌎 Slack Community -## Contributing +Join our [Open Source Community](https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=slack) on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. -### Bug Reports & Feature Requests +### πŸ“° Newsletter -Please use the [issue tracker](https://github.com/cloudposse/terraform-aws-vpn-connection/issues) to report any bugs or file feature requests. +Sign up for [our newsletter](https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=newsletter) and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. +Dropped straight into your Inbox every week β€” and usually a 5-minute read. -### Developing +### πŸ“† Office Hours -If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email]. +[Join us every Wednesday via Zoom](https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=office_hours) for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a _live Q&A_ that you can’t find anywhere else. +It's **FREE** for everyone! -In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. +## About - 1. **Fork** the repo on GitHub - 2. **Clone** the project to your own machine - 3. **Commit** changes to your own branch - 4. **Push** your work back up to your fork - 5. Submit a **Pull Request** so that we can review your changes +This project is maintained by Cloud Posse, LLC. + -**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! +We are a [**DevOps Accelerator**](https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=commercial_support) for funded startups and enterprises. +Use our ready-to-go terraform architecture blueprints for AWS to get up and running quickly. +We build it with you. You own everything. Your team wins. Plus, we stick around until you succeed. +Learn More -## Copyright +*Your team can operate like a pro today.* -Copyright Β© 2017-2023 [Cloud Posse, LLC](https://cpco.io/copyright) +Ensure that your team succeeds by using our proven process and turnkey blueprints. Plus, we stick around until you succeed. +
+ πŸ“š See What's Included +- **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code. +- **Deployment Strategy.** You'll have a battle-tested deployment strategy using GitHub Actions that's automated and repeatable. +- **Site Reliability Engineering.** You'll have total visibility into your apps and microservices. +- **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes. +- **GitOps.** You'll be able to operate your infrastructure via Pull Requests. +- **Training.** You'll receive hands-on training so your team can operate what we build. +- **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel. +- **Troubleshooting.** You'll get help to triage when things aren't working. +- **Code Reviews.** You'll receive constructive feedback on Pull Requests. +- **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects. +
+ ## License -[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +License -See [LICENSE](LICENSE) for full details. +
+Preamble to the Apache License, Version 2.0 +
+
+ +Complete license is available in the [`LICENSE`](LICENSE) file. ```text Licensed to the Apache Software Foundation (ASF) under one @@ -356,80 +329,15 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` - - - - - - - - +
## Trademarks All other trademarks referenced herein are the property of their respective owners. +--- +Copyright © 2017-2024 [Cloud Posse, LLC](https://cpco.io/copyright) -## About - -This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know by [leaving a testimonial][testimonial]! - -[![Cloud Posse][logo]][website] - -We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❀️ [Open Source Software][we_love_open_source]. - -We offer [paid support][commercial_support] on all of our projects. - -Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. - - - -### Contributors - -| [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | [![Josh Myers][joshmyers_avatar]][joshmyers_homepage]
[Josh Myers][joshmyers_homepage] | -|---|---|---|---| - +README footer - [osterman_homepage]: https://github.com/osterman - [osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png - [aknysh_homepage]: https://github.com/aknysh - [aknysh_avatar]: https://img.cloudposse.com/150x150/https://github.com/aknysh.png - [goruha_homepage]: https://github.com/goruha - [goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png - [joshmyers_homepage]: https://github.com/joshmyers - [joshmyers_avatar]: https://img.cloudposse.com/150x150/https://github.com/joshmyers.png - -[![README Footer][readme_footer_img]][readme_footer_link] -[![Beacon][beacon]][website] - - [logo]: https://cloudposse.com/logo-300x69.svg - [docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=docs - [website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=website - [github]: https://cpco.io/github?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=github - [jobs]: https://cpco.io/jobs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=jobs - [hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=hire - [slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=slack - [linkedin]: https://cpco.io/linkedin?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=linkedin - [twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=twitter - [testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=testimonial - [office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=office_hours - [newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=newsletter - [discourse]: https://ask.sweetops.com/?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=discourse - [email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=email - [commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=commercial_support - [we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=we_love_open_source - [terraform_modules]: https://cpco.io/terraform-modules?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=terraform_modules - [readme_header_img]: https://cloudposse.com/readme/header/img - [readme_header_link]: https://cloudposse.com/readme/header/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=readme_header_link - [readme_footer_img]: https://cloudposse.com/readme/footer/img - [readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=readme_footer_link - [readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img - [readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-vpn-connection&utm_content=readme_commercial_support_link - [share_twitter]: https://twitter.com/intent/tweet/?text=terraform-aws-vpn-connection&url=https://github.com/cloudposse/terraform-aws-vpn-connection - [share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=terraform-aws-vpn-connection&url=https://github.com/cloudposse/terraform-aws-vpn-connection - [share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/terraform-aws-vpn-connection - [share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/terraform-aws-vpn-connection - [share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/terraform-aws-vpn-connection - [share_email]: mailto:?subject=terraform-aws-vpn-connection&body=https://github.com/cloudposse/terraform-aws-vpn-connection - [beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-vpn-connection?pixel&cs=github&cm=readme&an=terraform-aws-vpn-connection - +Beacon diff --git a/docs/terraform.md b/docs/terraform.md index c9ea05b..a5c1645 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -3,9 +3,8 @@ | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 0.13.0 | +| [terraform](#requirement\_terraform) | >= 1.3.0 | | [aws](#requirement\_aws) | >= 2.0 | -| [null](#requirement\_null) | >= 2.0 | ## Providers @@ -24,6 +23,10 @@ | Name | Type | |------|------| | [aws_customer_gateway.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/customer_gateway) | resource | +| [aws_ec2_tag.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_tag) | resource | +| [aws_ec2_transit_gateway_route.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route) | resource | +| [aws_ec2_transit_gateway_route_table_association.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_association) | resource | +| [aws_ec2_transit_gateway_route_table_propagation.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_propagation) | resource | | [aws_vpn_connection.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpn_connection) | resource | | [aws_vpn_connection_route.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpn_connection_route) | resource | | [aws_vpn_gateway.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpn_gateway) | resource | @@ -56,11 +59,13 @@ | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | | [transit\_gateway\_enabled](#input\_transit\_gateway\_enabled) | Set to true to enable VPN connection to transit gateway and then pass in the existing\_transit\_gateway\_id | `bool` | `false` | no | -| [vpc\_id](#input\_vpc\_id) | The ID of the VPC to which the Virtual Private Gateway will be attached | `string` | n/a | yes | +| [transit\_gateway\_route\_table\_id](#input\_transit\_gateway\_route\_table\_id) | The ID of the route table for the transit gateway that you want to associate + propogate the VPN connection's TGW attachment | `string` | `null` | no | +| [transit\_gateway\_routes](#input\_transit\_gateway\_routes) | A map of transit gateway routes to create on the given TGW route table (via `transit_gateway_route_table_id`) for the created VPN Attachment. Use the key in the map to describe the route. |
map(object({
blackhole = optional(bool, false)
destination_cidr_block = string
}))
| `{}` | no | +| [vpc\_id](#input\_vpc\_id) | The ID of the VPC to which the Virtual Private Gateway will be attached | `string` | `null` | no | | [vpn\_connection\_local\_ipv4\_network\_cidr](#input\_vpn\_connection\_local\_ipv4\_network\_cidr) | The IPv4 CIDR on the customer gateway (on-premises) side of the VPN connection. | `string` | `"0.0.0.0/0"` | no | | [vpn\_connection\_remote\_ipv4\_network\_cidr](#input\_vpn\_connection\_remote\_ipv4\_network\_cidr) | The IPv4 CIDR on the AWS side of the VPN connection. | `string` | `"0.0.0.0/0"` | no | | [vpn\_connection\_static\_routes\_destinations](#input\_vpn\_connection\_static\_routes\_destinations) | List of CIDR blocks to be used as destination for static routes. Routes to destinations will be propagated to the route tables defined in `route_table_ids` | `list(string)` | `[]` | no | -| [vpn\_connection\_static\_routes\_only](#input\_vpn\_connection\_static\_routes\_only) | If set to `true`, the VPN connection will use static routes exclusively. Static routes must be used for devices that don't support BGP | `string` | `"true"` | no | +| [vpn\_connection\_static\_routes\_only](#input\_vpn\_connection\_static\_routes\_only) | If set to `true`, the VPN connection will use static routes exclusively. Static routes must be used for devices that don't support BGP | `bool` | `false` | no | | [vpn\_connection\_tunnel1\_dpd\_timeout\_action](#input\_vpn\_connection\_tunnel1\_dpd\_timeout\_action) | The action to take after DPD timeout occurs for the first VPN tunnel. Specify restart to restart the IKE initiation. Specify clear to end the IKE session. Valid values are clear \| none \| restart. | `string` | `"clear"` | no | | [vpn\_connection\_tunnel1\_ike\_versions](#input\_vpn\_connection\_tunnel1\_ike\_versions) | The IKE versions that are permitted for the first VPN tunnel. Valid values are ikev1 \| ikev2. | `list(string)` | `[]` | no | | [vpn\_connection\_tunnel1\_inside\_cidr](#input\_vpn\_connection\_tunnel1\_inside\_cidr) | The CIDR block of the inside IP addresses for the first VPN tunnel | `string` | `null` | no | @@ -90,6 +95,7 @@ | Name | Description | |------|-------------| | [customer\_gateway\_id](#output\_customer\_gateway\_id) | Customer Gateway ID | +| [transit\_gateway\_attachment\_id](#output\_transit\_gateway\_attachment\_id) | The ID of the transit gateway attachment for the VPN connection (if a TGW connection) | | [vpn\_connection\_customer\_gateway\_configuration](#output\_vpn\_connection\_customer\_gateway\_configuration) | The configuration information for the VPN connection's Customer Gateway (in the native XML format) | | [vpn\_connection\_id](#output\_vpn\_connection\_id) | VPN Connection ID | | [vpn\_connection\_tunnel1\_address](#output\_vpn\_connection\_tunnel1\_address) | The public IP address of the first VPN tunnel | From 555c21bfc7dfe4ee65062cb75775bebead41252d Mon Sep 17 00:00:00 2001 From: Matt Gowie Date: Mon, 19 Feb 2024 18:53:00 -0700 Subject: [PATCH 5/9] =?UTF-8?q?chore:=20cleans=20up=20tflint=20issues=20?= =?UTF-8?q?=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- outputs.tf | 14 +++++++------- variables.tf | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/outputs.tf b/outputs.tf index 3e8d60f..6f281c7 100644 --- a/outputs.tf +++ b/outputs.tf @@ -17,38 +17,38 @@ output "vpn_connection_customer_gateway_configuration" { description = "The configuration information for the VPN connection's Customer Gateway (in the native XML format)" value = join( "", - aws_vpn_connection.default.*.customer_gateway_configuration, + aws_vpn_connection.default[*].customer_gateway_configuration, ) } output "vpn_connection_tunnel1_address" { description = "The public IP address of the first VPN tunnel" - value = join("", aws_vpn_connection.default.*.tunnel1_address) + value = join("", aws_vpn_connection.default[*].tunnel1_address) } output "vpn_connection_tunnel1_cgw_inside_address" { description = "The RFC 6890 link-local address of the first VPN tunnel (Customer Gateway side)" - value = join("", aws_vpn_connection.default.*.tunnel1_cgw_inside_address) + value = join("", aws_vpn_connection.default[*].tunnel1_cgw_inside_address) } output "vpn_connection_tunnel1_vgw_inside_address" { description = "The RFC 6890 link-local address of the first VPN tunnel (Virtual Private Gateway side)" - value = join("", aws_vpn_connection.default.*.tunnel1_vgw_inside_address) + value = join("", aws_vpn_connection.default[*].tunnel1_vgw_inside_address) } output "vpn_connection_tunnel2_address" { description = "The public IP address of the second VPN tunnel" - value = join("", aws_vpn_connection.default.*.tunnel2_address) + value = join("", aws_vpn_connection.default[*].tunnel2_address) } output "vpn_connection_tunnel2_cgw_inside_address" { description = "The RFC 6890 link-local address of the second VPN tunnel (Customer Gateway side)" - value = join("", aws_vpn_connection.default.*.tunnel2_cgw_inside_address) + value = join("", aws_vpn_connection.default[*].tunnel2_cgw_inside_address) } output "vpn_connection_tunnel2_vgw_inside_address" { description = "The RFC 6890 link-local address of the second VPN tunnel (Virtual Private Gateway side)" - value = join("", aws_vpn_connection.default.*.tunnel2_vgw_inside_address) + value = join("", aws_vpn_connection.default[*].tunnel2_vgw_inside_address) } output "transit_gateway_attachment_id" { diff --git a/variables.tf b/variables.tf index 9639297..c5c3ca1 100644 --- a/variables.tf +++ b/variables.tf @@ -5,6 +5,7 @@ variable "vpc_id" { } variable "vpn_gateway_amazon_side_asn" { + type = number description = "The Autonomous System Number (ASN) for the Amazon side of the VPN gateway. If you don't specify an ASN, the Virtual Private Gateway is created with the default ASN" default = 64512 } From e881c3ed6b6f32371f1f208034ef96aa95ae1e96 Mon Sep 17 00:00:00 2001 From: Matt Gowie Date: Tue, 20 Feb 2024 10:27:11 -0700 Subject: [PATCH 6/9] fix: adds sensitive = true for gateway_config output (fixes #36) --- outputs.tf | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/outputs.tf b/outputs.tf index 6f281c7..0990e47 100644 --- a/outputs.tf +++ b/outputs.tf @@ -15,10 +15,8 @@ output "vpn_connection_id" { output "vpn_connection_customer_gateway_configuration" { description = "The configuration information for the VPN connection's Customer Gateway (in the native XML format)" - value = join( - "", - aws_vpn_connection.default[*].customer_gateway_configuration, - ) + sensitive = true + value = join("", aws_vpn_connection.default[*].customer_gateway_configuration) } output "vpn_connection_tunnel1_address" { From dbd82e9e2224c328143070a1cb137e0ad70c5e9d Mon Sep 17 00:00:00 2001 From: Matt Gowie Date: Tue, 20 Feb 2024 10:50:41 -0700 Subject: [PATCH 7/9] chore: empty commit to try and kick /terratest From 630eac5ca72d132ffbe2687465754d4338c73d7f Mon Sep 17 00:00:00 2001 From: Matt Gowie Date: Tue, 20 Feb 2024 11:09:38 -0700 Subject: [PATCH 8/9] fix: updates examples gateway_config output to sensitive --- examples/complete/outputs.tf | 1 + examples/complete/versions.tf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf index e4c24eb..7dc3295 100644 --- a/examples/complete/outputs.tf +++ b/examples/complete/outputs.tf @@ -15,6 +15,7 @@ output "vpn_connection_id" { output "vpn_connection_customer_gateway_configuration" { description = "The configuration information for the VPN connection's Customer Gateway (in the native XML format)" + sensitive = true value = module.vpn_connection.vpn_connection_customer_gateway_configuration } diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 66f1cb2..a326ce5 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.13.0" + required_version = ">= 1.3" required_providers { aws = { source = "hashicorp/aws" From 09a07f6588637b2bbf724b5e92fda3ea25e2fdaa Mon Sep 17 00:00:00 2001 From: Matt Gowie Date: Tue, 20 Feb 2024 11:14:28 -0700 Subject: [PATCH 9/9] fix: set version for aws provider in example --- examples/complete/versions.tf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index a326ce5..f80ee09 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -1,8 +1,10 @@ terraform { - required_version = ">= 1.3" + required_version = ">= 1.3.0" + required_providers { aws = { - source = "hashicorp/aws" + source = "hashicorp/aws" + version = ">= 2.0" } } }