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: provider/CONTRIBUTE.md
+59-1Lines changed: 59 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,8 +72,66 @@ Do a `terraform init` again and you're done ! :-)
72
72
## Debug the AzureRM provider using Visual Studio Code and Delve
73
73
74
74
It is possible to use Visual Studio Code and Delve (the Golang debugger) to debug the AzureRM provider.
75
+
The easiest way to debug Terraform AzureRM Provider is to execute the acceptances unit test with the Delve debugger attached. Acceptance tests are tests that are written for every resources and data sources and that will really execute the code to an Azure subscription, to validate everything is working well.
75
76
76
-
**TODO**
77
+
First, to be able to connect to Azure, you need to create a service principal using the following command:
78
+
79
+
```bash
80
+
az ad sp create-for-rbac --role=Contributor --scope=/subscriptions/<YOUR_SUBSCRIPTION_ID>
81
+
```
82
+
83
+
Then, you need to create a `.launch.json` file inside the `.vscode` folder at the root of the Terraform AzureRM provider directory (create the `.vscode` folder if it does not exist).
84
+
85
+
Copy the following content into the file:
86
+
87
+
```json
88
+
{
89
+
// Use IntelliSense to learn about possible attributes.
90
+
// Hover to view descriptions of existing attributes.
91
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
The configuration above allows to start debugging a Terraform resource, by launching one or more acceptance test:
113
+
114
+
- The `program` property indicates the file you want to debug
115
+
- The last entry of the `args` property, here `TestAccAzureRMContainerRegistry_geoReplication` represents th test to launch. You can use regex to run multiple tests (ex: `TestAccAzureRMContainerRegistry_*`)
116
+
- The `envFile` property defines the path to get the environment variables file (mainly Azure credentials) that needs to be used to run the acceptance test.
117
+
118
+
Create the `private.env` file into the `.vscode` folder and fill it with the following environment variables:
0 commit comments