-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enhance naming for vpc resources and fix prefix checks #685
Conversation
While the code says public gateway creation is optional ( terraform-ibm-landing-zone-vpc/main.tf Line 218 in f03b300
public_gateway_name variable to make an "existing_vpc" example.
If we want to keep the public gateway optional - perhaps we need to create a flag or something else in the logic |
Ran every test locally and also ran hub-spoke-manual-resolver apply (doesn't have test) - everything worked fine. |
SKIP UPGRADE TEST: change of vpc name in main.tf
Not skipping upgrade test anymore as reverted changes back on the vpc name with prefix. |
@rajatagarwal-ibm It seems you added several things since skipping the upgrade test so I'm not comfortable with it being skipped. Can you unskip it (use commit with |
UNSKIP UPGRADE TEST: testing
UNSKIP UPGRADE TEST: removed variable name change
The upgrade test fails only because of the change in the VPC name, here: Local run test result:
I didn't like the naming this way so removed one variable, but I guess I will revert it back as its not required as part of this issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rajatagarwal-ibm See my comments please
variable "public_gateway_name" { | ||
description = "The name of the public gateway" | ||
type = string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding a new variable, can you just hard code the variable values in the main.tf of the existing_vpc example main.tf ?
variables.tf
Outdated
@@ -3,11 +3,47 @@ | |||
############################################################################## | |||
|
|||
variable "name" { | |||
description = "The name to give the newly provisioned VPC. Only used if 'create_vpc' is true." | |||
description = "The name to give the provisioned VPC. Only used if 'create_vpc' is true." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, name is also used for other resources, not just the VPC. I would update this to:
"The string to use for the naming of VPC resources."
I think you should also then add a new variable called vpc_name
which can be used to explicitly name the VPC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module is being consumed in the SLZ module. Any changes which we make here with name
will impact that too. I don't think so that's needed. Hence my proposal is I can rename the description to the following:
"The string to use for the naming of VPC, when var.create_vpc is true. This string also use for the naming of VPC resources."
main.tf
Outdated
@@ -193,7 +198,7 @@ resource "time_sleep" "wait_for_authorization_policy" { | |||
|
|||
resource "ibm_is_vpc_routing_table" "route_table" { | |||
for_each = module.dynamic_values.routing_table_map | |||
name = var.prefix != null ? "${var.prefix}-${var.name}-route-${each.value.name}" : "${var.name}-route-${each.value.name}" | |||
name = var.prefix != null ? "${var.prefix}-${var.name}-route-${each.value.name}" : "${var.routing_table_name}-${each.value.name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reason to add var.routing_table_name
- you can achieve this naming with the current code using var.name
. There can be multiple routing tables here, so we will always be appending ${each.value.name}
to the name here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the objective of the task is to give freedom to the user to name it anything they like, I have added these as variables. If they don't provide the value then it will pick up either prefix or name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But how are you going to handle the naming of multiple routing tables with 1 string variable. You dont want them all named the same, so hence you will need to use ${each.value.name}
in the naming
main.tf
Outdated
@@ -228,7 +233,7 @@ locals { | |||
|
|||
resource "ibm_is_public_gateway" "gateway" { | |||
for_each = local.gateway_object | |||
name = var.prefix != null ? "${var.prefix}-${var.name}-public-gateway-${each.key}" : "${var.name}-public-gateway-${each.key}" | |||
name = var.prefix != null ? "${var.prefix}-${var.name}-public-gateway-${each.key}" : "${var.public_gateway_name}-${each.key}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reason to add var.public_gateway_name
- you can achieve this naming with the current code using var.name
. There can be multiple public gateways here, so we will always be appending ${each.value.name}
to the name here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the objective of the task is to give freedom to the user to name it anything they like, I have added these as variables. If they don't provide the value then it will pick up either prefix or name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as #685 (comment)
…raform-ibm-modules/terraform-ibm-landing-zone-vpc into enhance-naming-and-fix-prefix-checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Rajat, some comments
/run pipeline |
/run pipeline |
…raform-ibm-modules/terraform-ibm-landing-zone-vpc into enhance-naming-and-fix-prefix-checks
/run pipeline |
/run pipeline |
SKIP UPGRADE TEST: removed vpc from prefix name in gateway name
/run pipeline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rajatagarwal-ibm I left some comments - maybe we need to jump on a call to discuss how we want this to look as its starting to get confusing now to support all the use cases
SKIP UPGRADE TEST: removed vpc from prefix name in gateway name
main.tf
Outdated
resource_group = var.resource_group_id | ||
classic_access = var.classic_access | ||
# address prefix is set to auto only if no address prefixes NOR any subnet is passed as input | ||
address_prefix_management = (length([for prefix in values(coalesce(var.address_prefixes, {})) : prefix if prefix != null]) != 0) || (length([for subnet in values(coalesce(var.subnets, {})) : subnet if subnet != null]) != 0) ? "manual" : null | ||
address_prefix_management = length([for prefix in values(coalesce(var.address_prefixes, {})) : prefix if prefix != null]) != 0 ? "manual" : null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this change needed?
SKIP UPGRADE TEST: removed vpc from prefix name in gateway name
Created #697 since we can no longer bypass the upgrade test in this PR This can be closed |
Description
Addresses:
Release required?
x.x.X
)x.X.x
)X.x.x
)Release notes content
Run the pipeline
If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.
Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:
Checklist for reviewers
For mergers