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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/next-image/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/static/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/with-custom-domain/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/with-existing-cloudfront/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ module "next_image" {
count = var.create_image_optimization ? 1 : 0

source = "milliHQ/next-js-image-optimization/aws"
version = "~> 12.0.10"
version = ">= 12.1.0"

cloudfront_create_distribution = false

Expand Down
8 changes: 6 additions & 2 deletions modules/cloudfront-proxy-config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ locals {

resource "aws_s3_bucket" "proxy_config_store" {
bucket_prefix = "${var.deployment_name}-tfn-config"
acl = "private"
force_destroy = true
tags = merge(var.tags, var.tags_s3_bucket)
}

resource "aws_s3_bucket_acl" "proxy_config_store" {
bucket = aws_s3_bucket.proxy_config_store.id
acl = "private"
}

data "aws_iam_policy_document" "cf_access" {
statement {
actions = ["s3:GetObject"]
Expand All @@ -36,7 +40,7 @@ resource "aws_s3_bucket_policy" "proxy_config_store_origin_access" {
# Upload Proxy Config
#####################

resource "aws_s3_bucket_object" "config_json" {
resource "aws_s3_object" "config_json" {
bucket = aws_s3_bucket.proxy_config_store.id
key = local.proxy_config_key
content = var.proxy_config_json
Expand Down
2 changes: 1 addition & 1 deletion modules/cloudfront-proxy-config/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.0"
version = ">= 4.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/proxy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module "proxy_package" {

module "edge_proxy" {
source = "terraform-aws-modules/lambda/aws"
version = "2.4.0"
version = "3.1.0"

lambda_at_edge = true

Expand Down
51 changes: 35 additions & 16 deletions modules/statics-deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@ locals {

resource "aws_s3_bucket" "static_upload" {
bucket_prefix = "${var.deployment_name}-tfn-deploy"
acl = "private"
force_destroy = true

# We are using versioning here to ensure that no file gets overridden at upload
versioning {
enabled = true
}

tags = merge(var.tags, var.tags_s3_bucket)
}

resource "aws_s3_bucket_acl" "static_upload" {
bucket = aws_s3_bucket.static_upload.id
acl = "private"
}

# We are using versioning here to ensure that no file gets overridden at upload
resource "aws_s3_bucket_versioning" "static_upload" {
bucket = aws_s3_bucket.static_upload.id
versioning_configuration {
status = "Enabled"
}
}

resource "aws_s3_bucket_notification" "on_create" {
bucket = aws_s3_bucket.static_upload.id

Expand All @@ -35,23 +42,35 @@ resource "aws_s3_bucket_notification" "on_create" {

resource "aws_s3_bucket" "static_deploy" {
bucket_prefix = "${var.deployment_name}-tfn-static"
acl = "private"
force_destroy = true

lifecycle_rule {
id = "Expire static assets"
enabled = var.expire_static_assets >= 0 # -1 disables the cleanup
tags = merge(var.tags, var.tags_s3_bucket)
}

resource "aws_s3_bucket_acl" "static_deploy" {
bucket = aws_s3_bucket.static_deploy.id
acl = "private"
}

resource "aws_s3_bucket_lifecycle_configuration" "static_deploy" {
bucket = aws_s3_bucket.static_deploy.id

tags = {
"tfnextExpire" = "true"
}
rule {
id = "Expire static assets"

expiration {
days = var.expire_static_assets > 0 ? var.expire_static_assets : 0
}
}

tags = merge(var.tags, var.tags_s3_bucket)
filter {
tag {
key = "tfnextExpire"
value = "true"
}
}

status = var.expire_static_assets >= 0 ? "Enabled" : "Disabled" # -1 disables the cleanup
}
}

# CloudFront permissions for the bucket
Expand Down Expand Up @@ -172,7 +191,7 @@ module "lambda_content" {

module "deploy_trigger" {
source = "terraform-aws-modules/lambda/aws"
version = "2.4.0"
version = "3.1.0"

function_name = "${var.deployment_name}_tfn-deploy"
description = "Managed by Terraform Next.js"
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.64.0"
version = ">= 4.8"
configuration_aliases = [aws.global_region]
}
}
Expand Down