Terraform modules
main.tf |
Generated files |
---|---|
|
|
main.tf |
Using a module |
---|---|
|
|
variable "ipv4" {
description = "The server's IPV4 address e.g. '141.62.1.5'"
type = string
}
variable "hostNames" {
description = "Set of unique local host names e.g. [\"www\", \"cloud\"] "
type = list
}
...
resource "local_file" "known_hosts" {...
Switching between parent and child module context by ${path.module}:
resource "local_file" "ssh_script" {
content = templatefile("${path.module}/tpl/ssh.sh", {
serverFqdn = "${var.ostNames}.${var.dnsZone}"
devopsUsername = var.loginUser
})
filename = "bin/ssh"
file_permission = "755"
depends_on = [local_file.known_hosts]
}
No. 17
A module for local file generation
Q: |
Complete the idea of Figure 1038, “Local file generation by module ” defining
a module for generating |