Terraform Version
$ terraform -v
Terraform v0.11.6
+ provider.rancher v1.2.0
+ provider.template v1.0.0
Affected Resource(s)
Please list the resources as a list, for example:
- rancher_stack
Terraform Configuration Files
$ cat docker-compose.yml.tpl
version: '2'
services:
web:
image: ${image_name}
$ cat rancher-compose.yml.tpl
version: '2'
services:
web:
scale: ${scale_count}
$ cat main.tf
provider "rancher" {
api_url = "${var.rancher_api_url}"
access_key = "${var.rancher_access_key}"
secret_key = "${var.rancher_secret_key}"
}
data "template_file" "docker-compose" {
template = "${file("${path.module}/docker-compose.yml.tpl")}"
vars {
image_name = "${var.image_name}"
}
}
data "template_file" "rancher-compose" {
template = "${file("${path.module}/rancher-compose.yml.tpl")}"
vars {
scale_count = "${var.scale_count}"
}
}
data "rancher_environment" "rancher_environment" {
name = "${var.environment}"
}
resource "rancher_stack" "test" {
name = "test"
description = "teststack"
environment_id = "${data.rancher_environment.rancher_environment.id}"
scope = "user"
docker_compose = "${data.template_file.docker-compose.rendered}"
rancher_compose = "${data.template_file.rancher-compose.rendered}"
start_on_create = true
finish_upgrade = true
}
Panic Output
# successfully applied the change
$ terraform init
$ terraform apply
# but has issue to change the setting or destroy
$ TF_VAR_scale_count=3 terraform apply
> rancher_stack.test: Error deleting Stack: Bad response statusCode [455]. Status [455 ]. Body: [] from [https://rancher.xxx.com/v2-beta/projects/1a7/stacks/1st31]
$ terraform destroy
> rancher_stack.test: Error deleting Stack: Bad response statusCode [455]. Status [455 ]. Body: [] from [https://rancher.xxx.com/v2-beta/projects/1a7/stacks/1st31]
Secondly, when plan it after apply, always see the change:
~ rancher_stack.test
rancher_compose: version: '2'
services:
web:
scale: 3
- start_on_create: true
Report the issue to terraform as well: https://github.com/terraform-providers/terraform-provider-rancher/issues/69