Skip to content

Commit 25a781e

Browse files
committed
terraform/datacrunch: Use pathexpand() for credentials file path
The datacrunch_api_key_file variable default uses tilde which Terraform does not automatically expand in string defaults. While the Python extraction script handles this via os.path.expanduser(), it is better practice to make the expansion explicit at the Terraform level. Apply pathexpand() when passing the path to the external data source so the behavior is clear and self-documenting. Add a comment explaining that tilde paths are supported. Generated-by: Claude AI Signed-off-by: Chuck Lever <[email protected]>
1 parent de19bcc commit 25a781e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

terraform/datacrunch/provider.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ terraform {
1313
}
1414

1515
# Extract OAuth2 credentials from credentials file
16+
# Use pathexpand() to properly handle tilde (~) in paths since
17+
# Terraform doesn't expand tilde in string variable defaults
1618
data "external" "datacrunch_credentials" {
17-
program = ["python3", "${path.module}/extract_api_key.py", var.datacrunch_api_key_file]
19+
program = ["python3", "${path.module}/extract_api_key.py", pathexpand(var.datacrunch_api_key_file)]
1820
}
1921

2022
provider "datacrunch" {

terraform/datacrunch/vars.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
variable "datacrunch_api_key_file" {
2-
description = "Path to file containing DataCrunch API key (client secret)"
2+
description = "Path to file containing DataCrunch API credentials. Tilde (~) paths are supported and expanded via pathexpand()."
33
type = string
44
default = "~/.datacrunch/credentials"
55
}

0 commit comments

Comments
 (0)