Skip to content

Commit

Permalink
Update several variable names for consistency across modules
Browse files Browse the repository at this point in the history
  • Loading branch information
John Titus committed Dec 13, 2019
1 parent 70ce6dd commit 15acd0b
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 33 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ By default only `vpc_name` is required to be set. Unless changed `aws_region` de
| build\_vpn | Whether or not to build a VPN gateway | string | `"false"` | no |
| cidr\_range | CIDR range for the VPC | string | `"172.18.0.0/19"` | no |
| custom\_azs | A list of AZs that VPC resources will reside in | list | `<list>` | no |
| custom\_tags | Optional tags to be applied on top of the base tags on all resources | map | `<map>` | no |
| default\_tenancy | Default tenancy for instances. Either multi-tenant (default) or single-tenant (dedicated) | string | `"default"` | no |
| domain\_name | Custom domain name for the VPC | string | `""` | no |
| domain\_name\_servers | Array of custom domain name servers | list | `<list>` | no |
Expand All @@ -50,6 +49,7 @@ By default only `vpc_name` is required to be set. Unless changed `aws_region` de
| logging\_bucket\_name | Bucket name to store s3 flow logs. If empty, to create random bucket name. In conjuction with build_s3_flow_logs | string | `""` | no |
| logging\_bucket\_prefix | The prefix for the location in the S3 bucket. If you don't specify a prefix, the access logs are stored in the root of the bucket. | string | `""` | no |
| logging\_bucket\_retention | The number of days to retain load balancer logs. 0 to ratain forever. | string | `"14"` | no |
| name | Name for the VPC and related resources | string | n/a | yes |
| private\_cidr\_ranges | An array of CIDR ranges to use for private subnets | list | `<list>` | no |
| private\_subnet\_names | Text that will be included in generated name for private subnets. Given the default value of `["Private"]`, subnet names in the form \"<vpc_name>-Private<count+1>\", e.g. \"MyVpc-Public2\" will be produced. Otherwise, given a list of names with length the same as the value of `az_count`, the first `az_count` subnets will be named using the first string in the list, the second `az_count` subnets will be named using the second string, and so on. | list | `<list>` | no |
| private\_subnet\_tags | A list of maps containing tags to be applied to private subnets. List should either be the same length as the number of AZs to apply different tags per set of subnets, or a length of 1 to apply the same tags across all private subnets. | list | `<list>` | no |
Expand All @@ -59,7 +59,7 @@ By default only `vpc_name` is required to be set. Unless changed `aws_region` de
| public\_subnet\_tags | A list of maps containing tags to be applied to public subnets. List should either be the same length as the number of AZs to apply different tags per set of subnets, or a length of 1 to apply the same tags across all public subnets. | list | `<list>` | no |
| public\_subnets\_per\_az | Number of public subnets to create in each AZ. NOTE: This value, when multiplied by the value of `az_count`, should not exceed the length of the `public_cidr_ranges` list! | string | `"1"` | no |
| spoke\_vpc | Whether or not the VPN gateway is a spoke of a Transit VPC | string | `"false"` | no |
| vpc\_name | Name for the VPC | string | n/a | yes |
| tags | Optional tags to be applied on top of the base tags on all resources | map | `<map>` | no |

## Outputs

Expand All @@ -76,4 +76,3 @@ By default only `vpc_name` is required to be set. Unless changed `aws_region` de
| public\_subnets | The IDs of the public subnets |
| vpc\_id | The ID of the VPC |
| vpn\_gateway | The ID of the VPN gateway if one was created |

4 changes: 2 additions & 2 deletions examples/basic_usage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ provider "aws" {

module "vpc" {
source = "[email protected]:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.10"
vpc_name = "MyVPC"

name = "MyVPC"
}
2 changes: 1 addition & 1 deletion examples/custom_azs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ provider "aws" {
module "vpc" {
source = "[email protected]:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.10"

vpc_name = "MyVPC"
name = "MyVPC"
custom_azs = ["us-west-2a", "us-west-2b"]

cidr_range = "10.0.0.0/19"
Expand Down
2 changes: 1 addition & 1 deletion examples/vpn_provided.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ provider "aws" {
module "vpc" {
source = "[email protected]:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork//?ref=v0.0.10"

vpc_name = "MyVPC"
name = "MyVPC"
build_vpn = true
spoke_vpc = true
}
28 changes: 14 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ locals {
}

tags = merge(
var.custom_tags,
var.tags,
local.base_tags
)

Expand Down Expand Up @@ -72,7 +72,7 @@ resource "aws_vpc" "vpc" {
tags = merge(
local.tags,
{
Name = var.vpc_name
Name = var.name
},
)

Expand All @@ -88,7 +88,7 @@ resource "aws_vpc_dhcp_options" "dhcp_options" {
tags = merge(
local.tags,
{
Name = "${var.vpc_name}-DHCPOptions"
Name = "${var.name}-DHCPOptions"
},
)
}
Expand All @@ -106,7 +106,7 @@ resource "aws_internet_gateway" "igw" {
tags = merge(
local.tags,
{
Name = format("%s-IGW", var.vpc_name)
Name = format("%s-IGW", var.name)
},
)
}
Expand All @@ -123,7 +123,7 @@ resource "aws_eip" "nat_eip" {
tags = merge(
local.tags,
{
Name = format("%s-NATEIP%d", var.vpc_name, count.index + 1)
Name = format("%s-NATEIP%d", var.name, count.index + 1)
},
)

Expand All @@ -139,7 +139,7 @@ resource "aws_nat_gateway" "nat" {
tags = merge(
local.tags,
{
Name = format("%s-NATGW%d", var.vpc_name, count.index + 1)
Name = format("%s-NATGW%d", var.name, count.index + 1)
},
)

Expand All @@ -164,7 +164,7 @@ resource "aws_subnet" "public_subnet" {
{
Name = format(
"%s-%s%d",
var.vpc_name,
var.name,
element(var.public_subnet_names, floor(count.index / var.az_count)),
count.index % var.az_count + 1,
)
Expand All @@ -186,7 +186,7 @@ resource "aws_subnet" "private_subnet" {
{
Name = format(
"%s-%s%d",
var.vpc_name,
var.name,
element(var.private_subnet_names, floor(count.index / var.az_count)),
count.index % var.az_count + 1,
)
Expand All @@ -206,7 +206,7 @@ resource "aws_route_table" "public_route_table" {
tags = merge(
local.tags,
{
Name = format("%s-PublicRouteTable", var.vpc_name)
Name = format("%s-PublicRouteTable", var.name)
},
)
}
Expand All @@ -219,7 +219,7 @@ resource "aws_route_table" "private_route_table" {
tags = merge(
local.tags,
{
Name = format("%s-PrivateRouteTable%d", var.vpc_name, count.index + 1)
Name = format("%s-PrivateRouteTable%d", var.name, count.index + 1)
},
)
}
Expand Down Expand Up @@ -266,7 +266,7 @@ resource "aws_vpn_gateway" "vpn_gateway" {
tags = merge(
local.tags,
{
Name = format("%s-VPNGateway", var.vpc_name)
Name = format("%s-VPNGateway", var.name)
"transitvpc:spoke" = var.spoke_vpc
},
)
Expand Down Expand Up @@ -338,13 +338,13 @@ resource "aws_flow_log" "cw_vpc_log" {
resource "aws_cloudwatch_log_group" "flowlog_group" {
count = var.build_flow_logs ? 1 : 0

name = "${var.vpc_name}-FlowLogs"
name = "${var.name}-FlowLogs"
}

resource "aws_iam_role" "flowlog_role" {
count = var.build_flow_logs ? 1 : 0

name = "${var.vpc_name}-FlowLogsRole"
name = "${var.name}-FlowLogsRole"

assume_role_policy = <<EOF
{
Expand All @@ -367,7 +367,7 @@ EOF
resource "aws_iam_role_policy" "flowlog_policy" {
count = var.build_flow_logs ? 1 : 0

name = "${var.vpc_name}-FlowLogsPolicy"
name = "${var.name}-FlowLogsPolicy"
role = aws_iam_role.flowlog_role[0].id

policy = <<EOF
Expand Down
2 changes: 1 addition & 1 deletion tests/test1/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ provider "aws" {
module "vpc" {
source = "../../module"

vpc_name = "Test1VPC"
name = "Test1VPC"
}
2 changes: 1 addition & 1 deletion tests/test2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ provider "aws" {
module "vpc" {
source = "../../module"

vpc_name = "Test2VPC"
name = "Test2VPC"
custom_azs = ["us-west-2a", "us-west-2b"]

cidr_range = "172.19.0.0/19"
Expand Down
2 changes: 1 addition & 1 deletion tests/test3/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ provider "aws" {
module "vpc" {
source = "../../module"

vpc_name = "Test1VPC"
name = "Test1VPC"
build_igw = "false"
}
19 changes: 10 additions & 9 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ variable "custom_azs" {
default = []
}

variable "custom_tags" {
description = "Optional tags to be applied on top of the base tags on all resources"
type = map(string)
default = {}
}

variable "default_tenancy" {
description = "Default tenancy for instances. Either multi-tenant (default) or single-tenant (dedicated)"
type = string
Expand Down Expand Up @@ -134,6 +128,11 @@ variable "logging_bucket_retention" {
default = "14"
}

variable "name" {
description = "Name prefix for the VPC and related resources"
type = string
}

variable "private_cidr_ranges" {
description = "An array of CIDR ranges to use for private subnets"
type = list(string)
Expand Down Expand Up @@ -219,7 +218,9 @@ variable "spoke_vpc" {
type = string
default = "false"
}
variable "vpc_name" {
description = "Name for the VPC"
type = string

variable "tags" {
description = "Optional tags to be applied on top of the base tags on all resources"
type = map(string)
default = {}
}

0 comments on commit 15acd0b

Please sign in to comment.