Skip to content

Conversation

@averbuks
Copy link
Member

@averbuks averbuks self-assigned this Oct 17, 2019
@averbuks averbuks added the enhancement New feature or request label Oct 17, 2019
variable "network" {
type = string
description = "The name or self_link of the network to create compute instance in. Only one of network or subnetwork should be specified."
default = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty defaults should ~never be used. If a default value is provided, it must be a usable valuable for at least some customers.

In this case, I think default = "default" would work.

Copy link
Member Author

@averbuks averbuks Oct 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with default = "default” is that thegoogle_compute_instance resource expect only one of the network, subnetwork to be specified, and only subnetwork should be specified in case of custom network.
So, if I put var network { default = "default" } and the user has custom network, the user will have to provide subnetwork = "subSelfLink" and it will fail due to network = default.

Approach with “null” defaults has been gotten from https://github.com/terraform-google-modules/terraform-google-vm/tree/master/modules/compute_instance
.
But I found a solution, we can specify only subnetwork and default = default
So, if you have a default/auto net you can go with default value, if a custom one then you have to specify subnetwork anyway.

variable "network" {
type = string
description = "The name or self_link of the network to create compute instance in. Only one of network or subnetwork should be specified."
default = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No null defaults.

- [Terraform Provider for Google Cloud Platform][t7m-provider-gcp-site]
v2.1.Z
- [Terraform][terraform-site] v0.12
- [Terraform Provider for Google Cloud Platform][terraformm-provider-gcp-site] v2.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Terraform Provider for Google Cloud Platform][terraformm-provider-gcp-site] v2.5
- [Terraform Provider for Google Cloud Platform][terraform-provider-gcp-site] v2.5

@averbuks averbuks requested a review from morgante October 17, 2019 15:54
## Usage

To provision this example, populate `terraform.tfvars` with the [required variables][#inputs] and run the following commands within
To provision this example, populate `terraform.tfvars` with the [required variables][variables] and run the following commands within
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, I don't think we should link to the variables file directly. The inputs table works fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I did not realised that it works this way. Thanks, fixed

variable "subnetwork" {
type = string
description = "The name or self_link of the subnetwork to create compute instance in."
default = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a usable value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this one, fixed

@averbuks averbuks requested a review from morgante October 17, 2019 17:17
Copy link
Contributor

@morgante morgante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but linters/tests are failing. Please fix.

@averbuks averbuks requested a review from morgante October 17, 2019 20:59
@morgante morgante merged commit 78e3559 into terraform-google-modules:master Oct 17, 2019
@averbuks averbuks deleted the averbuks-remove-hardcoded-net branch October 18, 2019 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants