unable to execute terraform apply in azure devops

0 votes

I am trying to execute terraform scripts through Azure DevOps. I am not able to apply and validate through different tasks, though terraform plan is successful terraform apply is failing.

##[error]TypeError: Cannot read property 'includes' of null

Here are the terraform tasks which I am using. I have tried two different tasks

1.

- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV2@2
  displayName: 'Terraform : apply -auto-approve'
  inputs:
    command: apply
    workingDirectory: '$(System.DefaultWorkingDirectory)/Terraform'
    commandOptions: '-auto-approve'
    environmentServiceNameAzureRM: 'ps-vs-sc'
    backendAzureRmResourceGroupName: '$(rgname)'
    backendAzureRmStorageAccountName: $(strname)
    backendAzureRmContainerName: $(tfContainer)
    backendAzureRmKey: '$(storagekey)'
- task: TerraformTaskV2@2
  inputs:
    provider: 'azurerm'
    command: 'apply'
    workingDirectory: '$(System.DefaultWorkingDirectory)/Terraform'
    commandOptions: '--auto-approve'
    environmentServiceNameAzureRM: 'ps-vs1-sc'

Here is my terraform file.

provider "azurerm" {
features {}
}

terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "2.74.0"
    }
  }
}

data "azurerm_api_management" "example" {
  name                = var.apimName
  resource_group_name = var.rgName
}

resource "azurerm_api_management_api" "example" {
  name                = var.apName
  resource_group_name = var.rgName
  api_management_name = var.apimname
  revision            = "1"
  display_name        = "Example API1"
  path                = "example1"
  protocols           = ["https"]
  service_url         = "http://123.0.0.0:8000"
  subscription_required  = true

  import {
    content_format = "openapi+json"
    content_value  = #{storageaccountlink}#
     
}
Any answers would be helpful.

Mar 29, 2022 in Other DevOps Questions by Kichu
• 19,040 points
832 views

1 answer to this question.

0 votes

I have added the complete pipeline details here in this GitHub link:

https://gist.github.com/PrakashRajanSakthivel/e6d8e03044a51d74803499aca75a258c

Just use it and you will be fine to proceed.

Also, check that Terraform initialization fails in the Azure DevOps Pipeline. What could be the reasons?

answered Mar 31, 2022 by narikkadan
• 63,600 points

Related Questions In Other DevOps Questions

0 votes
1 answer

How to configure and execute Azure Devops classic editor pipeline after commit in Github?

If you're looking for CI/CD triggers, all ...READ MORE

answered Feb 10, 2022 in Other DevOps Questions by Bhavitha
• 1,000 points
1,085 views
0 votes
1 answer

Is it possible to have a link to raw content of file in Azure DevOps

Sure, here's the call for the rests: GET ...READ MORE

answered Feb 10, 2022 in Other DevOps Questions by Bhavitha
• 1,000 points
709 views
0 votes
1 answer

How to include Different Types of Workitems in Boards of Azure DevOps?

Predefined backlog levels in Azure DevOps may ...READ MORE

answered Feb 11, 2022 in Other DevOps Questions by Bhavitha
• 1,000 points
1,620 views
0 votes
0 answers

unable to install mcafee-epo from azure devops

When I run the command 'pip install ...READ MORE

Mar 20, 2022 in Other DevOps Questions by Kichu
• 19,040 points
525 views
0 votes
0 answers
0 votes
1 answer
0 votes
2 answers

Which is better azure devops or aws devops?

Azure DevOps, a part of Microsoft's cloud ...READ MORE

answered Jan 8 in Cloud Computing by anonymous
• 700 points
2,275 views
0 votes
1 answer
0 votes
1 answer

Terraform and Azure DevOps pipelines

This error message is normal. Usually, the ...READ MORE

answered Apr 23, 2022 in Other DevOps Questions by narikkadan
• 63,600 points
1,059 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP