Terraform: Example Code for Create Multiple Azure Linux Vms


Step 1 – Install terraform

Step 2 – Copy a followng code into new directory in file called “main.tf”

Step 3 – Create IAM user and assign Service Principal Access?

Step 4 – update main.tf with following entry


  subscription_id = ""
  client_id       = ""
  client_secret   = ""
  tenant_id       = ""

Step 5 – Go inside a directory and run following command


$ terraform init
$ terraform plan 
$ terraform apply 
$ terraform destroy
Rajesh Kumar
Follow me
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Akhil
Akhil
11 months ago

PS D:\Devops Codes> terraform plan

Planning failed. Terraform encountered an error while generating this plan.


│ Error: building account: getting authenticated object ID: listing Service Principals: ServicePrincipalsClient.BaseClient.Get(): clientCredentialsToken: received HTTP status 401 with response: {“error”:”invalid_client”,”error_description”:”AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app ’27cbb9f1-be27-49e8-aee0-7ac8e7032efd’.\r\nTrace ID: 28a73c19-bbc4-45e1-aae0-ead5ac800e00\r\nCorrelation ID: 46b12c2d-aabc-47da-b8fd-ba3498320195\r\nTimestamp: 2023-04-27 05:05:54Z”,”error_codes”:[7000215],”timestamp”:”2023-04-27 05:05:54Z”,”trace_id”:”28a73c19-bbc4-45e1-aae0-ead5ac800e00″,”correlation_id”:”46b12c2d-aabc-47da-b8fd-ba3498320195″,”error_uri”:”https://login.microsoftonline.com/error?code=7000215″}

│  with provider[“registry.terraform.io/hashicorp/azurerm”],
│  on terraform.tf line 11, in provider “azurerm”:
│  11: provider “azurerm” {


PS D:\Devops Codes> 

1
0
Would love your thoughts, please comment.x
()
x