This repository was archived by the owner on Jul 11, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 10 files changed +128
-2
lines changed Expand file tree Collapse file tree 10 files changed +128
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ variable "cidr_blocks" {
1717 type = list (string )
1818}
1919
20+ variable "ipv6_cidr_blocks" {
21+ description = " List of IPv6 CIDR block ranges that the SG allows ingress from"
22+ type = list (string )
23+ default = []
24+ }
25+
2026variable "description" {
2127 description = " Use this string to add a description for the SG rule"
2228 type = string
@@ -53,6 +59,7 @@ resource "aws_security_group_rule" "tcp_ingress" {
5359 to_port = var. port
5460 protocol = " tcp"
5561 cidr_blocks = var. cidr_blocks
62+ ipv6_cidr_blocks = var. ipv6_cidr_blocks
5663 security_group_id = var. security_group_id
5764}
5865
@@ -65,5 +72,6 @@ resource "aws_security_group_rule" "udp_ingress" {
6572 to_port = var. port
6673 protocol = " udp"
6774 cidr_blocks = var. cidr_blocks
75+ ipv6_cidr_blocks = var. ipv6_cidr_blocks
6876 security_group_id = var. security_group_id
6977}
Original file line number Diff line number Diff line change 1+ ## AWS subnet IPv6
2+
3+ Creates a single IPv6 ready subnet
Original file line number Diff line number Diff line change 1+ /* *
2+ * ## AWS Subnet IPv6
3+ * Creates a single IPv6 ready subnet
4+ *
5+ */
6+
7+ resource "aws_subnet" "main" {
8+ vpc_id = var. vpc_id
9+ cidr_block = var. cidr_block
10+ ipv6_cidr_block = cidrsubnet (var. vpc_ipv6_cidr_block , var. ipv6_newbits , var. ipv6_netsum )
11+ availability_zone = var. az
12+
13+ tags = merge (
14+ {
15+ " Name" = " ${ var . name_prefix } -${ var . az } "
16+ },
17+ var. extra_tags ,
18+ )
19+
20+ map_public_ip_on_launch = var. public
21+ assign_ipv6_address_on_creation = true
22+ }
Original file line number Diff line number Diff line change 1+ output "id" {
2+ description = " The subnet id"
3+ value = aws_subnet. main . id
4+ }
5+
6+ output "cidr_block" {
7+ description = " The IPv4 CIDR block"
8+ value = aws_subnet. main . cidr_block
9+ }
10+
11+ output "ipv6_cidr_block" {
12+ description = " The IPv6 CIDR block"
13+ value = aws_subnet. main . ipv6_cidr_block
14+ }
15+
16+ output "az" {
17+ value = aws_subnet. main . availability_zone
18+ description = " The availability zones of the subnet"
19+ }
20+
21+ output "vpc_id" {
22+ description = " ID of the VPC the subnet is in"
23+ value = var. vpc_id
24+ }
25+
Original file line number Diff line number Diff line change 1+ variable "name_prefix" {
2+ description = " Name to prefix subnets with"
3+ type = string
4+ }
5+
6+ variable "vpc_id" {
7+ description = " VPC ID where subnets will be created"
8+ type = string
9+ }
10+
11+ variable "cidr_block" {
12+ description = " The IPv4 CIDR block for the subnet"
13+ type = string
14+ }
15+
16+ variable "az" {
17+ description = " The Availaiblity Zones to create the subnet in"
18+ type = string
19+ }
20+
21+ variable "extra_tags" {
22+ default = {}
23+ description = " Extra tags that will be added to aws_subnet resources"
24+ type = map (string )
25+ }
26+
27+ # default to creating a public subnet
28+ variable "public" {
29+ default = true
30+ description = " Boolean, maps to the map_public_ip_on_launch variable"
31+ type = bool
32+ }
33+
34+ variable "vpc_ipv6_cidr_block" {
35+ description = " The IPv6 cidr block for the vpc"
36+ type = string
37+ }
38+
39+ variable "ipv6_newbits" {
40+ description = " The number of additional bits with which to extend the prefix"
41+ type = number
42+ default = 8
43+ }
44+
45+ variable "ipv6_netsum" {
46+ description = " a whole number that can be represented as a binary integer with no more than newbits binary digits"
47+ type = number
48+ default = 162
49+ }
Original file line number Diff line number Diff line change 1+
2+ terraform {
3+ required_version = " >= 0.12"
4+ }
Original file line number Diff line number Diff line change @@ -28,6 +28,5 @@ variable "extra_tags" {
2828variable "public" {
2929 default = true
3030 description = " Boolean, maps to the map_public_ip_on_launch variable"
31- type = string # no boolean type...
31+ type = bool
3232}
33-
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ resource "aws_vpc" "main" {
1616 enable_dns_hostnames = var. enable_dns_hostnames
1717 enable_dns_support = var. enable_dns_support
1818
19+ assign_generated_ipv6_cidr_block = var. assign_generated_ipv6_cidr_block
20+
1921 tags = merge (
2022 {
2123 " Name" = var.name_prefix
Original file line number Diff line number Diff line change @@ -13,3 +13,10 @@ output "dhcp_options_id" {
1313 description = " ID of the DHCP options resource"
1414}
1515
16+ # It would be great if Terraform had an Option or Maybe type
17+ # Otherwise this will output an empty default value if the IPv6 option is not
18+ # set to true
19+ output "ipv6_cidr_block" {
20+ value = (var. assign_generated_ipv6_cidr_block ? aws_vpc. main . ipv6_cidr_block : " " )
21+ description = " Optional IPv6 CIDR block output for the VPC"
22+ }
Original file line number Diff line number Diff line change @@ -35,6 +35,13 @@ variable "dns_servers" {
3535 default = [" AmazonProvidedDNS" ]
3636 description = " list of DNS servers for the DHCP options resource"
3737 type = list (string )
38+
39+ }
40+
41+ variable "assign_generated_ipv6_cidr_block" {
42+ description = " Whether to request an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC"
43+ type = bool
44+ default = false
3845}
3946
4047variable "ntp_servers" {
You can’t perform that action at this time.
0 commit comments