1 Reply Latest reply on Aug 7, 2019 12:34 AM by andreaspa

    Terraform and creating org with vdc

    andreaspa Enthusiast

      Hi,

       

      I'm trying to automate parts of our customer onboarding process with Terraform, but I'm running in to some issues.

      The idea is to have a parameters file containing the settings like customer name, usernames, passwords etc and then create an Org, VDC, orgadmin and some networks.

       

      Here's how my config looks like at the moment:

      resource "vcd_org" "new_org" {
        name             = "${var.cust_name_short}"
        full_name        = "${var.cust_name_long}"
        description      = "${var.cust_name_desc}"
        is_enabled       = "true"
        delete_recursive = "true"
        delete_force     = "true"
        can_publish_catalogs = "false"
      }
      
      
      #
      # We need to create a customer admin user
      #
      
      resource "vcd_org_user" "vcduser" {
        org = "${var.cust_name_short}"
      
        name          = "${var.cust_admin_user}"
        description   = "${var.cust_admin_desc}"
        role          = "Organization Administrator"
        password      = "${var.cust_admin_pass}"
      }
      
      
      resource "vcd_org_vdc" "orgvdc" {
        name = "${var.cust_vdc_name}"
        description = "${var.cust_vdc_desc}"
        org = "${var.cust_name_short}"
      
        allocation_model = "AllocationVApp"
        network_pool_name = "Labb VDC-VXLAN-NP"
        provider_vdc_name = "Labb VDC"
      
        storage_profile {
          name = "vCloud Storage"
          default = true
          limit = 0
        }
      
        compute_capacity {
          cpu {
            #
          }
      
          memory {
            #
          }
        }
      
      
        enabled = true
        enable_thin_provisioning = true
        enable_fast_provisioning = true
        delete_force = true
        delete_recursive = true
      
      }
      

       

      The issue I'm encountering is this:

      vcd_org_vdc.orgvdc: Creating...

      vcd_org.new_org: Creating...

      vcd_org_user.vcduser: Creating...

      vcd_org.new_org: Creation complete after 1s [id=e204ec9b-90d2-4fb9-9b64-1d5700ba2dfd]

       

      Error: couldn't find org with name: TestCust1. Please check Org name as it is case sensitive

       

        on customer.tf line 33, in resource "vcd_org_user" "vcduser":

        33: resource "vcd_org_user" "vcduser" {

       

       

       

      Error: error retrieving Org: error retrieving Org TestCust1: couldn't find org with name: TestCust1. Please check Org name as it is case sensitive

       

        on customer.tf line 43, in resource "vcd_org_vdc" "orgvdc":

        43: resource "vcd_org_vdc" "orgvdc" {

      TestCust1 is the cust_name_short variable, so the org is created sucessfully but the user is not created since I get an error.

       

      Any help would be appreciated!