terraform-provider-azurerm icon indicating copy to clipboard operation
terraform-provider-azurerm copied to clipboard

vsts_configuration is not working as expected which is required for adf

Open zameer712 opened this issue 2 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Community Note

  • Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

terraform_version: ~1.0

AzureRM Provider Version

3.61.0

Affected Resource(s)/Data Source(s)

azurerm_data_factory

Terraform Configuration Files

│   on variables.tf line 480, in variable "vsts_configuration":
│  480:    default = {
│  481:     account_name    = "organame"
│  482:     branch_name     = "main"
│  483:     repository_name = "repo-name"
│  484:     root_folder     = "/"
│  485:     tenant_id       = "tenant id"
│  486:     project_name    = "projectname"
│  487:   }
│ 
│ This default value is not compatible with the variable's type constraint:
│ element "root_folder": object required.


Even Github_configuration is not working it throws this error

[7:20 pm] M Roshan Zameer

│ Error: Unsupported block type

144│

145│   on datafactory.tf line 11, in module "datafactory_mcs":

146│   11:   github_configuration {

147│

143│ Blocks of type "github_configuration" are not expected here. Did you mean

144│ to define argument "github_configuration"? If so, use the equals sign to

145│ assign it a value.

Debug Output/Panic Output

Code iam using for adding it 

module "datafactory_mcs" {
  source                          = "git::https://github.com/<org-name>/<project>.git//infrastructure/modules/data-factory?ref=test-v1.0.65"
  name                            = var.adf_name_mcs_cdt
  resource_group_name             = var.resource_group
  location                        = var.location
  tags                            = var.tags
  managed_virtual_network_enabled = var.managed_virtual_network_enabled
  public_network_enabled          = var.public_network_enabled

  # Configure GitHub integration
  vsts_configuration { 
    account_name = var.account_name
    repository_name  = var.github_repository
    branch       = var.github_branch
    branch_name  = var.branch_name
    project_name = var.project_name
    root_folder  = var.root_folder
    tenant_id    = var.tenant_id
  }
}

Module code is here

#Azure rm3 Module for data factory

#https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_factory -- Code of latest version of azurerm3

resource "azurerm_data_factory" "data_factory" {
  name                = var.name
  resource_group_name = var.resource_group_name
  location            = var.location
  tags                = var.tags
  dynamic "github_configuration" {
    for_each = var.github_configuration != null ? [var.github_configuration] : []
    content {
      git_url         = github_configuration.value.git_url
      account_name    = github_configuration.value.account_name
      branch_name     = github_configuration.value.branch_name
      repository_name = github_configuration.value.repository_name
      root_folder     = github_configuration.value.root_folder
    }
  }
  identity {
    type = "SystemAssigned"
 }
  lifecycle {
    ignore_changes = [vsts_configuration, github_configuration, global_parameter]
  }
  managed_virtual_network_enabled = var.managed_virtual_network_enabled
  public_network_enabled          = var.public_network_enabled
  dynamic "vsts_configuration" {
    iterator = each
    for_each = var.vsts_configuration
    content {
      account_name    = each.value.account_name
      branch_name     = each.value.branch_name
      project_name    = each.value.project_name
      repository_name = each.value.repository_name
      root_folder     = each.value.root_folder
      tenant_id       = each.value.tenant_id
    }
  }
}

variable "github_configuration" {
  description = "An input object to define the settings for connecting to GitHub. NOTE! You must log in to the Data Factory management UI to complete the authentication to the GitHub repository."
  type = object({
    git_url         = string # - OPTIONAL: Specifies the GitHub Enterprise host name. Defaults to "https://github.com"
    account_name    = string # - REQUIRED: Specifies the GitHub account name. Defaults to ''
    repository_name = string # - REQUIRED: Specifies the name of the git repository. 
    branch_name     = string # - OPTIONAL: Specifies the branch of the repository to get code from. Defaults to 'main'
    root_folder     = string # - OPTIONAL: Specifies the root folder within the repository. Defaults to '/' for top level.
  })
  default = null
}

variable "vsts_configuration" {
  description = <<EOF
    (Optional) vsts_configuration block supports the following:
    account_name - (Required) Specifies the VSTS account name.
    branch_name - (Required) Specifies the branch of the repository to get code from.
    project_name - (Required) Specifies the name of the VSTS project.
    repository_name - (Required) Specifies the name of the git repository.
    root_folder - (Required) Specifies the root folder within the repository. Set to / for the top level.
    tenant_id - (Required) Specifies the Tenant ID associated with the VSTS account.
EOF
  type = map(object({
    account_name    = string
    branch_name     = string
    project_name    = string
    repository_name = string
    root_folder     = string
    tenant_id       = string
  }))
  default = {}
}

Expected Behaviour

No response

Actual Behaviour

No response

Steps to Reproduce

No response

Important Factoids

No response

References

No response

zameer712 avatar Jun 20 '23 14:06 zameer712

Thanks for raising this issue. Seems your variable definition is incorrect. Below is an example.

tf config:

provider "azurerm" {
  features {}
}

variable "vsts_configuration" {
  description = "Testing2"
  type = list(object({
    account_name    = string
    branch_name     = string
    project_name    = string
    repository_name = string
    root_folder     = string
    tenant_id       = string
  }))
  default = [
    {
        account_name    = "test account name"
        branch_name     = "test branch name"
        repository_name = "test repository name"
        root_folder     = "/"
        tenant_id       = "00000000-0000-0000-0000-000000000000"
        project_name    = "test project name"
    }
  ]
}

resource "azurerm_resource_group" "test" {
  name     = "acctestRG-df-test02"
  location = "west europe"
}

resource "azurerm_purview_account" "test" {
  name                = "acctestaccpatest02"
  resource_group_name = azurerm_resource_group.test.name
  location            = azurerm_resource_group.test.location

  identity {
    type = "SystemAssigned"
  }
}

resource "azurerm_data_factory" "test" {
  name                            = "acctestDFtest02"
  location                        = azurerm_resource_group.test.location
  resource_group_name             = azurerm_resource_group.test.name
  purview_id                      = azurerm_purview_account.test.id
  managed_virtual_network_enabled = false
  public_network_enabled          = true

  identity {
    type = "SystemAssigned"
  }

  dynamic "vsts_configuration" {
    iterator = each
    for_each = var.vsts_configuration
    content {
      account_name    = each.value.account_name
      branch_name     = each.value.branch_name
      project_name    = each.value.project_name
      repository_name = each.value.repository_name
      root_folder     = each.value.root_folder
      tenant_id       = each.value.tenant_id
    }
  }
}

neil-yechenwei avatar Jun 21 '23 02:06 neil-yechenwei

@neil-yechenwei Thanks for responding quick looks like its not working as expected again i made changes as well

vsts_configuration and github_configuration is not working as expected

│ Error: Unsupported block type │ │ on datafactory.tf line 25, in module "datafactory_mcs": │ 25: github_configuration { │ │ Blocks of type "github_configuration" are not expected here. Did you mean │ to define argument "github_configuration"? If so, use the equals sign to │ assign it a value.

│ Error: Unsupported block type │ │ on datafactory.tf line 25, in module "datafactory_mcs": │ 25: vsts_configuration { │ │ Blocks of type "vsts_configuration" are not expected here.

variable "vsts_configuration" { description = "Datafactory-repo-integration" type = list(object({ account_name = string branch_name = string project_name = string repository_name = string root_folder = string tenant_id = string })) default = [ { account_name = "org-name" branch_name = "main" repository_name = "repo-name" root_folder = "/" tenant_id = "tenandid" project_name = "project-name" } ] }

The above code is declared inside infra spin up and below code we are using to point out to the module

`resource "azurerm_data_factory" "data_factory" { name = var.name resource_group_name = var.resource_group_name location = var.location tags = var.tags dynamic "github_configuration" { for_each = var.github_configuration != null ? [var.github_configuration] : [] content { git_url = github_configuration.value.git_url account_name = github_configuration.value.account_name branch_name = github_configuration.value.branch_name repository_name = github_configuration.value.repository_name root_folder = github_configuration.value.root_folder } } identity { type = "SystemAssigned" } lifecycle { ignore_changes = [vsts_configuration, github_configuration, global_parameter] } managed_virtual_network_enabled = var.managed_virtual_network_enabled public_network_enabled = var.public_network_enabled dynamic "vsts_configuration" { iterator = each for_each = var.vsts_configuration content { account_name = each.value.account_name branch_name = each.value.branch_name project_name = each.value.project_name repository_name = each.value.repository_name root_folder = each.value.root_folder tenant_id = each.value.tenant_id } } }

variable "github_configuration" { description = "An input object to define the settings for connecting to GitHub. NOTE! You must log in to the Data Factory management UI to complete the authentication to the GitHub repository." type = object({ git_url = string # - OPTIONAL: Specifies the GitHub Enterprise host name. Defaults to "https://github.com" account_name = string # - REQUIRED: Specifies the GitHub account name. Defaults to '' repository_name = string # - REQUIRED: Specifies the name of the git repository. branch_name = string # - OPTIONAL: Specifies the branch of the repository to get code from. Defaults to 'main' root_folder = string # - OPTIONAL: Specifies the root folder within the repository. Defaults to '/' for top level. }) default = null }

variables of it:- variable "vsts_configuration" { description = <<EOF (Optional) vsts_configuration block supports the following: account_name - (Required) Specifies the VSTS account name. branch_name - (Required) Specifies the branch of the repository to get code from. project_name - (Required) Specifies the name of the VSTS project. repository_name - (Required) Specifies the name of the git repository. root_folder - (Required) Specifies the root folder within the repository. Set to / for the top level. tenant_id - (Required) Specifies the Tenant ID associated with the VSTS account. EOF type = map(object({ account_name = string branch_name = string project_name = string repository_name = string root_folder = string tenant_id = string })) default = {} }`

zameer712 avatar Jun 21 '23 06:06 zameer712

For more usage problems, suggest filing issue on https://discuss.hashicorp.com/c/terraform-providers/tf-azure/34. Thanks.

neil-yechenwei avatar Jun 17 '25 03:06 neil-yechenwei