Skip to content

Commit 5f44ed0

Browse files
authored
Add TerraTest and examples (#2)
Adds TerraTest https://terratest.gruntwork.io/ Adds testing for - Make sure the public subnets are public - Make sure the private subnets are not publically routable - Make sure that when we ask for a single nat gateway we only get one
1 parent e2547e9 commit 5f44ed0

File tree

6 files changed

+604
-0
lines changed

6 files changed

+604
-0
lines changed

examples/main.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module "main" {
2+
single_nat_gw = true
3+
source = "../."
4+
}
5+
6+
output "public_subnets" {
7+
value = module.main.public_subnets
8+
}
9+
10+
output "private_subnets" {
11+
value = module.main.private_subnets
12+
}
13+
14+
output "database_subnets" {
15+
value = module.main.database_subnets
16+
}
17+
18+
output "vpc" {
19+
value = module.main.vpc
20+
}
21+
22+
output "nat_gws" {
23+
value = module.main.aws_nat_gateways
24+
}

main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ resource "aws_vpc" "vpc" {
55
tags = merge(local.tags, { "Name" = "VPC" })
66
}
77

8+
output "vpc" {
9+
value = aws_vpc.vpc
10+
}
11+
812
data "aws_region" "current" {}
913

1014
resource "aws_vpc_endpoint" "s3" {

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ output "private_subnets" {
1313
output "database_subnets" {
1414
value = aws_subnet.database.*.id
1515
}
16+
17+
output "aws_nat_gateways" {
18+
value = aws_nat_gateway.nat_gw
19+
}

test/go.mod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module damacus/terraform-module-vpc
2+
3+
go 1.14
4+
5+
require (
6+
github.com/gruntwork-io/terratest v0.26.6
7+
github.com/stretchr/testify v1.5.1
8+
)

0 commit comments

Comments
 (0)