terraform-provider-octopusdeploy
terraform-provider-octopusdeploy copied to clipboard
Machine data sources do not work correctly
Describe the bug
Given the following Terraform:
terraform {
required_providers {
octopusdeploy = { source = "OctopusDeployLabs/octopusdeploy", version = "0.13.2" }
}
}
variable "octopus_server" {
type = string
nullable = false
sensitive = false
description = "The URL of the Octopus server e.g. https://myinstance.octopus.app."
}
variable "octopus_apikey" {
type = string
nullable = false
sensitive = true
description = "The API key used to access the Octopus server. See https://octopus.com/docs/octopus-rest-api/how-to-create-an-api-key for details on creating an API key."
}
variable "octopus_space_id" {
type = string
nullable = false
sensitive = false
description = "The ID of the Octopus space to populate."
}
provider "octopusdeploy" {
address = "${var.octopus_server}"
api_key = "${var.octopus_apikey}"
space_id = "${var.octopus_space_id}"
}
data "octopusdeploy_cloud_region_deployment_targets" "cloud_targets" {
skip = 0
take = 100
}
output "cloud-targets" {
value = data.octopusdeploy_cloud_region_deployment_targets
}
And a space that has cloud region targets, the data.octopusdeploy_cloud_region_deployment_targets.cloud_region_deployment_targets
property is null.
Steps to reproduce
- Run the example terraform above against a space with cloud region targets
- Note the output shows the
cloud_region_deployment_targets
is null.
Expected behavior
The cloud_region_deployment_targets
property should be a list of cloud regions targets in the space.
Logs and other supporting information
Changes to Outputs:
+ cloud-targets = {
+ cloud_region_deployment_targets = null
+ deployment_id = null
+ environments = null
+ health_statuses = null
+ id = "CloudRegionDeploymentTargets 2023-12-05 04:27:03.293728771 +0000 UTC"
+ ids = null
+ is_disabled = null
+ name = null
+ partial_name = null
+ roles = null
+ shell_names = null
+ skip = 0
+ take = 4
+ tenant_tags = null
+ tenants = null
+ thumbprint = null
}
Screenshots If applicable, add screenshots to help explain your problem.
Environment and versions:
- OS: 'Linux'
- Octopus Server Version: [e.g.
2024.1
] - Terraform Version: [e.g.
1.6.5
] - Octopus Terraform Provider Version: [e.g.
0.13.2
]
Additional context Add any other context about the problem here.
The line d.Set("cloud_region_deployment_targets", flattenedCloudRegionDeploymentTargets)
in data_source_cloud_region_deployment_targets.go attempts to set the cloud_region_deployment_targets
property to the list of targets. However, this function call returns an error that is swallowed. This means Terraform returns a null list. I haven't yet worked out why this function call returns an error.