diff --git a/README.md b/README.md index a694fbe..b96e85f 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,28 @@ -# How to use this template +# Terraform module - VPC Factory -## Desciption +## Usage -This is a template for a minimal terraform module under GNU General Public License version 3. +``` +module "network" { + source = "git:https://gitea.fillon.info/terraform-modules/terraform-aws-vpc-factory?ref=main" - -## Todo - -* workflows / actions (.tf format and validate) -* git hooks + cidr_block = "10.0.0.0/16" +} +``` ## Requirements -No requirements. +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >=1.0.0 | +| [aws](#requirement\_aws) | >=4.0 | ## Providers -No providers. +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | 5.33.0 | ## Modules @@ -25,13 +30,21 @@ No modules. ## Resources -No resources. +| Name | Type | +|------|------| +| [aws_vpc.self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource | +| [aws_availability_zones.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source | ## Inputs -No inputs. +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [cidr\_block](#input\_cidr\_block) | The IPv4 CIDR block for the VPC. | `string` | `"10.0.0.0/16"` | no | ## Outputs -No outputs. +| Name | Description | +|------|-------------| +| [aws\_availability\_zones](#output\_aws\_availability\_zones) | List of available AZ names. | +| [vpc](#output\_vpc) | value | diff --git a/examples/minimum/README.md b/examples/minimum/README.md new file mode 100644 index 0000000..4ee1399 --- /dev/null +++ b/examples/minimum/README.md @@ -0,0 +1,46 @@ +# Minimum VPC Factory + +Configuration in this directory creates a VPC from module VPC Factory with default variables values. + +## Usage + +To run this example you need to execute: + +```bash +terraform init +terraform plan +terraform apply +``` + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >=1.0 | +| [aws](#requirement\_aws) | >=4.0 | + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [vpc](#module\_vpc) | ../.. | n/a | + +## Resources + +No resources. + +## Inputs + +No inputs. + +## Outputs + +| Name | Description | +|------|-------------| +| [module](#output\_module) | VPC module outputs | + diff --git a/examples/minimum/main.tf b/examples/minimum/main.tf new file mode 100644 index 0000000..e3b029a --- /dev/null +++ b/examples/minimum/main.tf @@ -0,0 +1,22 @@ +provider "aws" { + region = local.region + + default_tags { + tags = local.tags + } +} + +locals { + name = "ex-${basename(path.cwd)}" + region = "eu-west-1" + + tags = { + Example = local.name + Repo = "terraform-aws-vpc-factory" + Org = "terraform-modules" + } +} + +module "vpc" { + source = "../.." +} diff --git a/examples/minimum/outputs.tf b/examples/minimum/outputs.tf new file mode 100644 index 0000000..095271b --- /dev/null +++ b/examples/minimum/outputs.tf @@ -0,0 +1,4 @@ +output "module" { + description = "VPC module outputs" + value = module.vpc +} diff --git a/examples/minimum/variables.tf b/examples/minimum/variables.tf new file mode 100644 index 0000000..e69de29 diff --git a/examples/minimum/versions.tf b/examples/minimum/versions.tf new file mode 100644 index 0000000..14cf5f6 --- /dev/null +++ b/examples/minimum/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">=1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">=4.0" + } + } +} diff --git a/main.tf b/main.tf index e69de29..52fa863 100644 --- a/main.tf +++ b/main.tf @@ -0,0 +1,44 @@ +terraform { + required_version = ">=1.0.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">=4.0" + } + } +} + +data "aws_availability_zones" "current" { + state = "available" +} + +resource "aws_vpc" "self" { + cidr_block = var.cidr_block +} + +resource "aws_default_route_table" "self" { + default_route_table_id = aws_vpc.self.default_route_table_id + + route = [] +} + +resource "aws_default_network_acl" "self" { + default_network_acl_id = aws_vpc.self.default_network_acl_id +} + +resource "aws_default_security_group" "self" { + vpc_id = aws_vpc.self.id +} + +resource "aws_default_vpc_dhcp_options" "default" { + lifecycle { + ignore_changes = [tags_all] + } +} + +resource "aws_subnet" "public" { + for_each = var.public_subnets + + vpc_id = aws_vpc.self.id +} diff --git a/outputs.tf b/outputs.tf index e69de29..4ac9a38 100644 --- a/outputs.tf +++ b/outputs.tf @@ -0,0 +1,9 @@ +output "aws_availability_zones" { + description = "List of available AZ names." + value = data.aws_availability_zones.current.names +} + +output "vpc" { + description = "value" + value = aws_vpc.self +} diff --git a/variables.tf b/variables.tf index e69de29..2e84209 100644 --- a/variables.tf +++ b/variables.tf @@ -0,0 +1,33 @@ +variable "cidr_block" { + description = "The IPv4 CIDR block for the VPC." + type = string + default = "10.0.0.0/16" +} + +# variable "public_cidr_block" { +# description = "Alternate CIDR block " +# type = string +# default = "" +# } + +# variable "internal_cidr_block" { +# description = "value" +# type = string +# default = "" +# } + +variable "public_subnets" { + description = "Map of public subnets" + type = map(object({ + cidr_block = string + })) + default = {} +} + +# variable "private_subnets" { + +# } + +# variable "internal_subnets" { + +# }