An open API service indexing awesome lists of open source software.

https://github.com/philips-software/terraform-aws-vpc

Terraform module to create an AWS VPC (public, or public and private)
https://github.com/philips-software/terraform-aws-vpc

aws infrastructure-as-code terraform

Last synced: 1 day ago
JSON representation

Terraform module to create an AWS VPC (public, or public and private)

Awesome Lists containing this project

README

        

# Terraform module for creating a vpc

This module creates one VPC, by default it creates public and private subnets in all the availability zones for the selected region.

## Terraform version

- Terraform 0.12: Pin module to `~> 2+`, submit pull request to branch `develop`
- Terraform 0.11: Pin module to `~> 1.x`, submit pull request to branch `terraform011`

## Example usages:

See the [examples](./examples) for executable examples.

```
module "vpc" {
source = "github.com/philips-software/terraform-aws-vpc.git?ref=2.2.0"

environment = "my-awsome-project"
aws_region = "eu-west-1"

// optional, defaults
project = "Forest"
create_private_hosted_zone = "false" // default = true
create_private_subnets = "false" // default = true

// example to override default availability_zones
availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]

// add aditional tags
tags = {
my-tag = "my-new-tag"
}
}
```

## Inputs

| Name | Description | Type | Default | Required |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | :---------: | :-------------: | :------: |
| availability\_zones | List to specify the availability zones for which subnes will be created. By default all availability zones will be used. | list | `` | no |
| aws\_region | The Amazon region | string | n/a | yes |
| cidr\_block | The CIDR block used for the VPC. | string | `"10.0.0.0/16"` | no |
| create\_private\_hosted\_zone | Indicate to create a private hosted zone. | bool | `"true"` | no |
| create\_private\_subnets | Indicates to create private subnets. | bool | `"true"` | no |
| create\_s3\_vpc\_endpoint | Whether to create a VPC Endpoint for S3, so the S3 buckets can be used from within the VPC without using the NAT gateway. | bool | `"true"` | no |
| enable\_create\_defaults | Add tags to the default resources. | bool | `"false"` | no |
| environment | Environment name, will be added for resource tagging. | string | n/a | yes |
| private\_subnet\_tags | Map of tags to apply on the private subnets | map(string) | `` | no |
| project | Project name, will be added for resource tagging. | string | `""` | no |
| public\_subnet\_map\_public\_ip\_on\_launch | Enable public ip creaton by default on EC2 instance launch. | bool | `"false"` | no |
| public\_subnet\_tags | Map of tags to apply on the public subnets | map(string) | `` | no |
| tags | Map of tags to apply on the resources | map(string) | `` | no |

## Outputs

| Name | Description |
| ------------------------------ | ----------------------------------------- |
| availability\_zones | List of the availability zones. |
| nat\_gateway\_public\_ip | Public IP address of the NAT gateway. |
| private\_dns\_zone\_id | ID of the the private DNS zone, optional. |
| private\_domain\_name | Private domain name, optional. |
| private\_subnets | List of the private subnets. |
| private\_subnets\_route\_table | |
| public\_subnets | List of the public subnets. |
| public\_subnets\_route\_table | |
| vpc\_cidr | VPC CDIR. |
| vpc\_id | ID of the VPC. |

# VPC for Amazon EKS

Amazon EKS (Elastic Kubernetes Service) requires that both VPCs and Subnets (public and private) are tagged specifically with certain values according to the [aws-eks-docs].

Therefore, if the VPC created using this module is targeted for EKS, tag it with

```terraform
tags = {
"kubernetes.io/cluster/" = "my-new-tag"
}
```

## Subnets Tags

As stated above, tagging the subnets is also mandatory for EKS Clusters. The tags for public and private subnets are as follows, respectively:

### Public Subnet Tags

```terraform
public_subnet_tags = {
"kubernetes.io/cluster/" = "shared"
"kubernetes.io/role/elb" = "1"
}
```

### Private Subnet Tags

```terraform
private_subnet_tags = {
"kubernetes.io/cluster/" = "shared"
"kubernetes.io/role/internal-elb" = "1"
}
```

## Automated checks
Currently the automated checks are limited. In CI the following checks are done for the root and each example.
- lint: `terraform validate` and `terraform fmt`
- basic init / get check: `terraform init -get -backend=false -input=false`

## Generation variable documentation
A markdown table for variables can be generated as follow. Generation requires awk and terraform-docs installed.

```
.ci/bin/terraform-docs.sh markdown .
```

## Philips Forest

This module is part of the Philips Forest.

```
___ _
/ __\__ _ __ ___ ___| |_
/ _\/ _ \| '__/ _ \/ __| __|
/ / | (_) | | | __/\__ \ |_
\/ \___/|_| \___||___/\__|

Infrastructure
```

Talk to the forestkeepers in the `forest`-channel on Slack.

[![Slack](https://philips-software-slackin.now.sh/badge.svg)](https://philips-software-slackin.now.sh)
[aws-eks-docs]: https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html