Skip to content

Commit

Permalink
Merge pull request #3 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 1.1.0 - Export variables within Variable Sets
  • Loading branch information
dalenewby authored Jun 28, 2023
2 parents f09d0d2 + 4308164 commit 77710d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ Two files are created for each Terraform Cloud workspace:
- _workspace-name_-workspace.json
- _workspace-name_-variables.json

Variable Sets are exported to files named varset-_variable-set-name_.json
with spaces in the variable set name replaced with hyphens (`-`).
Two files are created for each Terraform Cloud Variable Set:

- varset-_variable-set-name_.json
- varset-_variable-set-name_-variables.json

Spaces in the variable set name are replaced with hyphens (`-`).

## Restrictions
The code assumes that all of the Terraform Cloud Variable Sets are contained
Expand Down
9 changes: 9 additions & 0 deletions tfc-dump.pl
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,18 @@
for (my $ii = 0; $ii < scalar @vs_names; $ii++) {
$filename = $vs_names[$ii];
$filename =~ s/ /-/g; # replace spaces with hyphens

# Get the Variable Set
$curl_query = "\"https://app.terraform.io/api/v2/varsets/$vs_ids[$ii]\"";
$curl_cmd = "curl $curl_headers --output varset-${filename}.json $curl_query";
system($curl_cmd);

# Get the variables within the Variable Set
$curl_query = "\"https://app.terraform.io/api/v2/varsets/$vs_ids[$ii]/relationships/vars\"";
$curl_cmd = "curl $curl_headers --output varset-${filename}-variables.json $curl_query";
system($curl_cmd);
}

unlink($tmpfile);

exit(0);

0 comments on commit 77710d6

Please sign in to comment.