-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
287 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
deploy_id = "plantest0013" | ||
region = "us-west-2" | ||
ssh_pvt_key_path = "domino.pem" | ||
|
||
default_node_groups = { | ||
compute = { | ||
availability_zone_ids = ["usw2-az1", "usw2-az2"] | ||
} | ||
gpu = { | ||
availability_zone_ids = ["usw2-az1", "usw2-az2"] | ||
} | ||
platform = { | ||
"availability_zone_ids" = ["usw2-az1", "usw2-az2"] | ||
} | ||
} | ||
|
||
vpn_connection = { | ||
create = true | ||
shared_ip = "203.0.113.12" | ||
cidr_block = "192.168.0.0/16" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# vpn | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_customer_gateway.customer_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/customer_gateway) | resource | | ||
| [aws_vpn_connection.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpn_connection) | resource | | ||
| [aws_vpn_connection_route.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpn_connection_route) | resource | | ||
| [aws_vpn_gateway.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpn_gateway) | resource | | ||
| [aws_vpn_gateway_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpn_gateway_attachment) | resource | | ||
| [aws_vpn_gateway_route_propagation.route_propagation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpn_gateway_route_propagation) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_deploy_id"></a> [deploy\_id](#input\_deploy\_id) | Domino Deployment ID | `string` | n/a | yes | | ||
| <a name="input_network_info"></a> [network\_info](#input\_network\_info) | id = VPC ID.<br> subnets = {<br> public = List of public Subnets.<br> [{<br> name = Subnet name.<br> subnet\_id = Subnet ud<br> az = Subnet availability\_zone<br> az\_id = Subnet availability\_zone\_id<br> }]<br> private = List of private Subnets.<br> [{<br> name = Subnet name.<br> subnet\_id = Subnet ud<br> az = Subnet availability\_zone<br> az\_id = Subnet availability\_zone\_id<br> }]<br> pod = List of pod Subnets.<br> [{<br> name = Subnet name.<br> subnet\_id = Subnet ud<br> az = Subnet availability\_zone<br> az\_id = Subnet availability\_zone\_id<br> }]<br> } | <pre>object({<br> vpc_id = string<br> route_tables = object({<br> public = optional(list(string))<br> private = optional(list(string))<br> pod = optional(list(string))<br> })<br> subnets = object({<br> public = list(object({<br> name = string<br> subnet_id = string<br> az = string<br> az_id = string<br> }))<br> private = list(object({<br> name = string<br> subnet_id = string<br> az = string<br> az_id = string<br> }))<br> pod = list(object({<br> name = string<br> subnet_id = string<br> az = string<br> az_id = string<br> }))<br> })<br> vpc_cidrs = string<br> })</pre> | n/a | yes | | ||
| <a name="input_vpn_connection"></a> [vpn\_connection](#input\_vpn\_connection) | shared\_ip = Customer's shared IP Address.<br> cidr\_block = CIDR block for the customer's network. | <pre>object({<br> shared_ip = string<br> cidr_block = string<br> })</pre> | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_vpn_connection"></a> [vpn\_connection](#output\_vpn\_connection) | VPN connection information | | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
|
||
resource "aws_customer_gateway" "customer_gateway" { | ||
ip_address = var.vpn_connection.shared_ip | ||
type = "ipsec.1" | ||
} | ||
|
||
resource "aws_vpn_gateway" "this" { | ||
vpc_id = var.network_info.vpc_id | ||
tags = { | ||
Name = "${var.deploy_id}-vpn-gateway" | ||
} | ||
} | ||
|
||
resource "aws_vpn_gateway_attachment" "this" { | ||
vpc_id = var.network_info.vpc_id | ||
vpn_gateway_id = aws_vpn_gateway.this.id | ||
} | ||
|
||
resource "aws_vpn_connection" "this" { | ||
customer_gateway_id = aws_customer_gateway.customer_gateway.id | ||
vpn_gateway_id = aws_vpn_gateway.this.id | ||
type = "ipsec.1" | ||
|
||
static_routes_only = true | ||
|
||
tags = { | ||
Name = "${var.deploy_id}-vpn-connection" | ||
} | ||
} | ||
|
||
resource "aws_vpn_connection_route" "this" { | ||
destination_cidr_block = var.vpn_connection.cidr_block | ||
vpn_connection_id = aws_vpn_connection.this.id | ||
} | ||
|
||
locals { | ||
route_table_ids = concat(var.network_info.route_tables.private, var.network_info.route_tables.pod) | ||
} | ||
|
||
resource "aws_vpn_gateway_route_propagation" "route_propagation" { | ||
count = length(local.route_table_ids) | ||
vpn_gateway_id = aws_vpn_gateway.this.id | ||
route_table_id = local.route_table_ids[count.index] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
output "vpn_connection" { | ||
description = "VPN connection information" | ||
sensitive = true | ||
value = { | ||
ip_sec_tunnel_1 = { | ||
address = aws_vpn_connection.this.tunnel1_address | ||
preshared_key = aws_vpn_connection.this.tunnel1_preshared_key | ||
} | ||
ip_sec_tunnel_2 = { | ||
address = aws_vpn_connection.this.tunnel2_address | ||
preshared_key = aws_vpn_connection.this.tunnel2_preshared_key | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
variable "deploy_id" { | ||
type = string | ||
description = "Domino Deployment ID" | ||
|
||
validation { | ||
condition = can(regex("^[a-z-0-9]{3,32}$", var.deploy_id)) | ||
error_message = "Argument deploy_id must: start with a letter, contain lowercase alphanumeric characters(can contain hyphens[-]) with length between 3 and 32 characters." | ||
} | ||
} | ||
|
||
variable "vpn_connection" { | ||
description = <<EOF | ||
shared_ip = Customer's shared IP Address. | ||
cidr_block = CIDR block for the customer's network. | ||
EOF | ||
type = object({ | ||
shared_ip = string | ||
cidr_block = string | ||
}) | ||
|
||
validation { | ||
condition = can(regex("^([0-9]{1,3}\\.){3}[0-9]{1,3}$", var.vpn_connection.shared_ip)) | ||
error_message = "The 'shared_ip' must be a valid IP address." | ||
} | ||
validation { | ||
condition = can(cidrhost(var.vpn_connection.cidr_block, 0)) | ||
error_message = "The 'cidr_block' must be a valid CIDR block." | ||
} | ||
} | ||
|
||
variable "network_info" { | ||
description = <<EOF | ||
id = VPC ID. | ||
subnets = { | ||
public = List of public Subnets. | ||
[{ | ||
name = Subnet name. | ||
subnet_id = Subnet ud | ||
az = Subnet availability_zone | ||
az_id = Subnet availability_zone_id | ||
}] | ||
private = List of private Subnets. | ||
[{ | ||
name = Subnet name. | ||
subnet_id = Subnet ud | ||
az = Subnet availability_zone | ||
az_id = Subnet availability_zone_id | ||
}] | ||
pod = List of pod Subnets. | ||
[{ | ||
name = Subnet name. | ||
subnet_id = Subnet ud | ||
az = Subnet availability_zone | ||
az_id = Subnet availability_zone_id | ||
}] | ||
} | ||
EOF | ||
type = object({ | ||
vpc_id = string | ||
route_tables = object({ | ||
public = optional(list(string)) | ||
private = optional(list(string)) | ||
pod = optional(list(string)) | ||
}) | ||
subnets = object({ | ||
public = list(object({ | ||
name = string | ||
subnet_id = string | ||
az = string | ||
az_id = string | ||
})) | ||
private = list(object({ | ||
name = string | ||
subnet_id = string | ||
az = string | ||
az_id = string | ||
})) | ||
pod = list(object({ | ||
name = string | ||
subnet_id = string | ||
az = string | ||
az_id = string | ||
})) | ||
}) | ||
vpc_cidrs = string | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters