@ashepherd-mvf wrote:
Is there a way for modules to output nested blocks that would be used within resources the calling terraform template?
From what i’ve read modules can create resources and output variables. Can they output blocks?
Background
I am using the Fastly provider to create fastly_service_v1 resources.
There are significant differences between our Fastly services preventing us using a module to manage creation of these resources.
However, within these fastly resources there is a common logging configuration, specified via a nested syslog block.The sample code below shows the current setup, where the syslog block is explicitly defined in the fastly resource using output variables from the logging module
In the spirit of DRY I’d like for the whole syslog block to be emitted by the module.
Is this possible?
Sample code
`module “logging” {
source = “app.terraform.io/our_org/logging/fastly”
version = “0.0.1”service_name = “example”
environment = “prd”
}resource “fastly_service_v1” “example-service” {
name = “example-service”domain {
name = “site1.example.com”
}backend {
address = “our.backend.com”
auto_loadbalance = false
name = “addr our.backend.com”
port = 80
ssl_check_cert = true
use_ssl = false
}syslog {
address = “{module.logging.config.address}" format = "{module.logging.format}”
format_version = 2
message_type = “blank”
name = “Datadog logging”
port = module.logging.port
tls_ca_cert = “”
tls_hostname = “${module.logging.hostname}”
use_tls = true
}force_destroy = true
}`
Posts: 2
Participants: 2