Novelty Terraform Module for AWS¶
Deploys Novelty on AWS ECS Fargate using the terraform-aws-novelty module.
Prerequisites¶
- Terraform >= 1.5.0
- AWS CLI configured with credentials
- Route53 hosted zone (for HTTPS)
- Novelty license key
Usage¶
Step 1: Create the Terraform files¶
Create the following files in a new directory:
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.0"
}
}
}
provider "aws" {
region = var.aws_region
}
resource "aws_acm_certificate" "this" {
domain_name = var.domain_name
validation_method = "DNS"
lifecycle {
create_before_destroy = true
}
}
resource "aws_route53_record" "cert_validation" {
for_each = {
for dvo in aws_acm_certificate.this.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
}
}
allow_overwrite = true
name = each.value.name
records = [each.value.record]
ttl = 60
type = each.value.type
zone_id = var.hosted_zone_id
}
resource "aws_acm_certificate_validation" "this" {
certificate_arn = aws_acm_certificate.this.arn
validation_record_fqdns = [for record in aws_route53_record.cert_validation : record.fqdn]
}
module "novelty" {
source = "github.com/thatdot/terraform-aws-novelty?ref=v1.0.0"
project_name = var.project_name
container_image = var.container_image
license_key = var.license_key
enable_https = true
certificate_arn = aws_acm_certificate.this.arn
depends_on = [aws_acm_certificate_validation.this]
}
resource "aws_route53_record" "alb_alias" {
zone_id = var.hosted_zone_id
name = var.domain_name
type = "A"
alias {
name = module.novelty.alb_dns_name
zone_id = module.novelty.alb_zone_id
evaluate_target_health = true
}
}
variable "aws_region" {
description = "AWS region"
type = string
default = "us-west-2"
}
variable "project_name" {
description = "Project name for resource naming"
type = string
}
variable "container_image" {
description = "Novelty container image"
type = string
}
variable "license_key" {
description = "Novelty license key"
type = string
sensitive = true
}
variable "domain_name" {
description = "Domain name for HTTPS (e.g., novelty.example.com)"
type = string
}
variable "hosted_zone_id" {
description = "Route53 hosted zone ID"
type = string
}
output "url" {
description = "URL to access Novelty"
value = "https://${var.domain_name}"
}
output "alb_dns_name" {
description = "ALB DNS name"
value = module.novelty.alb_dns_name
}
output "ecs_cluster_name" {
description = "ECS cluster name"
value = module.novelty.ecs_cluster_name
}
output "cloudwatch_log_group" {
description = "CloudWatch log group"
value = module.novelty.cloudwatch_log_group_name
}
project_name = "novelty"
container_image = "your-registry/novelty:latest"
license_key = "YOUR_LICENSE_KEY"
domain_name = "novelty.example.com"
hosted_zone_id = "Z0123456789ABCDEFGHIJ"
Step 2: Configure variables¶
Copy the example variables file and edit it with your values:
cp terraform.tfvars.example terraform.tfvars
Fill in the required values in terraform.tfvars:
domain_name- Your domain (e.g.,novelty.example.com)hosted_zone_id- Route53 zone ID for your domaincontainer_image- Your Novelty container imagelicense_key- Your Novelty license key
Step 3: Deploy¶
terraform init
terraform plan
terraform apply
Once complete, access Novelty at https://<your-domain-name>.
Cleanup¶
terraform destroy