Skip to content

Commit 6149243

Browse files
authored
Merge pull request #64 from drewmullen/contig-block
add option for contig blocks
2 parents ef908fc + a183786 commit 6149243

File tree

8 files changed

+77
-6
lines changed

8 files changed

+77
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.tfstate
66
*.tfstate.*
77
terraform.tfvars
8+
.terraform
89

910
# Crash log files
1011
crash.log

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,22 @@ The IPAM `operating_region` variable must be set for the primary Region in your
146146

147147
| Name | Description | Type | Default | Required |
148148
|------|-------------|------|---------|:--------:|
149-
| <a name="input_top_cidr"></a> [top\_cidr](#input\_top\_cidr) | Top-level CIDR blocks. | `list(string)` | n/a | yes |
150149
| <a name="input_address_family"></a> [address\_family](#input\_address\_family) | IPv4/6 address family. | `string` | `"ipv4"` | no |
151150
| <a name="input_create_ipam"></a> [create\_ipam](#input\_create\_ipam) | Determines whether to create an IPAM. If `false`, you must also provide a var.ipam\_scope\_id. | `bool` | `true` | no |
152151
| <a name="input_ipam_scope_id"></a> [ipam\_scope\_id](#input\_ipam\_scope\_id) | (Optional) Required if `var.ipam_id` is set. Determines which scope to deploy pools into. | `string` | `null` | no |
153152
| <a name="input_ipam_scope_type"></a> [ipam\_scope\_type](#input\_ipam\_scope\_type) | Which scope type to use. Valid inputs include `public` or `private`. You can alternatively provide your own scope ID. | `string` | `"private"` | no |
154153
| <a name="input_pool_configurations"></a> [pool\_configurations](#input\_pool\_configurations) | A multi-level, nested map describing nested IPAM pools. Can nest up to three levels with the top level being outside the `pool_configurations` in vars prefixed `top_`. If arugument descriptions are omitted, you can find them in the [official documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_ipam_pool#argument-reference).<br><br>- `ram_share_principals` = (optional, list(string)) of valid organization principals to create ram shares to.<br>- `name` = (optional, string) name to give the pool, the key of your map in var.pool\_configurations will be used if omitted.<br>- `description` = (optional, string) description to give the pool, the key of your map in var.pool\_configurations will be used if omitted.<br>- `cidr` = (optional, list(string)) list of CIDRs to provision into pool. Conflicts with `netmask_length`.<br>- `netmask_length` = (optional, number) netmask length to request provisioned into pool. Conflicts with `cidr`.<br><br>- `locale` = (optional, string) locale to set for pool.<br>- `auto_import` = (optional, string)<br>- `tags` = (optional, map(string))<br>- `allocation_default_netmask_length` = (optional, string)<br>- `allocation_max_netmask_length` = (optional, string)<br>- `allocation_min_netmask_length` = (optional, string)<br>- `allocation_resource_tags` = (optional, map(string))<br><br>The following arguments are available but only relevant for public ips<br>- `cidr_authorization_context` = (optional, map(string)) Details found in [official documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_ipam_pool_cidr#cidr_authorization_context).<br>- `aws_service` = (optional, string)<br>- `publicly_advertisable` = (optional, bool)<br><br>- `sub_pools` = (nested repeats of pool\_configuration object above) | `any` | `{}` | no |
155154
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to add to the aws\_vpc\_ipam resource. | `any` | `{}` | no |
156155
| <a name="input_top_auto_import"></a> [top\_auto\_import](#input\_top\_auto\_import) | `auto_import` setting for top-level pool. | `bool` | `null` | no |
156+
| <a name="input_top_aws_service"></a> [top\_aws\_service](#input\_top\_aws\_service) | AWS service, for usage with public IPs. Valid values "ec2". | `string` | `null` | no |
157+
| <a name="input_top_cidr"></a> [top\_cidr](#input\_top\_cidr) | Top-level CIDR blocks. | `list(string)` | `null` | no |
157158
| <a name="input_top_cidr_authorization_contexts"></a> [top\_cidr\_authorization\_contexts](#input\_top\_cidr\_authorization\_contexts) | CIDR must match a CIDR defined in `var.top_cidr`. A list of signed documents that proves that you are authorized to bring the specified IP address range to Amazon using BYOIP. Document is not stored in the state file. For more information, refer to https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_ipam_pool_cidr#cidr_authorization_context. | <pre>list(object({<br> cidr = string<br> message = string<br> signature = string<br> }))</pre> | `[]` | no |
158159
| <a name="input_top_description"></a> [top\_description](#input\_top\_description) | Description of top-level pool. | `string` | `""` | no |
160+
| <a name="input_top_locale"></a> [top\_locale](#input\_top\_locale) | locale of the top-level pool. Do not use this value unless building an ipv6 contiguous block pool. You will have to instantiate the module for each operating region you want a pool structure in. | `string` | `null` | no |
159161
| <a name="input_top_name"></a> [top\_name](#input\_top\_name) | Name of top-level pool. | `string` | `null` | no |
160162
| <a name="input_top_netmask_length"></a> [top\_netmask\_length](#input\_top\_netmask\_length) | Top-level netmask length to request. Not possible to use for IPv4. Only possible to use with amazon provided ipv6. | `number` | `null` | no |
163+
| <a name="input_top_public_ip_source"></a> [top\_public\_ip\_source](#input\_top\_public\_ip\_source) | public IP source for usage with public IPs. Valid values "amazon" or "byoip". | `string` | `null` | no |
164+
| <a name="input_top_publicly_advertisable"></a> [top\_publicly\_advertisable](#input\_top\_publicly\_advertisable) | Whether or not the top-level pool is publicly advertisable. | `bool` | `null` | no |
161165
| <a name="input_top_ram_share_principals"></a> [top\_ram\_share\_principals](#input\_top\_ram\_share\_principals) | Principals to create RAM shares for top-level pool. | `list(string)` | `null` | no |
162166

163167
## Outputs
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module "ipv6_contiguous" {
2+
# source = "aws-ia/ipam/aws"
3+
source = "../.."
4+
5+
top_cidr = null
6+
top_netmask_length = "52"
7+
address_family = "ipv6"
8+
ipam_scope_type = "public"
9+
top_aws_service = "ec2"
10+
top_publicly_advertisable = false
11+
top_public_ip_source = "amazon"
12+
top_locale = "us-east-1"
13+
14+
pool_configurations = {
15+
us-east-1 = {
16+
name = "ipv6 us-east-1"
17+
description = "pool for ipv6 us-east-1"
18+
netmask_length = "55"
19+
locale = "us-east-1"
20+
aws_service = "ec2"
21+
publicly_advertisable = false
22+
public_ip_source = "amazon"
23+
24+
sub_pools = {
25+
team_a = {
26+
name = "team_a"
27+
netmask_length = "56"
28+
aws_service = "ec2"
29+
publicly_advertisable = false
30+
public_ip_source = "amazon"
31+
}
32+
}
33+
}
34+
}
35+
}

main.tf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@ module "level_zero" {
4949
cidr_authorization_contexts = var.top_cidr_authorization_contexts
5050

5151
pool_config = {
52-
cidr = var.top_cidr
53-
ram_share_principals = var.top_ram_share_principals
54-
auto_import = var.top_auto_import
55-
description = var.top_description
52+
cidr = var.top_cidr
53+
ram_share_principals = var.top_ram_share_principals
54+
auto_import = var.top_auto_import
55+
description = var.top_description
56+
public_ip_source = var.top_public_ip_source
57+
publicly_advertisable = var.top_publicly_advertisable
58+
aws_service = var.top_aws_service
59+
locale = var.top_locale
60+
5661

5762
name = var.top_name
5863
netmask_length = var.top_netmask_length

modules/sub_pool/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ No modules.
3232
|------|-------------|------|---------|:--------:|
3333
| <a name="input_address_family"></a> [address\_family](#input\_address\_family) | IPv4/6 address family. | `string` | n/a | yes |
3434
| <a name="input_ipam_scope_id"></a> [ipam\_scope\_id](#input\_ipam\_scope\_id) | IPAM Scope ID to attach the pool to. | `string` | n/a | yes |
35-
| <a name="input_pool_config"></a> [pool\_config](#input\_pool\_config) | Configuration of the Pool you want to deploy. All aws\_vpc\_ipam\_pool arguments are available as well as ram\_share\_principals list and sub\_pools map (up to 3 levels). | <pre>object({<br> cidr = optional(list(string))<br> ram_share_principals = optional(list(string))<br><br> locale = optional(string)<br> allocation_default_netmask_length = optional(string)<br> allocation_max_netmask_length = optional(string)<br> allocation_min_netmask_length = optional(string)<br> auto_import = optional(string)<br> aws_service = optional(string)<br> description = optional(string)<br> name = optional(string)<br> netmask_length = optional(number)<br> publicly_advertisable = optional(bool)<br><br> allocation_resource_tags = optional(map(string))<br> tags = optional(map(string))<br><br> sub_pools = optional(any)<br> })</pre> | n/a | yes |
35+
| <a name="input_pool_config"></a> [pool\_config](#input\_pool\_config) | Configuration of the Pool you want to deploy. All aws\_vpc\_ipam\_pool arguments are available as well as ram\_share\_principals list and sub\_pools map (up to 3 levels). | <pre>object({<br> cidr = optional(list(string))<br> ram_share_principals = optional(list(string))<br><br> locale = optional(string)<br> allocation_default_netmask_length = optional(string)<br> allocation_max_netmask_length = optional(string)<br> allocation_min_netmask_length = optional(string)<br> auto_import = optional(string)<br> aws_service = optional(string)<br> description = optional(string)<br> name = optional(string)<br> netmask_length = optional(number)<br> publicly_advertisable = optional(bool)<br> public_ip_source = optional(string)<br><br> allocation_resource_tags = optional(map(string))<br> tags = optional(map(string))<br><br> sub_pools = optional(any)<br> })</pre> | n/a | yes |
3636
| <a name="input_source_ipam_pool_id"></a> [source\_ipam\_pool\_id](#input\_source\_ipam\_pool\_id) | IPAM parent pool ID to attach the pool to. | `string` | n/a | yes |
3737
| <a name="input_cidr_authorization_contexts"></a> [cidr\_authorization\_contexts](#input\_cidr\_authorization\_contexts) | A list of signed documents that proves that you are authorized to bring the specified IP address range to Amazon using BYOIP. Document is not stored in the state file. For more information, refer to https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_ipam_pool_cidr#cidr_authorization_context. | <pre>list(object({<br> cidr = string<br> message = string<br> signature = string<br> }))</pre> | `[]` | no |
3838
| <a name="input_implied_description"></a> [implied\_description](#input\_implied\_description) | Description is implied from the pool tree name <parent>/<child> unless specified on the pool\_config. | `string` | `null` | no |

modules/sub_pool/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ resource "aws_vpc_ipam_pool" "sub" {
3030
auto_import = var.pool_config.auto_import
3131
aws_service = var.pool_config.aws_service
3232
publicly_advertisable = var.pool_config.publicly_advertisable
33+
public_ip_source = var.pool_config.public_ip_source
3334

3435
tags = local.tags
3536
}

modules/sub_pool/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ variable "pool_config" {
1414
name = optional(string)
1515
netmask_length = optional(number)
1616
publicly_advertisable = optional(bool)
17+
public_ip_source = optional(string)
1718

1819
allocation_resource_tags = optional(map(string))
1920
tags = optional(map(string))

variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ EOF
3030
variable "top_cidr" {
3131
description = "Top-level CIDR blocks."
3232
type = list(string)
33+
default = null
3334
}
3435

3536
variable "top_netmask_length" {
@@ -72,6 +73,29 @@ variable "top_cidr_authorization_contexts" {
7273
default = []
7374
}
7475

76+
variable "top_public_ip_source" {
77+
description = "public IP source for usage with public IPs. Valid values \"amazon\" or \"byoip\"."
78+
type = string
79+
default = null
80+
}
81+
82+
variable "top_publicly_advertisable" {
83+
description = "Whether or not the top-level pool is publicly advertisable."
84+
type = bool
85+
default = null
86+
}
87+
88+
variable "top_aws_service" {
89+
description = "AWS service, for usage with public IPs. Valid values \"ec2\"."
90+
type = string
91+
default = null
92+
}
93+
94+
variable "top_locale" {
95+
description = "locale of the top-level pool. Do not use this value unless building an ipv6 contiguous block pool. You will have to instantiate the module for each operating region you want a pool structure in."
96+
type = string
97+
default = null
98+
}
7599

76100
variable "address_family" {
77101
description = "IPv4/6 address family."

0 commit comments

Comments
 (0)