Skip to content

Commit 8f55c8b

Browse files
committed
minor
1 parent 9c18944 commit 8f55c8b

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ locals {
33
}
44

55
resource "openstack_compute_keypair_v2" "this" {
6-
count = "${var.generate_ssh_key}"
6+
count = "${var.generate_ssh_key ? 1 : 0}"
77
name = "${var.name}"
88
}
99

1010
resource "openstack_compute_keypair_v2" "this_provided" {
11-
count = "${1 - var.generate_ssh_key}"
11+
count = "${var.generate_ssh_key ? 0 : 1}"
1212

1313
name = "${var.name}"
1414
public_key = "${file("${var.public_key_file}")}"
1515
}
1616

1717
resource "local_file" "private_key_pem" {
18-
count = "${1 - var.generate_ssh_key}"
18+
count = "${var.generate_ssh_key ? 0 : 1}"
1919

2020
depends_on = ["openstack_compute_keypair_v2.this_provided"]
21-
content = "${openstack_compute_keypair_v2.this_provided.private_key}"
21+
content = "${openstack_compute_keypair_v2.this_provided.0.private_key}"
2222
filename = "${local.private_key_filename}"
2323
}

outputs.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
output "private_key_file" {
1+
output "name" {
22
description = "Private Key"
3-
value = "${openstack_compute_keypair_v2.this.*.private_key}"
3+
value = "${openstack_compute_keypair_v2.this.0.name}"
4+
}
5+
6+
output "private_key" {
7+
description = "Private Key"
8+
value = "${openstack_compute_keypair_v2.this.0.private_key}"
49
}
510

611
output "public_key_file" {
712
description = "Public Key"
8-
value = "${openstack_compute_keypair_v2.this_provided.*.public_key}"
13+
value = "${openstack_compute_keypair_v2.this_provided.0.public_key}"
914
}

0 commit comments

Comments
 (0)