Skip to content

Commit

Permalink
Fix access config and outputs (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbleyg authored Jun 27, 2023
1 parent ce13710 commit 68bf1eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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

0 comments on commit 68bf1eb

Please sign in to comment.