Skip to content

Commit 2be1447

Browse files
authored
Adding Instructions to dev versions of provider (#987)
1 parent db6cbdf commit 2be1447

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,58 @@ In order to test the provider, you can run `make test`. You can use [meta-argume
9797

9898
~> **Notice:** If you do not have a `public_key` and `private_key` you must create a programmatic API key to configure the provider (see [Creating Programmatic API key](#Programmatic-API-key)). If you already have one, you can continue with [Configuring environment variables](#Configuring-environment-variables)
9999

100+
#### Testing Atlas Provider Versions that are NOT hosted on Terraform Registry (i.e. pre-release versions)
101+
To test development / pre-release versions of the Terraform Atlas Provider that are not hosted on the Terraform Registry, you will need to create a [Terraform Provider Network Mirror](https://developer.hashicorp.com/terraform/internals/provider-network-mirror-protocol).
102+
103+
The provider network mirror protocol is an optional protocol which you can implement to provide an alternative installation source for Terraform providers, regardless of their origin registries. Terraform uses network mirrors only if you activate them explicitly in the CLI configuration's `provider_installation` block. When enabled, a network mirror can serve providers belonging to any registry hostname, which can allow an organization to serve all of the Terraform providers they intend to use from an internal server, rather than from each provider's origin registry.
104+
105+
To do this you can:
106+
1. Create a versions.tf file in a new directory with an existing live version from Terraform Registry. For example this can include:
107+
```
108+
terraform {
109+
required_providers {
110+
mongodbatlas = {
111+
source = "mongodb/mongodbatlas"
112+
}
113+
}
114+
required_version = ">= 0.13"
115+
}
116+
```
117+
118+
2. Use `terraform init` to create required file structures
119+
120+
3. `mkdir` a “tf_cache” sub-directory and `cd` into that directory
121+
122+
4. Create a .terraformrc file and insert below (modify accordingly to your own local path directory):
123+
```
124+
provider_installation {
125+
filesystem_mirror {
126+
path = "C:\Users\ZuhairAhmed\Desktop\Tenant_Upgrade\tf_cache"
127+
include = ["registry.terraform.io/hashicorp/*"]
128+
}
129+
direct {
130+
exclude = ["registry.terraform.io/hashicorp/*"]
131+
}
132+
}
133+
plugin_cache_dir = "C:\Users\ZuhairAhmed\Desktop\Tenant_Upgrade\tf_cache"
134+
disable_checkpoint=true
135+
```
136+
5. `cd` back up to original directory and `mv` the “.terraform/providers/registry.terraform.io” directory to “tf_cache”
137+
138+
6. Create required environment variables (modify accordingly to your own local path directory):
139+
```
140+
export TF_PLUGIN_CACHE_DIR=/mnt/c/Users/ZuhairAhmed/Desktop/Tenant_Upgrade/tf_cache
141+
export TF_CLI_CONFIG_FILE=/mnt/c/Users/ZuhairAhmed/Desktop/Tenant_Upgrade/tf_cache/terraform.rc
142+
```
143+
7. Delete the .terraform and .terraform.lock.hcl directories altogether. At this point you should only have the “tf_cache” directory and the “versions.tf” file remaining.
144+
145+
9. Next in the “tf_cache” directory replace existing terraform provider core files (Terraform Atlas Provider version binary, CHANGELOG.md, LICENSE, and README.md) with version you seek to test locally. Make sure to keep folder structure the same.
146+
147+
8. Lastly, run `terraform init` again and this time terraform will pull provider version from tf_cache network mirror. You can confirm by seeing above the “Terraform has been successfully initialized!” message a “Using mongodb/mongodbatlas Vx.x.x from the shared cache directory”
148+
149+
#### Logs
150+
To help with dubbing issues, you can turn on Logs with `export TF_LOG=TRACE`. Note: this is very noisy.
151+
100152
### Running the acceptance test
101153

102154
#### Programmatic API key

0 commit comments

Comments
 (0)