This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial support for IPv6 to the vpc module and add the subnet-ipv…
…6 module
- Loading branch information
Mike McGirr
committed
Mar 22, 2020
1 parent
dad0d84
commit a4ad35f
Showing
10 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## AWS subnet IPv6 | ||
|
||
Creates a single IPv6 ready subnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* ## AWS Subnet IPv6 | ||
* Creates a single IPv6 ready subnet | ||
* | ||
*/ | ||
|
||
resource "aws_subnet" "main" { | ||
vpc_id = var.vpc_id | ||
cidr_block = var.cidr_block | ||
ipv6_cidr_block = cidrsubnet(var.vpc_ipv6_cidr_block, var.ipv6_newbits, var.ipv6_netsum) | ||
availability_zone = var.az | ||
|
||
tags = merge( | ||
{ | ||
"Name" = "${var.name_prefix}-${var.az}" | ||
}, | ||
var.extra_tags, | ||
) | ||
|
||
map_public_ip_on_launch = var.public | ||
assign_ipv6_address_on_creation = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
output "id" { | ||
description = "The subnet id" | ||
value = aws_subnet.main.id | ||
} | ||
|
||
output "cidr_block" { | ||
description = "The IPv4 CIDR block" | ||
value = aws_subnet.main.cidr_block | ||
} | ||
|
||
output "ipv6_cidr_block" { | ||
description = "The IPv6 CIDR block" | ||
value = aws_subnet.main.ipv6_cidr_block | ||
} | ||
|
||
output "az" { | ||
value = aws_subnet.main.availability_zone | ||
description = "The availability zones of the subnet" | ||
} | ||
|
||
output "vpc_id" { | ||
description = "ID of the VPC the subnet is in" | ||
value = var.vpc_id | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
variable "name_prefix" { | ||
description = "Name to prefix subnets with" | ||
type = string | ||
} | ||
|
||
variable "vpc_id" { | ||
description = "VPC ID where subnets will be created" | ||
type = string | ||
} | ||
|
||
variable "cidr_block" { | ||
description = "The IPv4 CIDR block for the subnet" | ||
type = string | ||
} | ||
|
||
variable "az" { | ||
description = "The Availaiblity Zones to create the subnet in" | ||
type = string | ||
} | ||
|
||
variable "extra_tags" { | ||
default = {} | ||
description = "Extra tags that will be added to aws_subnet resources" | ||
type = map(string) | ||
} | ||
|
||
# default to creating a public subnet | ||
variable "public" { | ||
default = true | ||
description = "Boolean, maps to the map_public_ip_on_launch variable" | ||
type = bool | ||
} | ||
|
||
variable "vpc_ipv6_cidr_block" { | ||
description = "The IPv6 cidr block for the vpc" | ||
type = string | ||
} | ||
|
||
variable "ipv6_newbits" { | ||
description = "The number of additional bits with which to extend the prefix" | ||
type = number | ||
default = 8 | ||
} | ||
|
||
variable "ipv6_netsum" { | ||
description = "a whole number that can be represented as a binary integer with no more than newbits binary digits" | ||
type = number | ||
default = 162 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters