Skip to content

feat: security and infrastructure improvements#6

Merged
flaviomilan merged 4 commits intomainfrom
feat/security-and-infrastructure-improvements
Mar 27, 2026
Merged

feat: security and infrastructure improvements#6
flaviomilan merged 4 commits intomainfrom
feat/security-and-infrastructure-improvements

Conversation

@flaviomilan
Copy link
Copy Markdown
Owner

Melhorias de Segurança e Infraestrutura

Resumo

Reestruturação completa do Terraform e dos workflows GitHub Actions para uma solução altamente segura e automatizada.

Mudanças Principais

🔒 Segurança

  • S3 com criptografia AES-256, versionamento e lifecycle
  • CloudFront com HTTP/3, TLS 1.2_2021, headers completos (CSP, HSTS, Referrer-Policy, Permissions-Policy)
  • WAF v2 com 5 regras: Rate Limiting, Common Rules (OWASP), Known Bad Inputs, IP Reputation, Anonymous IP + logging
  • ACM com SAN para www + timeout de validação
  • Route53 com force_destroy=false, IPv6 (AAAA) e registros www
  • OIDC para GitHub Actions (elimina access keys de longa duração)

🏗️ Infraestrutura

  • Terraform reestruturado em arquivos por recurso (s3.tf, cloudfront.tf, acm.tf, route53.tf, waf.tf, monitoring.tf)
  • Módulo bootstrap/ para state remoto (S3 + DynamoDB locking)
  • 13 variáveis com validações (era 6)
  • Content-type mapping automático para 30 extensões

🔄 CI/CD

  • Deploy em 4 etapas com approval gates: Plan → DNS → Certificate → Site
  • Verificação automática de propagação DNS com retry
  • Invalidação de cache CloudFront no deploy
  • PR check corrigido (paths, format check, valida bootstrap)
  • Bootstrap workflow manual (workflow_dispatch)

📊 Monitoramento

  • CloudWatch dashboard (requests, errors, bytes, cache hit rate, WAF)
  • Alarmes para 5xx, 4xx e WAF blocked spike
  • SNS + email para notificações

🐛 Bugs Corrigidos

  • count + for_each simultâneos em Route53 records e S3 objects (inválido no Terraform)
  • Paths inconsistentes nos workflows (/infra/aws, /apps/src)

Validação

  • terraform validate ✅ em src/ e bootstrap/

- Restructure Terraform into separate files per resource (s3, cloudfront, acm, route53, waf, monitoring)
- Add S3 encryption (AES-256), versioning, and lifecycle management
- Enhance CloudFront with HTTP/3, TLS 1.2_2021, CSP, Referrer-Policy, Permissions-Policy
- Expand WAF v2 with rate limiting, Known Bad Inputs, IP Reputation, Anonymous IP rules and logging
- Add ACM SAN for www subdomain with validation timeout
- Add Route53 IPv6 (AAAA) records and www aliases, force_destroy=false by default
- Add CloudWatch dashboard, alarms (5xx/4xx/WAF), SNS notifications
- Add bootstrap module for remote state (S3 + DynamoDB locking)
- Redesign GitHub Actions: 4-step deploy with approval gates, DNS verification, cache invalidation
- Switch to OIDC authentication (no long-lived AWS credentials)
- Fix invalid count+for_each on Route53 records and S3 objects
- Fix inconsistent workflow paths (/infra/aws, /apps -> /src)
- Add 13 variables with validations (was 6), including CSP, WAF rate limit, monitoring
- Update README with full documentation, deploy flow, costs, and troubleshooting
- Change enable_monitoring default to false (~$10-15/month)
- Add enable_s3_versioning variable (default false)
- Gate S3 versioning and lifecycle on enable_s3_versioning
- Update README cost table with per-feature costs and toggle variables
- Remove AWS credentials from PR quality check (not needed for validate)
- Add access key fallback to all deploy/bootstrap workflow credential steps
- The action auto-detects: OIDC if AWS_ROLE_ARN is set, access keys otherwise
- Translate entire README.md from Portuguese to English
- Add troubleshooting section for credential errors
- Document both auth options (access keys and OIDC)
@flaviomilan flaviomilan merged commit 4afd7de into main Mar 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant