Ask a Question!Hi team, Using terraform-provider-portainer and it appeared to be compatible with the Portainer Server version. I'm using Portainer Server 2.33.x. terraform {
required_providers {
portainer = {
source = "portainer/portainer"
version = ">= 1.24.0"
}
}
}
provider "portainer" {
api_key = "..."
endpoint = "https://my-portainer.server:9443"
skip_ssl_verify = true
}
resource "portainer_environment" "this" {
name = "my-server"
environment_address = "tcp://my-server.local:9001"
type = 2 # Agent
tag_ids = [1]
}terraform apply
│ Error: failed to create environment: [POST /endpoints][400] endpointCreateBadRequest
│
│ with portainer_environment.this,
│ on main.tf line 28, in resource "portainer_environment" "this":
│ 28: resource "portainer_environment" "this" {
...Pinning version to 1.23.x then By the way, deleting the If there is version compatibility between the Terraform provider and Server, it would be helpful if that matrix were shown in the documentation. |
Replies: 5 comments
|
Hi @skokado - thanks for the report. The 400 you see is misleading: in v1.24.0 we migrated portainer_environment to the Portainer Go SDK, whose auto-generated error readers discard the response body and only print placeholders like endpointCreateBadRequest. The actual Portainer error (likely a real validation against 2.33.x) was hidden from you. Fixed in v1.31.0: the provider now appends Portainer's raw response body to the error. Re-running your config will produce something like: Error: failed to create environment: [POST /endpoints][400] endpointCreateBadRequest: {"message":"...","details":"..."} A compat matrix in CI (LTS / 2.33.x / latest) is on the follow-up list. 🙌🏽 |
|
Thank you. I tried the Terraform code today and it successfully created the portainer_environment in both 1.30.0 and 1.31.0. Also, the fact that error details for 1.31.0 are now output with dummy settings is very helpful. Thank you! resource "portainer_environment" "test" {
name = "skokado-test"
environment_address = "tcp://dummy-host:9001"
type = 2
} |
|
Sorry after closed, Regarding to the error response using v1.31.0, I understand that the format for |
|
The portainer_environment was successfully created in v1.31.1! |
Thanks @skokado - fixed in v1.31.1: the provider now sends
tag_idsin the single bracketed-string multipart format Portainer expects, so your original HCL works on 2.33.x without changes.