# S3 bucket for static assets
resource "aws_s3_bucket" "assets" {
bucket = "${var.project_name}-assets-${var.environment}"
}
resource "aws_s3_bucket_versioning" "assets" {
#!/bin/bash
# Helm commands
# Add repositories
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
# Optimized production Dockerfile
# Stage 1: Dependencies
FROM node:20-alpine AS deps
WORKDIR /app
---
# Main playbook
- name: Configure web servers
hosts: webservers
become: yes
vars:
# Pre-commit hooks configuration
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
# Install cert-manager (Helm)
# helm install cert-manager jetstack/cert-manager # --namespace cert-manager # --create-namespace # --set installCRDs=true
---
# ClusterIssuer for Let's Encrypt (staging)
apiVersion: cert-manager.io/v1
# ECS Task Execution Role (pull images, push logs)
resource "aws_iam_role" "ecs_execution" {
name = "${var.project_name}-ecs-execution"
assume_role_policy = jsonencode({
Version = "2012-10-17"
// Structured logging with Winston (Node.js)
const winston = require('winston');
const { v4: uuidv4 } = require('uuid');
// Create logger
const logger = winston.createLogger({
# Grafana provisioning: datasources
# /etc/grafana/provisioning/datasources/prometheus.yml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
# Prometheus configuration
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_timeout: 10s
# Main nginx.conf
worker_processes auto;
worker_rlimit_nofile 65535;
events {
#!/bin/bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'