You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTION.md
+39-30Lines changed: 39 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -389,40 +389,49 @@ If you want to onboard resources of a STACKIT service `foo` that was not yet in
389
389
To test your changes locally, you have to compile the provider (requires Go 1.22) and configure the Terraform CLI to use the local version.
390
390
391
391
1. Clone the repository.
392
-
2. Set the provider address to a custom address for local development. It must correspond to the same address that is included in the dev_overrides block, in step 4.
393
-
In `main.go` replace the address `registry.terraform.io/providers/stackitcloud/stackit` with `local-dev.com/stackit/stackit`.
394
-
3. Go to the repository root and compile the provider locally to any location by running `go build -o <PATH_TO_BINARY>`. The binary name must start with `terraform-provider`, e.g. `terraform-provider-stackit`.
395
-
4. Create a `.terraformrc` config file in your home directory (`~`) for the terraform CLI with the following content:
# For all other providers, install them directly from their origin provider
401
+
# registries as normal. If you omit this, Terraform will _only_ use
402
+
# the dev_overrides block, and so no other providers will be available.
403
+
direct {}
404
+
}
405
+
```
406
+
1. Copy one of the folders in the [examples](examples/) folder to a location of your choosing, and define the Terraform variables according to its README. The main.tf file needs some additional configuration to use the local provider:
# For all other providers, install them directly from their origin provider
404
-
# registries as normal. If you omit this, Terraform will _only_ use
405
-
# the dev_overrides block, and so no other providers will be available.
406
-
direct {}
407
-
}
408
-
```
418
+
1. Go to the copied example and initialize Terraform by running `terraform init -reconfigure -upgrade`. This will throw an error ("Failed to query available provider packages") which can be ignored since we are using the local provider build.
419
+
> Note: Terraform will store its resources' states locally. To allow multiple people to use the same resources, check [Setup for multi-person usage](#setup-centralized-terraform-state)
420
+
1. Setup authentication by setting the env var `STACKIT_SERVICE_ACCOUNT_TOKEN` as a valid token (see [Authentication](#authentication) for more details on how to autenticate).
421
+
1. Run `terraform plan` or `terraform apply` commands.
422
+
1. To debug the terraform provider, execute the following steps:
423
+
* install the compiled terraform provider to binary path defined in the .terraformrc file
424
+
* run the terraform provider from your IDE with the `-debug` flag set
425
+
* The provider will emit the setting for the env variable `TF_REATTACH_PROVIDERS`, e.g.
409
426
410
-
4. Copy one of the folders in the [examples](examples/) folder to a location of your choosing, and define the Terraform variables according to its README. The main.tf file needs some additional configuration to use the local provider:
Starting terraform with this environment variable set will automatically connect to the running IDE session, instead of starting a new GRPC server with the plugin. This allows to set
432
+
breakpoints and inspect the state of the provider.
433
+
421
434
422
-
5. Go to the copied example and initialize Terraform by running `terraform init -reconfigure -upgrade`. This will throw an error ("Failed to query available provider packages") which can be ignored since we are using the local provider build.
423
-
> Note: Terraform will store its resources' states locally. To allow multiple people to use the same resources, check [Setup for multi-person usage](#setup-centralized-terraform-state)
424
-
6. Setup authentication by setting the env var `STACKIT_SERVICE_ACCOUNT_TOKEN` as a valid token (see [Authentication](#authentication) for more details on how to autenticate).
425
-
7. Run `terraform plan` or `terraform apply` commands.
0 commit comments