Page cover

2 6 0 Terraform Cloud and Multi Homes (HCL)

Andrew deploys multiple homes. This is the end of the project. As the code repeats, Andrew suggests some challenges for us that we can work on.

Code Notes

  • Below is the pattern of houses if we deploy multiple homes.

public
β”œβ”€β”€ home1
β”‚   β”œβ”€β”€ assets
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   └── image.jpg
β”‚   β”œβ”€β”€ index.html
β”‚   └── error.html
β”œβ”€β”€ home2
β”‚   β”œβ”€β”€ assets
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   └── image.jpg
β”‚   β”œβ”€β”€ index.html
└── └── error.html 

Below is how we create them. We repeat the entire resource and module blocks as many times as we would like to create homes.

resource "terratowns_home" "home" {
  name = "How to play Arcanum in 2023!"
  description = <<DESCRIPTION ...
DESCRIPTION
  domain_name = module.home_arcanum_hosting.domain_name
  town = "missingo"
  content_version = var.arcanum.content_version
}

module "home_arcanum_hosting" {
  source = "./modules/terrahome_aws"
  user_uuid = var.teacherseat_user_uuid
  public_path = var.arcanum.public_path
  content_version = var.arcanum.content_version
}

Explore and try to optimise the code so we can still create the same number of homes with less line of code with increased simplicity.

Resources

Last updated