From 1ce127c51c432a44ebcca68315c366d925d42b67 Mon Sep 17 00:00:00 2001 From: DaX Date: Fri, 31 Oct 2025 02:07:14 +0100 Subject: [PATCH] Remove deprecated Amplify resources after CloudFront migration - Comment out Amplify app, branches, and domain association - Remove Amplify-related outputs - Add migration notes for reference - Amplify app deleted from AWS (dd6qls201bf9n) --- terraform/main.tf | 209 ++++++++++++++++++++----------------------- terraform/outputs.tf | 39 ++++---- 2 files changed, 115 insertions(+), 133 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 45b5fa0..38f4eca 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -20,117 +20,98 @@ provider "cloudflare" { api_token = var.cloudflare_api_token != "" ? var.cloudflare_api_token : "dummy" # Dummy token if not provided } -resource "aws_amplify_app" "filamenteka" { - name = "filamenteka" - repository = var.github_repository - platform = "WEB" - - # GitHub access token for private repos (optional for public repos) - # access_token = var.github_token - - # Build settings for Next.js - build_spec = <<-EOT - version: 1 - frontend: - phases: - preBuild: - commands: - - npm ci - - npm run security:check - build: - commands: - - npm run build - - npm run test - artifacts: - baseDirectory: .next - files: - - '**/*' - cache: - paths: - - node_modules/**/* - - .next/cache/**/* - EOT - - # Environment variables - environment_variables = { - NEXT_PUBLIC_API_URL = "https://api.filamenteka.rs/api" # Using Cloudflare proxied subdomain - } - - # Custom rules for single-page app - custom_rule { - source = "/<*>" - status = "404" - target = "/index.html" - } - - # Enable branch auto build - enable_branch_auto_build = true - - tags = { - Name = "Filamenteka" - Environment = var.environment - # Disable GitHub App migration prompt - "amplify:github_app_migration" = "opted_out" - } -} - -# Main branch -resource "aws_amplify_branch" "main" { - app_id = aws_amplify_app.filamenteka.id - branch_name = "main" - - # Enable auto build - enable_auto_build = true - - # Environment variables specific to this branch (optional) - environment_variables = {} - - stage = "PRODUCTION" - - tags = { - Name = "Filamenteka-main" - Environment = var.environment - } -} - -# Development branch (optional) -resource "aws_amplify_branch" "dev" { - app_id = aws_amplify_app.filamenteka.id - branch_name = "dev" - - enable_auto_build = true - - stage = "DEVELOPMENT" - - tags = { - Name = "Filamenteka-dev" - Environment = "development" - } -} - -# Custom domain (optional) -resource "aws_amplify_domain_association" "filamenteka" { - count = var.domain_name != "" ? 1 : 0 - - app_id = aws_amplify_app.filamenteka.id - domain_name = var.domain_name - wait_for_verification = false - - # Map main branch to root domain - sub_domain { - branch_name = aws_amplify_branch.main.branch_name - prefix = "" - } - - # Map main branch to www subdomain - sub_domain { - branch_name = aws_amplify_branch.main.branch_name - prefix = "www" - } - - # Map dev branch to dev subdomain - sub_domain { - branch_name = aws_amplify_branch.dev.branch_name - prefix = "dev" - } -} \ No newline at end of file +# ===== DEPRECATED: Amplify Hosting (Migrated to CloudFront + S3) ===== +# Amplify app was deleted due to broken GitHub integration +# Frontend now hosted on CloudFront + S3 (see cloudfront-frontend.tf) +# Kept here for reference only +# +# resource "aws_amplify_app" "filamenteka" { +# name = "filamenteka" +# repository = var.github_repository +# platform = "WEB" +# +# build_spec = <<-EOT +# version: 1 +# frontend: +# phases: +# preBuild: +# commands: +# - npm ci +# - npm run security:check +# build: +# commands: +# - npm run build +# - npm run test +# artifacts: +# baseDirectory: .next +# files: +# - '**/*' +# cache: +# paths: +# - node_modules/**/* +# - .next/cache/**/* +# EOT +# +# environment_variables = { +# NEXT_PUBLIC_API_URL = "https://api.filamenteka.rs/api" +# } +# +# custom_rule { +# source = "/<*>" +# status = "404" +# target = "/index.html" +# } +# +# enable_branch_auto_build = true +# +# tags = { +# Name = "Filamenteka" +# Environment = var.environment +# "amplify:github_app_migration" = "opted_out" +# } +# } +# +# resource "aws_amplify_branch" "main" { +# app_id = aws_amplify_app.filamenteka.id +# branch_name = "main" +# enable_auto_build = true +# environment_variables = {} +# stage = "PRODUCTION" +# tags = { +# Name = "Filamenteka-main" +# Environment = var.environment +# } +# } +# +# resource "aws_amplify_branch" "dev" { +# app_id = aws_amplify_app.filamenteka.id +# branch_name = "dev" +# enable_auto_build = true +# stage = "DEVELOPMENT" +# tags = { +# Name = "Filamenteka-dev" +# Environment = "development" +# } +# } +# +# resource "aws_amplify_domain_association" "filamenteka" { +# count = var.domain_name != "" ? 1 : 0 +# app_id = aws_amplify_app.filamenteka.id +# domain_name = var.domain_name +# wait_for_verification = false +# +# sub_domain { +# branch_name = aws_amplify_branch.main.branch_name +# prefix = "" +# } +# +# sub_domain { +# branch_name = aws_amplify_branch.main.branch_name +# prefix = "www" +# } +# +# sub_domain { +# branch_name = aws_amplify_branch.dev.branch_name +# prefix = "dev" +# } +# } \ No newline at end of file diff --git a/terraform/outputs.tf b/terraform/outputs.tf index a333c92..9e0445d 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -1,22 +1,23 @@ -output "app_id" { - description = "The ID of the Amplify app" - value = aws_amplify_app.filamenteka.id -} - -output "app_url" { - description = "The default URL of the Amplify app" - value = "https://main.${aws_amplify_app.filamenteka.default_domain}" -} - -output "dev_url" { - description = "The development branch URL" - value = "https://dev.${aws_amplify_app.filamenteka.default_domain}" -} - -output "custom_domain_url" { - description = "The custom domain URL (if configured)" - value = var.domain_name != "" ? "https://${var.domain_name}" : "Not configured" -} +# ===== DEPRECATED: Amplify Outputs (removed after migration to CloudFront) ===== +# output "app_id" { +# description = "The ID of the Amplify app" +# value = aws_amplify_app.filamenteka.id +# } +# +# output "app_url" { +# description = "The default URL of the Amplify app" +# value = "https://main.${aws_amplify_app.filamenteka.default_domain}" +# } +# +# output "dev_url" { +# description = "The development branch URL" +# value = "https://dev.${aws_amplify_app.filamenteka.default_domain}" +# } +# +# output "custom_domain_url" { +# description = "The custom domain URL (if configured)" +# value = var.domain_name != "" ? "https://${var.domain_name}" : "Not configured" +# } output "rds_endpoint" { value = aws_db_instance.filamenteka.endpoint