The portainer_docker_node resource allows you to update, inspect, and delete Docker Swarm nodes via the Portainer API.
You can change attributes such as availability, role, name or labels, or even remove the node entirely from the cluster using this resource.
resource "portainer_docker_node" "example" {
endpoint_id = 1
node_id = "wna048ajhbc1n1t5ispvf6mvg"
version = 4869
name = "node-name"
availability = "active"
role = "manager"
labels = {
foo = "barrerun"
}
}
- You can update node's role, availability, name, or labels by running:
terraform apply- To destroy the node:
terraform destroy| Name | Type | Required | Description |
|---|---|---|---|
endpoint_id |
number | ✅ yes | ID of the Portainer environment (endpoint) |
node_id |
string | ✅ yes | ID of the Docker Swarm node to update |
version |
number | ✅ yes | Version of the swarm node, required for updates and deletion |
name |
string | 🚫 optional | Custom name to assign to the node |
availability |
string | 🚫 optional | Node availability (active, pause, or drain) |
role |
string | 🚫 optional | Node role in the cluster (manager or worker) |
labels |
map(string) | 🚫 optional | Key-value metadata labels to attach to the node |
|
| Name | Description |
|---|---|
id |
A combination of endpoint ID and node ID ({endpoint}-{node}) |