forked from aws-ia/terraform-aws-vpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request aws-ia#110 from pablo19sc/main
Amazon VPC Lattice Support
- Loading branch information
Showing
13 changed files
with
265 additions
and
3 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
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,9 @@ | ||
# Creating Amazon VPC Lattice Service Network VPC Assocation | ||
|
||
This example shows how you can use this module to create a [VPC Lattice]() Service Network VPC association. The example creates: | ||
|
||
* VPC Lattice Service Network. | ||
* Security Group (allowing HTTP and HTTPS traffic from the local CIDR). Used to attach it to the VPC Lattice association | ||
* The VPC module creates the following: | ||
* One set of subnets (*workload*) | ||
* VPC Lattice Service Network VPC association. |
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 @@ | ||
formatter: markdown | ||
header-from: .header.md | ||
settings: | ||
anchor: true | ||
color: true | ||
default: true | ||
escape: true | ||
html: true | ||
indent: 2 | ||
required: true | ||
sensitive: true | ||
type: true | ||
lockfile: false | ||
|
||
sort: | ||
enabled: true | ||
by: required | ||
|
||
output: | ||
file: README.md | ||
mode: replace |
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,49 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
# Creating Amazon VPC Lattice Service Network VPC Assocation | ||
|
||
This example shows how you can use this module to create a [VPC Lattice]() Service Network VPC association. The example creates: | ||
|
||
* VPC Lattice Service Network. | ||
* Security Group (allowing HTTP and HTTPS traffic from the local CIDR). Used to attach it to the VPC Lattice association | ||
* The VPC module creates the following: | ||
* One set of subnets (*workload*) | ||
* VPC Lattice Service Network VPC association. | ||
|
||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.65.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.65.0 | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_vpc"></a> [vpc](#module\_vpc) | aws-ia/vpc/aws | >= 4.3.0 | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_security_group.security_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource | | ||
| [aws_vpclattice_service_network.service_network](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpclattice_service_network) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS Region. | `string` | `"eu-west-1"` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_vpc_lattice_service_network_association"></a> [vpc\_lattice\_service\_network\_association](#output\_vpc\_lattice\_service\_network\_association) | VPC Lattice Service Network VPC association. | | ||
<!-- END_TF_DOCS --> |
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,76 @@ | ||
|
||
# VPC module | ||
module "vpc" { | ||
source = "aws-ia/vpc/aws" | ||
version = ">= 4.3.0" | ||
|
||
name = "tgw" | ||
cidr_block = "10.0.0.0/24" | ||
az_count = 2 | ||
|
||
vpc_lattice = { | ||
service_network_identifier = aws_vpclattice_service_network.service_network.id | ||
security_group_ids = [aws_security_group.security_group.id] | ||
tags = { | ||
vpc_lattice = true | ||
} | ||
} | ||
|
||
subnets = { | ||
workload = { netmask = 28 } | ||
} | ||
|
||
tags = { | ||
vpc_module = true | ||
} | ||
} | ||
|
||
# VPC Lattice Service Network | ||
resource "aws_vpclattice_service_network" "service_network" { | ||
name = "example-service-network" | ||
auth_type = "NONE" | ||
} | ||
|
||
# Security Group | ||
resource "aws_security_group" "security_group" { | ||
name = "lattice-sg" | ||
description = "Lattice Securigy Group." | ||
vpc_id = module.vpc.vpc_attributes.id | ||
|
||
ingress { | ||
description = "Allow HTTP" | ||
from_port = 80 | ||
to_port = 80 | ||
protocol = "tcp" | ||
cidr_blocks = ["10.0.0.0/24"] | ||
} | ||
|
||
ingress { | ||
description = "Allow HTTPS" | ||
from_port = 443 | ||
to_port = 443 | ||
protocol = "tcp" | ||
cidr_blocks = ["10.0.0.0/24"] | ||
} | ||
|
||
egress { | ||
description = "Allowing inter-VPC traffic." | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["10.0.0.0/24"] | ||
} | ||
|
||
egress { | ||
description = "Allowing VPC Lattice traffic." | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["169.254.171.0/24"] | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
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,6 @@ | ||
## Used for Testing, do not delete | ||
|
||
output "vpc_lattice_service_network_association" { | ||
description = "VPC Lattice Service Network VPC association." | ||
value = module.vpc.vpc_lattice_service_network_association.id | ||
} |
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,15 @@ | ||
terraform { | ||
required_version = ">= 1.3.0" | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 4.65.0" | ||
} | ||
} | ||
} | ||
|
||
# Provider definition | ||
provider "aws" { | ||
region = var.aws_region | ||
} | ||
|
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,7 @@ | ||
|
||
variable "aws_region" { | ||
description = "AWS Region." | ||
type = string | ||
|
||
default = "eu-west-1" | ||
} |
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,17 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
) | ||
|
||
func TestExamplesVPCLattice(t *testing.T) { | ||
|
||
terraformOptions := &terraform.Options{ | ||
TerraformDir: "../examples/vpc_lattice", | ||
} | ||
|
||
defer terraform.Destroy(t, terraformOptions) | ||
terraform.InitAndApply(t, terraformOptions) | ||
} |
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