This repository was archived by the owner on Jul 11, 2023. It is now read-only.
File tree 10 files changed +128
-2
lines changed
10 files changed +128
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ variable "cidr_blocks" {
17
17
type = list (string )
18
18
}
19
19
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
+
20
26
variable "description" {
21
27
description = " Use this string to add a description for the SG rule"
22
28
type = string
@@ -53,6 +59,7 @@ resource "aws_security_group_rule" "tcp_ingress" {
53
59
to_port = var. port
54
60
protocol = " tcp"
55
61
cidr_blocks = var. cidr_blocks
62
+ ipv6_cidr_blocks = var. ipv6_cidr_blocks
56
63
security_group_id = var. security_group_id
57
64
}
58
65
@@ -65,5 +72,6 @@ resource "aws_security_group_rule" "udp_ingress" {
65
72
to_port = var. port
66
73
protocol = " udp"
67
74
cidr_blocks = var. cidr_blocks
75
+ ipv6_cidr_blocks = var. ipv6_cidr_blocks
68
76
security_group_id = var. security_group_id
69
77
}
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" {
28
28
variable "public" {
29
29
default = true
30
30
description = " Boolean, maps to the map_public_ip_on_launch variable"
31
- type = string # no boolean type...
31
+ type = bool
32
32
}
33
-
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ resource "aws_vpc" "main" {
16
16
enable_dns_hostnames = var. enable_dns_hostnames
17
17
enable_dns_support = var. enable_dns_support
18
18
19
+ assign_generated_ipv6_cidr_block = var. assign_generated_ipv6_cidr_block
20
+
19
21
tags = merge (
20
22
{
21
23
" Name" = var.name_prefix
Original file line number Diff line number Diff line change @@ -13,3 +13,10 @@ output "dhcp_options_id" {
13
13
description = " ID of the DHCP options resource"
14
14
}
15
15
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" {
35
35
default = [" AmazonProvidedDNS" ]
36
36
description = " list of DNS servers for the DHCP options resource"
37
37
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
38
45
}
39
46
40
47
variable "ntp_servers" {
You can’t perform that action at this time.
0 commit comments