Skip to content

Commit

Permalink
fix: feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Williams2 authored and Jordan-Williams2 committed Jan 8, 2024
1 parent b2eab2a commit 8768804
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ An IBM Provider [issue](https://github.com/IBM-Cloud/terraform-provider-ibm/issu
* [Examples](./examples)
* [End-to-end example](./examples/default)
* [Every multi-tenant VPE](./examples/every-mt-vpe)
* [Existing Reserved IP example](./examples/reserved-ips)
* [Existing Reserved IP's example](./examples/reserved-ips)
* [Contributing](#contributing)
<!-- END OVERVIEW HOOK -->

Expand Down
4 changes: 2 additions & 2 deletions examples/reserved-ips/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Existing Reserved IP example
# Existing Reserved IP's example

This example creates reserved ip's in the example and passes those values to the main modules `reserved_ips` variable which will use those existing reserved ip's instead of creating new values.

Expand All @@ -8,7 +8,7 @@ This example creates the following infrastructure:
- The VPC is created with three subnets across the three availability zones of the region that is passed as input.
- A security group in the VPC.
- The security group is created with a single inbound rule that allows traffic from resources that are attached to the default VPC security group. This rule is added as an example.
- The reserved IPs are created. These are later passed to the gateway as an example of how the reserved IP module could be used.
- The reserved IPs are created. These are later passed to the gateway as an example of how the reserved IP's module could be used.
- Two virtual private endpoint (VPE) gateways. By default, one VPE to COS and another VPE to Key Protect are created. You can change the defaults by using the `service_endpoints` input.
- Each of the two virtual private endpoint gateways are attached to the three VPC subnets.
- The new security group is attached to the two VPE gateways.
Expand Down
14 changes: 7 additions & 7 deletions modules/reserved-ips/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IBM Reserved IP Module
# Reserved IP's Module

The module creates reserved IP's (https://cloud.ibm.com/docs/vpc?topic=vpc-managing-ip-addresses) on existing subnets. Reserved IP's can be assigned to your resources, for example VPE endpoint gateways.

Expand Down Expand Up @@ -104,13 +104,13 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cloud_service_by_crn"></a> [cloud\_service\_by\_crn](#input\_cloud\_service\_by\_crn) | List of cloud service CRNs. Each CRN will have a unique endpoint gateways created. For a list of supported services, see the docs [here](https://cloud.ibm.com/docs/vpc?topic=vpc-vpe-supported-services). | <pre>list(<br> object({<br> name = string # service name<br> crn = string # service crn<br> })<br> )</pre> | `[]` | no |
| <a name="input_cloud_services"></a> [cloud\_services](#input\_cloud\_services) | List of cloud services to create an endpoint gateway. The keys are the service names, the values (all optional) give some level of control on the created VPEs. | <pre>set(object({<br> service_name = string<br> vpe_name = optional(string), # Full control on the VPE name. If not specified, the VPE name will be computed based on prefix, vpc name and service name.<br> allow_dns_resolution_binding = optional(bool, false)<br> }))</pre> | `[]` | no |
| <a name="input_endpoint_ip_list"></a> [endpoint\_ip\_list](#input\_endpoint\_ip\_list) | List of IPs to create. Each object contains an IP name and subnet id | <pre>list(<br> object({<br> ip_name = string # reserved ip name<br> subnet_id = string # subnet id<br> gateway_name = string # gateway name<br> name = string # ip name<br> })<br> )</pre> | `[]` | no |
| <a name="input_cloud_services"></a> [cloud\_services](#input\_cloud\_services) | List of cloud services to create reserved ip's for. The keys are the service names, the values (all optional) give some level of control on the created VPEs. | <pre>set(object({<br> service_name = string<br> vpe_name = optional(string), # Full control on the VPE name. If not specified, the VPE name will be computed based on prefix, vpc name and service name.<br> }))</pre> | `[]` | no |
| <a name="input_endpoint_ip_list"></a> [endpoint\_ip\_list](#input\_endpoint\_ip\_list) | List of IP's to create. Each object contains an ip name and subnet id | <pre>list(<br> object({<br> ip_name = string # reserved ip name<br> subnet_id = string # subnet id<br> gateway_name = string # gateway name<br> name = string # ip name<br> })<br> )</pre> | `[]` | no |
| <a name="input_prefix"></a> [prefix](#input\_prefix) | The prefix that you would like to append to your resources. Value is only used if no value is passed for the `vpe_name` option in the `cloud_services` input variable. | `string` | `"vpe"` | no |
| <a name="input_region"></a> [region](#input\_region) | The region where VPC and services are deployed | `string` | `"us-south"` | no |
| <a name="input_reserved_ips"></a> [reserved\_ips](#input\_reserved\_ips) | Map of existing reserved IP names and values. Leave this value as default if you want to create new reserved ips, this value is used in the main module in which a user passes their existing reserved ips created here so as to not attempt to recreate them. | <pre>object({<br> name = optional(string) # endpoint gateway IP ID<br> })</pre> | `{}` | no |
| <a name="input_subnet_zone_list"></a> [subnet\_zone\_list](#input\_subnet\_zone\_list) | List of subnets in the VPC where gateways and reserved IPs will be provisioned. This value is intended to use the `subnet_zone_list` output from the Landing Zone VPC Subnet Module (https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc) or from templates using that module for subnet creation. | <pre>list(<br> object({<br> name = string<br> id = string<br> zone = optional(string)<br> cidr = optional(string)<br> })<br> )</pre> | `[]` | no |
| <a name="input_vpc_name"></a> [vpc\_name](#input\_vpc\_name) | Name of the VPC where the Endpoint Gateways will be created. This value is used to dynamically generate VPE names. Value is only used if no value is passed for the `vpe_name` option in the `cloud_services` input variable. | `string` | `"vpc"` | no |
| <a name="input_region"></a> [region](#input\_region) | The region to be used in the reserved ip naming convention. | `string` | `"us-south"` | no |
| <a name="input_reserved_ips"></a> [reserved\_ips](#input\_reserved\_ips) | Map of existing reserved IP names and values. Leave this value as default if you want to create new reserved ip's, this value is used in the main module in which a user passes their existing reserved ips created here so as to not attempt to recreate them. | <pre>object({<br> name = optional(string) # endpoint gateway IP ID<br> })</pre> | `{}` | no |
| <a name="input_subnet_zone_list"></a> [subnet\_zone\_list](#input\_subnet\_zone\_list) | List of subnets in the VPC where reserved IPs will be provisioned. This value is intended to use the `subnet_zone_list` output from the Landing Zone VPC Subnet Module (https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc) or from templates using that module for subnet creation. | <pre>list(<br> object({<br> name = string<br> id = string<br> zone = optional(string)<br> })<br> )</pre> | `[]` | no |
| <a name="input_vpc_name"></a> [vpc\_name](#input\_vpc\_name) | Name of the VPC that will be used when naming the newly created reserved ip's. Value is only used if no value is passed for the `vpe_name` option in the `cloud_services` input variable. | `string` | `"vpc"` | no |

### Outputs

Expand Down
14 changes: 6 additions & 8 deletions modules/reserved-ips/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@ locals {
concat([
for service in var.cloud_services :
{
ip_name = "${subnet.name}-${service.service_name}-gateway-${replace(subnet.zone, "/${var.region}-/", "")}-ip"
subnet_id = subnet.id
gateway_name = service.vpe_name != null ? service.vpe_name : "${var.prefix}-${var.vpc_name}-${service.service_name}"
name = service.vpe_name != null ? "${service.vpe_name}-${replace(subnet.zone, "/${var.region}-/", "")}" : "${var.prefix}-${var.vpc_name}-${service.service_name}-${replace(subnet.zone, "/${var.region}-/", "")}"
ip_name = "${subnet.name}-${service.service_name}-gateway-${replace(subnet.zone, "/${var.region}-/", "")}-ip"
subnet_id = subnet.id
name = service.vpe_name != null ? "${service.vpe_name}-${replace(subnet.zone, "/${var.region}-/", "")}" : "${var.prefix}-${var.vpc_name}-${service.service_name}-${replace(subnet.zone, "/${var.region}-/", "")}"
}
],
[
for service in var.cloud_service_by_crn :
{
ip_name = service.vpe_name != null ? "${subnet.name}-${service.vpe_name}-gateway-${replace(subnet.zone, "/${var.region}-/", "")}-ip" : "${subnet.name}-${service.service_name != null ? service.service_name : element(split(":", service.crn), 4)}-gateway-${replace(subnet.zone, "/${var.region}-/", "")}-ip"
subnet_id = subnet.id
gateway_name = service.vpe_name != null ? service.vpe_name : "${var.prefix}-${var.vpc_name}-${service.service_name != null ? service.service_name : element(split(":", service.crn), 4)}"
name = service.vpe_name != null ? "${service.vpe_name}-${replace(subnet.zone, "/${var.region}-/", "")}" : "${var.prefix}-${var.vpc_name}-${service.service_name != null ? service.service_name : element(split(":", service.crn), 4)}-${replace(subnet.zone, "/${var.region}-/", "")}"
ip_name = service.vpe_name != null ? "${subnet.name}-${service.vpe_name}-gateway-${replace(subnet.zone, "/${var.region}-/", "")}-ip" : "${subnet.name}-${service.service_name != null ? service.service_name : element(split(":", service.crn), 4)}-gateway-${replace(subnet.zone, "/${var.region}-/", "")}-ip"
subnet_id = subnet.id
name = service.vpe_name != null ? "${service.vpe_name}-${replace(subnet.zone, "/${var.region}-/", "")}" : "${var.prefix}-${var.vpc_name}-${service.service_name != null ? service.service_name : element(split(":", service.crn), 4)}-${replace(subnet.zone, "/${var.region}-/", "")}"
}
])
]) : var.endpoint_ip_list
Expand Down
18 changes: 8 additions & 10 deletions modules/reserved-ips/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "prefix" {
}

variable "vpc_name" {
description = "Name of the VPC where the Endpoint Gateways will be created. This value is used to dynamically generate VPE names. Value is only used if no value is passed for the `vpe_name` option in the `cloud_services` input variable."
description = "Name of the VPC that will be used when naming the newly created reserved ip's. Value is only used if no value is passed for the `vpe_name` option in the `cloud_services` input variable."
type = string
default = "vpc"
}
Expand All @@ -19,13 +19,12 @@ variable "vpc_name" {
##############################################################################

variable "subnet_zone_list" {
description = "List of subnets in the VPC where gateways and reserved IPs will be provisioned. This value is intended to use the `subnet_zone_list` output from the Landing Zone VPC Subnet Module (https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc) or from templates using that module for subnet creation."
description = "List of subnets in the VPC where reserved IPs will be provisioned. This value is intended to use the `subnet_zone_list` output from the Landing Zone VPC Subnet Module (https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc) or from templates using that module for subnet creation."
type = list(
object({
name = string
id = string
zone = optional(string)
cidr = optional(string)
})
)
default = []
Expand All @@ -37,17 +36,16 @@ variable "subnet_zone_list" {
##############################################################################

variable "region" {
description = "The region where VPC and services are deployed"
description = "The region to be used in the reserved ip naming convention."
type = string
default = "us-south"
}

variable "cloud_services" {
description = "List of cloud services to create an endpoint gateway. The keys are the service names, the values (all optional) give some level of control on the created VPEs."
description = "List of cloud services to create reserved ip's for. The keys are the service names, the values (all optional) give some level of control on the created VPEs."
type = set(object({
service_name = string
vpe_name = optional(string), # Full control on the VPE name. If not specified, the VPE name will be computed based on prefix, vpc name and service name.
allow_dns_resolution_binding = optional(bool, false)
service_name = string
vpe_name = optional(string), # Full control on the VPE name. If not specified, the VPE name will be computed based on prefix, vpc name and service name.
}))
default = []
validation {
Expand Down Expand Up @@ -105,7 +103,7 @@ variable "cloud_service_by_crn" {
}

variable "endpoint_ip_list" {
description = "List of IPs to create. Each object contains an IP name and subnet id"
description = "List of IP's to create. Each object contains an ip name and subnet id"
type = list(
object({
ip_name = string # reserved ip name
Expand All @@ -118,7 +116,7 @@ variable "endpoint_ip_list" {
}

variable "reserved_ips" {
description = "Map of existing reserved IP names and values. Leave this value as default if you want to create new reserved ips, this value is used in the main module in which a user passes their existing reserved ips created here so as to not attempt to recreate them."
description = "Map of existing reserved IP names and values. Leave this value as default if you want to create new reserved ip's, this value is used in the main module in which a user passes their existing reserved ips created here so as to not attempt to recreate them."
type = object({
name = optional(string) # endpoint gateway IP ID
})
Expand Down

0 comments on commit 8768804

Please sign in to comment.