Skip to content
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

Fix access config and outputs #66

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/terraform/wordpress/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ resource "google_compute_instance" "default" {
subnetwork = network_interface.value.subnetwork

dynamic "access_config" {
for_each = compact([network_interface.value.external_ip == "None" ? null : 1])
for_each = compact([network_interface.value.external_ip == "NONE" ? null : 1])
content {
nat_ip = network_interface.value.external_ip == "Ephemeral" ? null : network_interface.value.external_ip
nat_ip = network_interface.value.external_ip == "EPHEMERAL" ? null : network_interface.value.external_ip
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions examples/terraform/wordpress/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
locals {
network_interface = google_compute_instance.default.network_interface[0]
}

output "instance_self_link" {
description = "Self-link for the Wordpress compute instance"
value = google_compute_instance.default.self_link
Expand All @@ -30,17 +34,17 @@ output "instance_machine_type" {

output "instance_nat_ip" {
description = "Machine type for the wordpress compute instance"
value = google_compute_instance.default.network_interface[0].access_config[0].nat_ip
value = length(local.network_interface.access_config) > 0 ? local.network_interface.access_config[0].nat_ip : null
}

output "has_external_ip" {
description = "Flag to indicate if the wordpress machine has an external IP"
value = google_compute_instance.default.network_interface[0].access_config[0].nat_ip != null ? true : false
value = length(compact(local.network_interface.access_config[*].nat_ip)) > 0 ? true : false
}

output "instance_network" {
description = "Machine type for the wordpress compute instance"
value = google_compute_instance.default.network_interface[0]
value = local.network_interface
}

output "mysql_password" {
Expand Down