terraform-provider-glob

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2019 License: MIT Imports: 10 Imported by: 0

README

Glob (Directory listing) provider for terraform

Why?

Because terraform cannot get a list of files matching a pattern (https://github.com/hashicorp/terraform/issues/16697), despite hyper-specific functions like template_dir existing, so I'm just going to write it.

This has happened before (https://github.com/jakexks/terraform-provider-gzip), which thankfully eventually made it in to the main terraform code (https://www.terraform.io/docs/configuration/functions/base64gzip.html)

How?

Install the provider:

go get -u github.com/jakexks/terraform-provider-glob

Edit ~/.terraformrc:

providers {
  glob = "/bin/terraform-provider-glob" # or /path/to/terraform-provider-glob
}

Use the provider:

data "glob_filename_list" "some_directory" {
  pattern = "./*"
}

output "all_files_in_some_directory" {
  value = "${data.glob_filename_list.some_directory.matches}"
}

data "glob_filename_list" "go_files" {
  pattern = "./*.go"
}

data "glob_contents_list" "go_files" {
  pattern = "./*.go"
}

data "glob_map" "go_files" {
  pattern = "./*.go"
}

output "go_filenames" {
  value = "${data.glob_filename_list.go_files.matches}"
}

output "go_filecontents" {
  value = "${data.glob_contents_list.go_files.matches}"
}

output "map" {
  value = "${data.glob_map.go_files.matches}"
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL