Skip to content

Commit 50968c1

Browse files
committed
feat(iac): Support overriding an output file path
1 parent 977a45f commit 50968c1

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

deployment/terraform/modules/openstack-cogstack-infra/compute-keypair.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ resource "openstack_compute_keypair_v2" "compute_keypair" {
2121
resource "local_file" "private_key" {
2222
count = local.is_using_existing_ssh_keypair ? 0 : 1
2323
content = openstack_compute_keypair_v2.compute_keypair.private_key
24-
filename = "${path.root}/.build/${openstack_compute_keypair_v2.compute_keypair.name}-rsa.pem"
24+
filename = "${local.output_file_directory}/${openstack_compute_keypair_v2.compute_keypair.name}-rsa.pem"
2525
file_permission = "0600"
2626
}
2727

2828
resource "local_file" "public_key" {
2929
count = local.is_using_existing_ssh_keypair ? 0 : 1
3030
content = openstack_compute_keypair_v2.compute_keypair.public_key
31-
filename = "${path.root}/.build/${openstack_compute_keypair_v2.compute_keypair.name}-rsa.pub"
31+
filename = "${local.output_file_directory}/${openstack_compute_keypair_v2.compute_keypair.name}-rsa.pub"
3232
file_permission = "0600"
33-
}
33+
}

deployment/terraform/modules/openstack-cogstack-infra/shared-locals.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
locals {
33
random_prefix = random_id.server.b64_url
4+
output_file_directory = var.output_file_directory != null ? var.output_file_directory : "${path.root}/.build"
45
}
56

67

@@ -17,8 +18,6 @@ locals {
1718
ip_address = var.preexisting_controller_host != null ? var.preexisting_controller_host.ip_address : local.created_controller_host.access_ip_v4
1819
unique_name = var.preexisting_controller_host != null && var.preexisting_controller_host.unique_name != null ? var.preexisting_controller_host.unique_name : local.created_controller_host.name
1920
}
20-
21-
2221
}
2322

2423
resource "random_id" "server" {

deployment/terraform/modules/openstack-cogstack-infra/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,11 @@ variable "ssh_key_pair" {
9999
condition = var.ssh_key_pair == null || fileexists(var.ssh_key_pair.public_key_file)
100100
error_message = "No file exists in SSH public key path"
101101
}
102+
}
103+
104+
105+
variable "output_file_directory" {
106+
type = string
107+
default = null
108+
description = "Optional path to write output files to. If directory doesnt exist it will be created"
102109
}

deployment/terraform/modules/openstack-kubernetes-infra/compute-keypair.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ resource "openstack_compute_keypair_v2" "compute_keypair" {
2121
resource "local_file" "private_key" {
2222
count = local.is_using_existing_ssh_keypair ? 0 : 1
2323
content = openstack_compute_keypair_v2.compute_keypair.private_key
24-
filename = "${path.root}/.build/${openstack_compute_keypair_v2.compute_keypair.name}-rsa.pem"
24+
filename = "${local.output_file_directory}/${openstack_compute_keypair_v2.compute_keypair.name}-rsa.pem"
2525
file_permission = "0600"
2626
}
2727

2828
resource "local_file" "public_key" {
2929
count = local.is_using_existing_ssh_keypair ? 0 : 1
3030
content = openstack_compute_keypair_v2.compute_keypair.public_key
31-
filename = "${path.root}/.build/${openstack_compute_keypair_v2.compute_keypair.name}-rsa.pub"
31+
filename = "${local.output_file_directory}/${openstack_compute_keypair_v2.compute_keypair.name}-rsa.pub"
3232
file_permission = "0600"
3333
}

deployment/terraform/modules/openstack-kubernetes-infra/shared-locals.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ locals {
1010
}
1111

1212
locals {
13-
kubeconfig_file = "${path.module}/.build/downloaded-kubeconfig.yaml"
13+
output_file_directory = var.output_file_directory != null ? var.output_file_directory : "${path.root}/.build"
14+
kubeconfig_file = "${local.output_file_directory}/downloaded-kubeconfig.yaml"
1415
}
1516

1617
resource "random_id" "server" {

deployment/terraform/modules/openstack-kubernetes-infra/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,10 @@ variable "ssh_key_pair" {
5454
condition = var.ssh_key_pair == null || fileexists(var.ssh_key_pair.public_key_file)
5555
error_message = "No file exists in SSH public key path"
5656
}
57+
}
58+
59+
variable "output_file_directory" {
60+
type = string
61+
default = null
62+
description = "Optional path to write output files to. If directory doesnt exist it will be created"
5763
}

0 commit comments

Comments
 (0)