Skip to content

Commit 6244a51

Browse files
authored
feat!: Expose output addresses and also validate the input variable and make names required (#173)
1 parent 0ea39ef commit 6244a51

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Terraform may change this fact, but this is the current limitation.
197197
| global | The scope in which the address should live. If set to true, the IP address will be globally scoped. Defaults to false, i.e. regionally scoped. When set to true, do not provide a subnetwork. | `bool` | `false` | no |
198198
| ip\_version | The IP Version that will be used by this address. | `string` | `"IPV4"` | no |
199199
| labels | Labels to apply to this address. | `map(string)` | `{}` | no |
200-
| names | A list of IP address resource names to create. This is the GCP resource name and not the associated hostname of the IP address. Existing resource names may be found with `gcloud compute addresses list` (e.g. ["gusw1-dev-fooapp-fe-0001-a-001-ip"]) | `list(string)` | `[]` | no |
200+
| names | A list of IP address resource names to create. This is the GCP resource name and not the associated hostname of the IP address. Existing resource names may be found with `gcloud compute addresses list` (e.g. ["gusw1-dev-fooapp-fe-0001-a-001-ip"]) | `list(string)` | n/a | yes |
201201
| network\_tier | The networking tier used for configuring this address. | `string` | `"PREMIUM"` | no |
202202
| prefix\_length | The prefix length of the IP range. | `number` | `16` | no |
203203
| project\_id | The project ID to create the address in | `string` | n/a | yes |

metadata.display.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ spec:
7575
names:
7676
name: names
7777
title: Names
78-
level: 1
78+
regexValidation: "^[a-z]([-a-z0-9]*[a-z0-9])?$"
79+
validation: "Each name must be 1-63 chars, start with lowercase, and be RFC1035 compliant."
7980
network_tier:
8081
name: network_tier
8182
title: Network Tier
@@ -95,3 +96,7 @@ spec:
9596
name: subnetwork
9697
title: Subnetwork
9798
level: 1
99+
runtime:
100+
outputs:
101+
addresses:
102+
visibility: VISIBILITY_ROOT

metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ spec:
6161
- name: names
6262
description: A list of IP address resource names to create. This is the GCP resource name and not the associated hostname of the IP address. Existing resource names may be found with `gcloud compute addresses list` (e.g. ["gusw1-dev-fooapp-fe-0001-a-001-ip"])
6363
varType: list(string)
64-
defaultValue: []
64+
required: true
6565
- name: addresses
6666
description: A list of IP addresses to create. GCP will reserve unreserved addresses if given the value "". If multiple names are given the default value is sufficient to have multiple addresses automatically picked for each name.
6767
varType: list(string)

variables.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ variable "region" {
2525
}
2626

2727
variable "names" {
28-
description = "A list of IP address resource names to create. This is the GCP resource name and not the associated hostname of the IP address. Existing resource names may be found with `gcloud compute addresses list` (e.g. [\"gusw1-dev-fooapp-fe-0001-a-001-ip\"])"
28+
description = "A list of IP address resource names to create. This is the GCP resource name and not the associated hostname of the IP address. Existing resource names may be found with `gcloud compute addresses list` (e.g. [\"gusw1-dev-fooapp-fe-0001-a-001-ip\"])"
2929
type = list(string)
30-
default = []
30+
31+
validation {
32+
condition = alltrue([
33+
for n in var.names : can(regex("^[a-z]([-a-z0-9]*[a-z0-9])?$", n)) && length(n) <= 63
34+
])
35+
error_message = "Each name must be 1-63 chars, start with lowercase, and be RFC1035 compliant."
36+
}
3137
}
3238

3339
variable "addresses" {

0 commit comments

Comments
 (0)