Skip to content

honestbank/terraform-aws-subnet

Repository files navigation

Terraform AWS Subnet module

A simple module that creates subnets for you.

How to use:

Make sure you have a VPC and know what region you are in.

Apply below module:

module "aws-subnet" {
  source = "./aws-subnet"

  subnet_cidr_block = var.subnet_cidr_block
  vpc_id            = aws_vpc.main.id
  subnet_name       = var.subnet_name
  aws_region        = var.aws_region
  aws_role_arn      = var.aws_role_arn
  subnet_tags       = var.subnet_tags
}

aws_role_arn is optional and can be set to null (or omitted)

Some built in features

  • We automatically add the tag CreatedBy = "terraform-aws-subnet" to all subnets. As of now, this can't be turned off.

Requirements

Name Version
terraform ~> 1.0
aws >= 5.0

Providers

Name Version
aws >= 5.0

Modules

Name Source Version
aws-subnet ./aws-subnet n/a

Resources

Name Type
aws_vpc.main resource

Inputs

Name Description Type Default Required
aws_region AWS Region any null no
aws_role_arn AWS Role ARN any null no
subnet_az availability zone string null no
subnet_cidr_block CIDR block for subnet string null no
subnet_name Name for subnet string null no
subnet_tags Tags map(any)
{
"CreatedBy": "terraform-aws-subnet"
}
no
vpc_cidr CIDR block for VPC string "10.0.0.0/16" no
vpc_id VPC ID any null no

Outputs

Name Description
vpc_id n/a