-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Feature/103 submodules #116
Feature/103 submodules #116
Conversation
Looks like lint test is failing on lint because of
(something not touched in this PR) Also a bit strange - I don't get that error locally even when using the same |
@taylorludwig This might be an issue with automatically pulling in the latest Terraform provider. Maybe try adding a version constraint on the module? https://www.terraform.io/docs/configuration/providers.html#provider-versions |
README.md
Outdated
routes = [ | ||
{ | ||
name = "egress-internet" | ||
routes = { |
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 think we need to change this into a map. We can still maintain the desired behavior by constructing the map (for for_each) internally within the module.
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.
sure, makes sense.
Ill create a local var map with the original default name
as the key.
modules/routes/README.md
Outdated
- Routes within vpc network. | ||
- Optionally deletes the default internet gateway routes. | ||
|
||
## Compatibility |
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.
We don't need compatibility warnings on each submodule.
modules/subnets/outputs.tf
Outdated
description = "The subnet resources" | ||
} | ||
|
||
output "subnets_names" { |
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.
Let's remove all these unnecessary outputs since we're not directly outputting the resources directly. We can keep them on the root module though.
modules/subnets/variables.tf
Outdated
*/ | ||
|
||
variable "project_id" { | ||
description = "The ID of the project where this VPC will be created" |
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.
Please clean up variable descriptions for submodules. In this case, this module doesn't create a VPC at all.
modules/vpc/main.tf
Outdated
Shared VPC | ||
*****************************************/ | ||
resource "google_compute_shared_vpc_host_project" "shared_vpc_host" { | ||
count = var.shared_vpc_host == "true" ? 1 : 0 |
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.
count = var.shared_vpc_host == "true" ? 1 : 0 | |
count = var.shared_vpc_host ? 1 : 0 |
modules/vpc/outputs.tf
Outdated
description = "The URI of the VPC being created" | ||
} | ||
|
||
output "svpc_host_project_id" { |
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 could just be project_id, no? (We can/should make it depend on the shared_vpc_host_project resource though.)
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.
Yeah seems logical. Updated
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.
Look like it still needs to be updated?
modules/vpc/variables.tf
Outdated
} | ||
|
||
variable "shared_vpc_host" { | ||
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.
Let's take this opportunity to switch to boolean.
@@ -17,3 +17,7 @@ | |||
terraform { | |||
required_version = "~> 0.12.0" | |||
} | |||
|
|||
provider "google" { |
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 should be a required version constraint, not a direct module invocation.
…validate" This reverts commit 3a3a408.
Co-Authored-By: Morgante Pell <[email protected]>
@morgante yep - the lack of provider version in the modules was the problem. I've added that to the main and submodules and linting is passing. Working on the other comments now. |
…ards compatability don't break
@morgante I believe I addressed all your comments. Tests are all passing again now as well. Thanks! |
modules/routes/variables.tf
Outdated
description = "The name of the network where routes will be created" | ||
} | ||
|
||
variable "network" { |
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.
Isn't this redundant with network_name
? Don't think we should need both.
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 just followed the original, single module, functionality. network
and subnet
resources were added to the depends_on
black of the routes to force the depedency.
But passing in just the network_name
from the output of the vpc submodule should force that dependency anyways. Ill remove network
modules/routes/variables.tf
Outdated
default = null | ||
} | ||
|
||
variable "subnets" { |
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.
We shouldn't need this.
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.
Its only passed into the depends_on
block, functionality that was there before.
Ill remove it and see what happens. I'm not entirely sure if the subnets really do need to be fully created before the routes are created.
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.
If it's an issue, we could possibly use an output from the subnets module to pass into the network.
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.
At least one of the tests fail if we remove this.
When creating a route with a next_hop_ip
with an ip inside a subnet it'll error out with the following when the route tries to get created before the subnet is finished.
Error: Error creating Route: googleapi: Error 400: Invalid value for field 'resource.nextHopIp': '10.10.40.10'. 10.10.40.10 must lie within the address spaces of (). multi-vpc-a1-02 does not own any address space. Please create a subnetwork first., invalid
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.
Got it. In that case, how about we follow the convention we started with network peering and add an explicit module_depends_on
variable?
variable "module_depends_on" { |
modules/vpc/outputs.tf
Outdated
description = "The URI of the VPC being created" | ||
} | ||
|
||
output "svpc_host_project_id" { |
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.
Look like it still needs to be updated?
outputs.tf
Outdated
description = "The name of the VPC being created" | ||
} | ||
|
||
output "network_self_link" { | ||
value = google_compute_network.network.self_link | ||
value = module.vpc.network_self_link | ||
description = "The URI of the VPC being created" | ||
} | ||
|
||
output "svpc_host_project_id" { |
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.
Let's just call this project_id
.
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.
Do you still want it only outputted if shared_vpc_host == true
?
The original logic was svpc_host_project_id
would only be outputted if you enabled shared vpc, otherwise it was ""
.
But outputting just project_id
seems like you'd still expect a value even with shared vpc off
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.
Yes, let's output it in both cases.
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.
One observation after looking at our current documentation.
Fixes #103
vpc
,subnets
, androutes
submodules.routes
input to be amap
from alist
to supportfor_each
resource creation.0.6.0
of developer tools image to fix errors when runninggenerate_docs
with complex types.