Skip to content

Client Applications

We use S3 buckets to host files, and Amazon CloudFront to servce the files.

CloudFront to S3

CloudFront to S3

Minimal working example

The following code creates a client application that will be reachable from https://kattehotell.dev.bymoslo.net:

main.tf
module "application" {
  source           = "git@github.com:BYM-IKT/terraform-app-master-module.git"
  team             = var.team
  account_id       = var.account_id
  environment      = var.environment
  region           = var.region
  application_name = var.application_name

  cloudfront_distributions = {
    kattehotell = {}
  }

  providers = {
    aws.route53   = aws.route53
    aws.us-east-1 = aws.us-east-1
    aws.ses       = aws.ses
  }
}

Note

The domain resulting is automatically inferred using the value of environment, i.e.:

`dev`  => `dev.bymoslo.net`
`prod` => `bymoslo.no`

Features

Additional domains

Sometimes we wish to have a client application reachable from multiple URLs. Additional URLs can be added as follows:

main.tf
module "application" {
  source      = "git@github.com:BYM-IKT/terraform-app-master-module.git"
  environment = "dev"

  # ...

  cloudfront_distributions = {
    kattehotell = {
      additional_domains = [
        {
          domain_name = "hotell-for-katter.dev.bymoslo.net"
          zone_name   = "bymoslo.net"
        },
        {
          domain_name = "www.cat-hotel.no"
          zone_name   = "cat-hotel.no"
        },
      ]
    }
  }
}

This provisions a client application reachable from 3 different URLs:

  • https://kattehotell.dev.bymoslo.net (default)
  • https://hotell-for-katter.dev.bymoslo.net
  • https://cat-hotel.dev.bymoslo.net