Skip to content

Unable to clone a Tenant when creating a new Tenant #267

@hnrkndrssn

Description

@hnrkndrssn

Describe the bug
When creating a new tenant that should be cloned from an existing tenant the new tenant is not cloned from the existing tenant.

Discovered when doing some testing in Terraform.

Steps to reproduce

Config

resource "octopusdeploy_tenant" "cloned" {
  name = "Cloned Tenant"
  cloned_from_tenant_id = "Tenants-128"
}

Existing Tenant

{
  "Id": "Tenants-128",
  "Name": "Tenant 001",
  "TenantTags": [
    "Test/Foo"
  ],
  "ProjectEnvironments": {
    "Projects-181": [
      "Environments-101"
    ]
  },
  "SpaceId": "Spaces-1",
  "ClonedFromTenantId": null,
  "Description": "",
  "Slug": "tenant-001",
  "Icon": null,
  "Links": {
    "Self": "/api/Spaces-1/tenants/Tenants-128",
    "Variables": "/api/Spaces-1/tenants/Tenants-128/variables",
    "Web": "/app#/Spaces-1/tenants/Tenants-128",
    "Logo": "/api/Spaces-1/tenants/Tenants-128/logo?cb=0.0.0-local"
  }
}

Created Tenant

{
  "Id": "Tenants-365",
  "Name": "Cloned Tenant",
  "TenantTags": [],
  "ProjectEnvironments": {},
  "SpaceId": "Spaces-1",
  "ClonedFromTenantId": null,
  "Description": "",
  "Slug": "clone-wars",
  "Icon": null,
  "Links": {
    "Self": "/api/Spaces-1/tenants/Tenants-365",
    "Variables": "/api/Spaces-1/tenants/Tenants-365/variables",
    "Web": "/app#/Spaces-1/tenants/Tenants-365",
    "Logo": "/api/Spaces-1/tenants/Tenants-365/logo?cb=0.0.0-local"
  }
}

Expected behavior
I expect the new Tenant to be cloned from the existing Tenant

Logs and other supporting information

tf plan

Terraform will perform the following actions:

  # octopusdeploy_tenant.cloned will be created
  + resource "octopusdeploy_tenant" "cloned" {
      + cloned_from_tenant_id = "Tenants-128"
      + id                    = (known after apply)
      + name                  = "Cloned Tenant"
      + space_id              = (known after apply)
      + tenant_tags           = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + created = {
      + cloned_from_tenant_id = "Tenants-128"
      + description           = null
      + id                    = (known after apply)
      + name                  = "Cloned Tenant"
      + space_id              = (known after apply)
      + tenant_tags           = (known after apply)
    }

tf apply

Terraform will perform the following actions:

  # octopusdeploy_tenant.cloned will be created
  + resource "octopusdeploy_tenant" "cloned" {
      + cloned_from_tenant_id = "Tenants-128"
      + id                    = (known after apply)
      + name                  = "Cloned Tenant"
      + space_id              = (known after apply)
      + tenant_tags           = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + created = {
      + cloned_from_tenant_id = "Tenants-128"
      + description           = null
      + id                    = (known after apply)
      + name                  = "Cloned Tenant"
      + space_id              = (known after apply)
      + tenant_tags           = (known after apply)
    }
octopusdeploy_tenant.cloned: Creating...
octopusdeploy_tenant.cloned: Creation complete after 0s [id=Tenants-366]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

created = {
  "cloned_from_tenant_id" = ""
  "description" = ""
  "id" = "Tenants-366"
  "name" = "Cloned Tenant"
  "space_id" = "Spaces-1"
  "tenant_tags" = tolist([])
}

Environment and versions:

  • OS: OSX
  • Octopus Server Version: latest
  • Terraform Version: 1.7.5
  • Octopus Terraform Provider Version: 0.22.1

Additional context
Bug happens due to a mismatch in properties for the Tenant ID to clone from passed to Octopus from the Provider, Octopus is expecting Clone but is passed ClonedFromTenantId.

Bug comes down to the tenant struct passing ClonedFromTenantID to Octopus, but Octopus is expecting Clone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions