Initial Filamenteka setup - Bambu Lab filament tracker

- React + TypeScript frontend with automatic color coding
- Confluence API integration for data sync
- AWS Amplify deployment with Terraform
- Support for all Bambu Lab filament colors including gradients
This commit is contained in:
DaX
2025-06-17 22:39:35 +02:00
parent 8cc137864b
commit c394d94bb0
23 changed files with 1090 additions and 0 deletions

117
terraform/main.tf Normal file
View File

@@ -0,0 +1,117 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
required_version = ">= 1.0"
}
provider "aws" {
region = "eu-central-1" # Frankfurt
}
resource "aws_amplify_app" "filamenteka" {
name = "filamenteka"
repository = var.github_repository
# GitHub access token for private repos
access_token = var.github_token
# Build settings
build_spec = <<-EOT
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
EOT
# Environment variables
environment_variables = {
CONFLUENCE_API_URL = var.confluence_api_url
CONFLUENCE_TOKEN = var.confluence_token
CONFLUENCE_PAGE_ID = var.confluence_page_id
}
# 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
}
}
# 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
# Map main branch to root domain
sub_domain {
branch_name = aws_amplify_branch.main.branch_name
prefix = ""
}
# Map dev branch to dev subdomain
sub_domain {
branch_name = aws_amplify_branch.dev.branch_name
prefix = "dev"
}
}

25
terraform/outputs.tf Normal file
View File

@@ -0,0 +1,25 @@
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 "github_webhook_url" {
description = "The webhook URL for GitHub"
value = aws_amplify_app.filamenteka.production_branch[0].webhook_url
sensitive = true
}

View File

@@ -0,0 +1,11 @@
# Copy this file to terraform.tfvars and fill in your values
github_repository = "https://github.com/yourusername/filamenteka"
github_token = "ghp_your_github_token_here"
confluence_api_url = "https://your-domain.atlassian.net"
confluence_token = "your_confluence_api_token"
confluence_page_id = "your_confluence_page_id"
# Optional: Custom domain
# domain_name = "filamenteka.yourdomain.com"

38
terraform/variables.tf Normal file
View File

@@ -0,0 +1,38 @@
variable "github_repository" {
description = "GitHub repository URL"
type = string
}
variable "github_token" {
description = "GitHub personal access token for Amplify"
type = string
sensitive = true
}
variable "confluence_api_url" {
description = "Confluence API base URL"
type = string
}
variable "confluence_token" {
description = "Confluence API token"
type = string
sensitive = true
}
variable "confluence_page_id" {
description = "Confluence page ID containing the filament table"
type = string
}
variable "domain_name" {
description = "Custom domain name (optional)"
type = string
default = ""
}
variable "environment" {
description = "Environment name"
type = string
default = "production"
}