Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Submodule flat_from_git added at 5ebfa3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"flat_from_git","Source":"git::https://github.com/aleatoricmbnt/flat?ref=v3.0.1","Dir":".terraform/modules/flat_from_git"},{"Key":"nested_from_git","Source":"git::https://github.com/aleatoricmbnt/base.git//main/git_https_target?ref=zerossl/0.0.1","Dir":".terraform/modules/nested_from_git/main/git_https_target"}]}
Submodule nested_from_git added at 9de5fd

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Terraform Provider: Random

The Random provider supports the use of randomness within Terraform configurations. The
provider resources can be used to generate a random [id](docs/resources/id.md),
[integer](docs/resources/integer.md), [password](docs/resources/password.md),
[pet](docs/resources/pet.md), [shuffle](docs/resources/shuffle.md) (random permutation
of a list of strings), [string](docs/resources/string.md) or
[uuid](docs/resources/uuid.md).

## Documentation, questions and discussions

Official documentation on how to use this provider can be found on the
[Terraform Registry](https://registry.terraform.io/providers/hashicorp/random/latest/docs).
In case of specific questions or discussions, please use the
HashiCorp [Terraform Providers Discuss forums](https://discuss.hashicorp.com/c/terraform-providers/31),
in accordance with HashiCorp [Community Guidelines](https://www.hashicorp.com/community-guidelines).

We also provide:

* [Support](.github/SUPPORT.md) page for help when using the provider
* [Contributing](.github/CONTRIBUTING.md) guidelines in case you want to help this project
* [Design](DESIGN.md) documentation to understand the scope and maintenance decisions

The remainder of this document will focus on the development aspects of the provider.

## Requirements

* [Terraform](https://www.terraform.io/downloads) (>= 0.12)
* [Go](https://go.dev/doc/install) (1.23)
* [GNU Make](https://www.gnu.org/software/make/)
* [golangci-lint](https://golangci-lint.run/usage/install/#local-installation) (optional)

## Development

### Building

1. `git clone` this repository and `cd` into its directory
2. `make build` will trigger the Golang build

The provided `GNUmakefile` defines additional commands generally useful during development,
like for running tests, generating documentation, code formatting and linting.
Taking a look at it's content is recommended.

### Testing

In order to test the provider, you can run

* `make test` to run provider tests
* `make testacc` to run provider acceptance tests

It's important to note that acceptance tests (`testacc`) will actually spawn
`terraform` and the provider. Read more about they work on the
[official page](https://www.terraform.io/plugin/sdkv2/testing/acceptance-tests).

### Generating documentation

This provider uses [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs/)
to generate documentation and store it in the `docs/` directory.
Once a release is cut, the Terraform Registry will download the documentation from `docs/`
and associate it with the release version. Read more about how this works on the
[official page](https://www.terraform.io/registry/providers/docs).

Use `make generate` to ensure the documentation is regenerated with any changes.

### Using a development build

If [running tests and acceptance tests](#testing) isn't enough, it's possible to set up a local terraform configuration
to use a development builds of the provider. This can be achieved by leveraging the Terraform CLI
[configuration file development overrides](https://www.terraform.io/cli/config/config-file#development-overrides-for-provider-developers).

First, use `make install` to place a fresh development build of the provider in your [`${GOBIN}`](https://pkg.go.dev/cmd/go#hdr-Compile_and_install_packages_and_dependencies) (defaults to `${GOPATH}/bin` or `${HOME}/go/bin` if `${GOPATH}` is not set). Repeat
this every time you make changes to the provider locally.

Then, in your `${HOME}/.terraformrc` (Unix) / `%APPDATA%\terraform.rc` (Windows), a `provider_installation` that contains
the following `dev_overrides`:

```hcl
provider_installation {
dev_overrides {
"hashicorp/random" = "${GOBIN}" //< replace `${GOBIN}` with the actual path on your system
}

direct {}
}
```

Note that it's also possible to use a dedicated Terraform configuration file and invoke `terraform` while setting
the environment variable `TF_CLI_CONFIG_FILE=my_terraform_config_file`.

Once the `dev_overrides` are in place, any local execution of `terraform plan` and `terraform apply` will
use the version of the provider found in the given `${GOBIN}` directory,
instead of the one indicated in your terraform configuration.

### Testing GitHub Actions

This project uses [GitHub Actions](https://docs.github.com/en/actions/automating-builds-and-tests) to realize its CI.

Sometimes it might be helpful to locally reproduce the behaviour of those actions,
and for this we use [act](https://github.com/nektos/act). Once installed, you can _simulate_ the actions executed
when opening a PR with:

```shell
# List of workflows for the 'pull_request' action
$ act -l pull_request

# Execute the workflows associated with the `pull_request' action
$ act pull_request
```

## Releasing

The release process is automated via GitHub Actions, and it's defined in the Workflow
[release.yml](./.github/workflows/release.yml).

Each release is cut by pushing a [semantically versioned](https://semver.org/) tag to the default branch.

## License

[Mozilla Public License v2.0](./LICENSE)
Binary file not shown.
16 changes: 16 additions & 0 deletions config_tests/module_sources/git_module_saved_locally/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module "flat_from_git" {
source = "git::https://github.com/aleatoricmbnt/flat?ref=v3.0.1"
}

module "nested_from_git" {
source = "git::https://github.com/aleatoricmbnt/base.git//main/git_https_target?ref=zerossl/0.0.1"
custom_var = var.required
}

variable "required" {
default = "value"
}

output "nested_from_git_module_id_from_output" {
value = module.nested_from_git.pet_name
}
18 changes: 1 addition & 17 deletions main/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,7 @@ variable "resource_count" {
}

variable "input" {
default = "default_value"
}

resource "terraform_data" "test" {
count = var.resource_count

input = {
index = count.index
timestamp = timestamp()
random = uuid()
description = "Test resource ${count.index} for blob writer testing"
}

# Force recreation on each apply to generate maximum output
triggers_replace = [
timestamp()
]
default = "batch6"
}

resource "terraform_data" "test2" {
Expand Down