Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
locals {
domain_name = "<% index .Params `productionHostRoot` %>"
}

# define policy documents for backend services
# sample policies
Expand All @@ -9,5 +12,13 @@ data "aws_iam_policy_document" "resource_access_backendservice" {
]
resources = ["arn:aws:ec2:::prod-*"]
}
statement {
effect = "Allow"
actions = [
"s3:GetObject",
"s3:PutObject",
]
resources = ["arn:aws:s3:::files.${local.domain_name}/*"]
}
# can be more statements here
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
locals {
domain_name = "<% index .Params `stagingHostRoot` %>"
}

# define policy documents for backend services
# sample policies
Expand All @@ -9,5 +12,13 @@ data "aws_iam_policy_document" "resource_access_backendservice" {
]
resources = ["arn:aws:ec2:::stage-*"]
}
statement {
effect = "Allow"
actions = [
"s3:GetObject",
"s3:PutObject",
]
resources = ["arn:aws:s3:::files.${local.domain_name}/*"]
}
# can be more statements here
}
16 changes: 12 additions & 4 deletions templates/terraform/environments/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ terraform {
region = "<% index .Params `region` %>"
dynamodb_table = "<% .Name %>-prod-terraform-state-locks"
}

required_providers {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

aws = {
source = "hashicorp/aws"
version = "~> 3.7"
}
}
}

locals {
Expand Down Expand Up @@ -59,11 +66,12 @@ module "prod" {

# Hosting configuration. Each domain will have a bucket created for it, but may have mulitple aliases pointing to the same bucket.
hosted_domains = [
{ domain : local.domain_name, aliases : [] },
{ domain : "<% index .Params `productionFrontendSubdomain` %>${local.domain_name}", aliases : [] },
{ domain : local.domain_name, aliases : [], signed_urls: false },
{ domain : "<% index .Params `productionFrontendSubdomain` %>${local.domain_name}", aliases : [], signed_urls: false },
<% if eq (index .Params `fileUploads`) "yes" %>{ domain : "files.${local.domain_name}", aliases : [], signed_urls: true },<% end %>
]
domain_name = "${local.domain_name}"
cf_signed_downloads = <% if eq (index .Params `fileUploads`) "yes" %>true<% else %>false<% end %>

domain_name = local.domain_name

# DB configuration
database = "<% index .Params `database` %>"
Expand Down
15 changes: 11 additions & 4 deletions templates/terraform/environments/stage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ terraform {
region = "<% index .Params `region` %>"
dynamodb_table = "<% .Name %>-stage-terraform-state-locks"
}

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.7"
}
}
}

locals {
Expand Down Expand Up @@ -57,13 +64,13 @@ module "stage" {
# https://${local.region}.console.aws.amazon.com/systems-manager/parameters/%252Faws%252Fservice%252Feks%252Foptimized-ami%252F1.17%252Famazon-linux-2%252Frecommended%252Fimage_id/description?region=${local.region}
eks_worker_ami = "<% index .Params `eksWorkerAMI` %>"

# Hosting configuration. Each domain will have a bucket created for it, but may have mulitple aliases pointing to the same bucket.
hosted_domains = [
{ domain : local.domain_name, aliases : [] },
{ domain : "<% index .Params `stagingFrontendSubdomain` %>${local.domain_name}", aliases : [] },
{ domain : local.domain_name, aliases : [], signed_urls: false },
{ domain : "<% index .Params `stagingFrontendSubdomain` %>${local.domain_name}", aliases : [], signed_urls: false },
<% if eq (index .Params `fileUploads`) "yes" %>{ domain : "files.${local.domain_name}", aliases : [], signed_urls: true },<% end %>
]

domain_name = local.domain_name
cf_signed_downloads = <% if eq (index .Params `fileUploads`) "yes" %>true<% else %>false<% end %>

# This will save some money as there a cost associated to each NAT gateway, but if the AZ with the gateway
# goes down, nothing in the private subnets will be able to reach the internet. Not recommended for production.
Expand Down
3 changes: 1 addition & 2 deletions templates/terraform/modules/environment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module "vpc" {
# To get the current account id
data "aws_caller_identity" "current" {}


#
# Provision the EKS cluster
module "eks" {
Expand Down Expand Up @@ -91,7 +90,7 @@ module "s3_hosting" {
version = "0.1.0"
count = length(var.hosted_domains)

cf_signed_downloads = var.cf_signed_downloads
cf_signed_downloads = var.hosted_domains[count.index].signed_urls
domain = var.hosted_domains[count.index].domain
aliases = var.hosted_domains[count.index].aliases
project = var.project
Expand Down
7 changes: 1 addition & 6 deletions templates/terraform/modules/environment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ variable "hosted_domains" {
type = list( object( {
domain = string
aliases = list(string)
signed_urls = bool
} ) )
}

Expand Down Expand Up @@ -141,12 +142,6 @@ variable "sendgrid_api_key_secret_name" {
type = string
}

variable "cf_signed_downloads" {
type = bool
description = "Enable Cloudfront signed URLs"
default = false
}

variable "roles" {
type = list(object({
name = string
Expand Down