github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/examples/azure/README.md (about)

     1  # Terratest Configuration and Setup
     2  
     3  Terratest uses Go to make calls to Azure through the azure-sdk-for-go library and independently confirm the actual Azure resource property matches the expected state provided by Terraform output variables.
     4  
     5  - Instructions for running each Azure Terratest module are included in each Terraform example sub-folder:
     6    - examples/azure/terraform-azure-\*-example/README.md
     7  - Tests which assert against expected Terraform output values are located in the the respective go files of the folder:
     8    - [test/azure/terraform-azure-\*-example_test.go](../../test/azure)
     9  - Test APIs which provide the actual Azure resource property values via the azure-sdk-for-go are located in the folder:
    10    - [modules/azure](../../modules/azure)
    11  
    12  ## Go Dependencies
    13  
    14  Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`
    15  
    16  These modules are currently using the latest version of Go and was tested with **go1.14.4**.
    17  
    18  ## Azure-sdk-for-go version
    19  
    20  Let's make sure [go.mod](https://github.com/gruntwork-io/terratest/blob/master/go.mod) includes the appropriate [azure-sdk-for-go version](https://github.com/Azure/azure-sdk-for-go/releases/tag/v46.1.0):
    21  
    22  ```go
    23  require (
    24      ...
    25      github.com/Azure/azure-sdk-for-go v46.1.0+incompatible
    26      ...
    27  )
    28  ```
    29  
    30  If we make changes to either the **go.mod** or the **go test file**, we should make sure that the go build command works still.
    31  
    32  ```powershell
    33  go build terraform_azure_*_test.go
    34  ```
    35  
    36  ## Review Environment Variables
    37  
    38  As part of configuring terraform for Azure, we'll want to check that we have set the appropriate [credentials](https://docs.microsoft.com/azure/terraform/terraform-install-configure?toc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fterraform%2Ftoc.json&bc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fbread%2Ftoc.json#set-up-terraform-access-to-azure) and also that we set the [environment variables](https://docs.microsoft.com/azure/terraform/terraform-install-configure?toc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fterraform%2Ftoc.json&bc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fbread%2Ftoc.json#configure-terraform-environment-variables) on the testing host.
    39  
    40  ```bash
    41  export ARM_CLIENT_ID=your_app_id
    42  export ARM_CLIENT_SECRET=your_password
    43  export ARM_SUBSCRIPTION_ID=your_subscription_id
    44  export ARM_TENANT_ID=your_tenant_id
    45  ```
    46  
    47  Note, in a Windows environment, these should be set as **system environment variables**. We can use a PowerShell console with administrative rights to update these environment variables:
    48  
    49  ```powershell
    50  [System.Environment]::SetEnvironmentVariable("ARM_CLIENT_ID",$your_app_id,[System.EnvironmentVariableTarget]::Machine)
    51  [System.Environment]::SetEnvironmentVariable("ARM_CLIENT_SECRET",$your_password,[System.EnvironmentVariableTarget]::Machine)
    52  [System.Environment]::SetEnvironmentVariable("ARM_SUBSCRIPTION_ID",$your_subscription_id,[System.EnvironmentVariableTarget]::Machine)
    53  [System.Environment]::SetEnvironmentVariable("ARM_TENANT_ID",$your_tenant_id,[System.EnvironmentVariableTarget]::Machine)
    54  ```