cloud-init.tf 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. data "template_file" "cloud-init" {
  2. count = var.interconnects_count
  3. # Should these be in a common directory? I suspect they'd be reusable
  4. template = file("${path.module}/cloud-init/cloud-init.tpl")
  5. vars = {
  6. hostname = "interconnect-${count.index}"
  7. fqdn = "interconnect-${count.index}.${var.dns_info["private"]["zone"]}"
  8. saltmaster = "salt-master.${ var.dns_public["name"] }"
  9. environment = var.environment
  10. aws_partition = var.aws_partition
  11. aws_partition_alias = var.aws_partition_alias
  12. aws_region = var.aws_region
  13. interconnect_id = count.index
  14. vpc_cidr = var.security_vpc_cidr
  15. }
  16. }
  17. # Render a multi-part cloud-init config making use of the part
  18. # above, and other source files
  19. data "template_cloudinit_config" "cloud-init" {
  20. count = var.interconnects_count
  21. gzip = true
  22. base64_encode = true
  23. # Main cloud-config configuration file.
  24. part {
  25. filename = "init.cfg"
  26. content_type = "text/cloud-config"
  27. content = data.template_file.cloud-init[count.index].rendered
  28. }
  29. # Additional parts as needed
  30. #part {
  31. # content_type = "text/x-shellscript"
  32. # content = "ffbaz"
  33. #}
  34. }