I'm also from Sydney. So hey, I want to convert my existing docker-compose HTPC setup to Terraform, just to practise using Terraform with something other than AWS (which is my job). My existing setup has sonarr, radarr, jackett, plex, deluge, and portainer (although I don't really use portainer -- was just curious).
When I tried to fire up your code with Terraform, I got errors -- can't declare ports and volumes variables multiple times.
I'm on:
terraform --version Terraform v1.1.9
I have since located the warnings and errors in your plex.tf file -- terraform will not init, fmt, or validate until they are fixed:
'ports' is not a variable. It is a block, so it should be ports { (i.e. no equals)
ports = { internal = 6789 external = 6789 }
'volumes' is also not a variable, so it should be volumes { (i.e. no equals)
These need to be changed in multiple places. I had already separated your code into multiple files, which is what we do at work. So I '.disabled' all the files and undisabled one by one, doing fmt and validate and init -- to check everything
This one gets a deprecated warning:
networks = ["${docker_network.private_network.id}"]
Warning: Quoted references are deprecated │ │ on couchpotato.tf line 48, in resource "docker_container" "couchpotato": │ 48: depends_on = ["docker_container.nzbget"] │ │ In this context, references are expected literally rather than in quotes. Terraform 0.11 and earlier required quotes, but quoted references are now deprecated and │ will be removed in a future version of Terraform. Remove the quotes surrounding this reference to silence this warning.
The fix is to change it to:
networks = [docker_network.private_network.id]
Similarly, remove the double quotes for all depends_on lines to remove those warnings:
depends_on = ["docker_container.nzbget"]
There is one more, but I haven't looked into it yet... need to use a 'networks_advanced' block.
terraform validate ╷ │ Warning: Argument is deprecated │ │ with docker_container.couchpotato, │ on couchpotato.tf line 11, in resource "docker_container" "couchpotato": │ 11: networks = [docker_network.private_network.id] │ │ Use networks_advanced instead. Will be removed in v3.0.0 │ │ (and 4 more similar warnings elsewhere) ╵ Success! The configuration is valid, but there were some validation warnings as shown above.
Hi Ray,
I'm also from Sydney. So hey, I want to convert my existing docker-compose HTPC setup to Terraform, just to practise using Terraform with something other than AWS (which is my job). My existing setup has sonarr, radarr, jackett, plex, deluge, and portainer (although I don't really use portainer -- was just curious).
When I tried to fire up your code with Terraform, I got errors -- can't declare ports and volumes variables multiple times.
I'm on:
terraform --version Terraform v1.1.9
I have since located the warnings and errors in your plex.tf file -- terraform will not init, fmt, or validate until they are fixed:
'ports' is not a variable. It is a block, so it should be ports { (i.e. no equals)
ports = { internal = 6789 external = 6789 }
'volumes' is also not a variable, so it should be volumes { (i.e. no equals)volumes = { host_path = "/etc/localtime" container_path = "/etc/localtime" read_only = true }
These need to be changed in multiple places. I had already separated your code into multiple files, which is what we do at work. So I '.disabled' all the files and undisabled one by one, doing fmt and validate and init -- to check everything
You can also add a volume name for each block:
volumes { volume_name = "tv" host_path = var.tv_dir container_path = "/tv" }
This one gets a deprecated warning:
networks = ["${docker_network.private_network.id}"]
Warning: Quoted references are deprecated │ │ on couchpotato.tf line 48, in resource "docker_container" "couchpotato": │ 48: depends_on = ["docker_container.nzbget"] │ │ In this context, references are expected literally rather than in quotes. Terraform 0.11 and earlier required quotes, but quoted references are now deprecated and │ will be removed in a future version of Terraform. Remove the quotes surrounding this reference to silence this warning.
The fix is to change it to:
networks = [docker_network.private_network.id]
Similarly, remove the double quotes for all depends_on lines to remove those warnings:
depends_on = ["docker_container.nzbget"]
There is one more, but I haven't looked into it yet... need to use a 'networks_advanced' block.
https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs/resources/container "networks (Set of String, Deprecated) ID of the networks in which the container is. networks_advanced (Block Set) The networks the container is attached to (see below for nested schema)"
terraform validate ╷ │ Warning: Argument is deprecated │ │ with docker_container.couchpotato, │ on couchpotato.tf line 11, in resource "docker_container" "couchpotato": │ 11: networks = [docker_network.private_network.id] │ │ Use networks_advanced instead. Will be removed in v3.0.0 │ │ (and 4 more similar warnings elsewhere) ╵ Success! The configuration is valid, but there were some validation warnings as shown above.
My file structure, fwiw
Hope this helps :)