Mapfre Incentivos
062125469108Descripción
Cuenta AWS para proyectos de incentivos Mapfre. MAP015 (infraestructura completa) y MP029 (dinamizaciones/screenshots). Documentación técnica completa.
Esta página documenta la cuenta 062125469108 (perfil map015): MAP015 — sistema web de incentivos comerciales (frontend React, backend Rails, RDS, Lambda, API Gateway) y MP029 — procesamiento de screenshots en paralelo (SQS, ECS, Lambda). La migración desde la cuenta 736497247007 está al 98%; el 2% restante son pasos de DNS y alias de producción (ver sección Migración).
Diagrama de arquitectura
Diagrama de flujo completo: frontend (usuarios → CloudFront → S3), backend (CloudFront → API Gateway → Lambda → RDS), cómputo (ECS Staging/Internal/Pro conectados a RDS) e integración MP029 (SQS → ECS Workers → S3). Colores: verde = producción, amarillo/ámbar = staging/internal.
Inventario de recursos
Resumen por proyecto. Detalle completo en las secciones MAP015 y MP029.
| Proyecto | Componentes principales | Región | Perfil CLI |
|---|---|---|---|
| MAP015 - Infraestructura completa | S3, CloudFront, Lambda, ECS, RDS, API Gateway | eu-west-1 | map015 |
| MP029 - Dinamizaciones | SQS, ECS (Fargate/EC2), Lambda autoscalers | eu-west-1 | map015 |
Cuentas: Recursos principales en 062125469108. Legacy producción (CloudFront + DNS) en 736497247007 hasta completar migración.
MAP015 - Infraestructura completa
Sistema web de gestión de incentivos comerciales MAPFRE: frontend React en S3 + CloudFront, backend Rails en ECS, PostgreSQL en RDS, APIs con Lambda y API Gateway. Almacenamiento de uploads en S3 (Gestor de Incidencias) vía Lambda map015-credenciales-front.
Cuenta: 062125469108 · Región principal: eu-west-1 (Irlanda) · CloudFront/ACM: us-east-1 (Virginia)
Ubicación de cuentas y región
| Cuenta | Perfil CLI | Contenido |
|---|---|---|
| 062125469108 | map015 | S3, CloudFront, Lambda, ECS, RDS, API Gateway, ECR, SQS. Entornos staging, internal y producción (en migración). |
| 736497247007 | default | CloudFront producción legacy (E19D44PWJU0CWV), DNS Route53 para incentivosmapfre.es. |
Entornos y dominios
| Entorno | Dominio | Estado | CloudFront ID | Cuenta |
|---|---|---|---|---|
| Staging | staging.incentivosmapfre.es | Operativo | E18PJCYR3XXFQG | 062125469108 |
| Staging AWS | staging.aws.incentivosmapfre.es | Operativo | E1RVUR943JP7KC | 062125469108 |
| Internal | staging.internal.incentivosmapfre.es | Operativo | EJ6DDMJUMZHW8 | 062125469108 |
| Production | incentivosmapfre.es | En migración (98%) | E3FMW0SA8DSNUG (sin alias) / E19D44PWJU0CWV (actual) | 062125469108 / 736497247007 |
S3 - Buckets (detalle completo)
Todos en eu-west-1, cuenta 062125469108. Listado con propósito real según inventario.
| # | Nombre del bucket | Propósito | Dominio / Uso |
|---|---|---|---|
| 1 | mapfre-comercial-goals-production-sub | Frontend production (React build) | Origen CloudFront E3FMW0SA8DSNUG (~32.7 MB) |
| 2 | mapfre-comercial-goals-staging-sub | Frontend staging | staging.incentivosmapfre.es |
| 3 | mapfre-comercial-goals-staging-aws-sub | Frontend staging alternativo | staging.aws.incentivosmapfre.es |
| 4 | mapfre-comercial-goals-internal-sub | Frontend internal/admin | staging.internal.incentivosmapfre.es (~28.2 MB) |
| 5 | map015-produccion-sub | Archivos subidos por usuarios (Gestor de Incidencias) | Lambda map015-credenciales-front, API 9dkphme809. Carpeta: FicherosGestorIncidencias/ (~233.5 MiB, 793 archivos) |
| 6 | map015-staging-sub | Archivos staging | Backend staging |
| 7 | admin.incentivosmapfre.es-production-sub | Backend admin production | Admin production |
| 8 | admin.staging.incentivosmapfre.es-production-sub | Backend admin staging | Admin staging |
| 9 | map020-planconvencer | Proyecto MAP020 (Plan Convencer) | CloudFront E2B7EYOTK0WY3T |
| 10 | dinamizaciones-v2 | Proyecto MAP029 (Dinamizaciones) | MAP029 |
| 11 | dinamizaciones-v3 | Proyecto MAP029 (Dinamizaciones) | MAP029 |
| 12 | mapfre-alb-logs | Logs de Application Load Balancer | ALB access logs |
Comandos útiles S3:
aws s3 ls --profile map015 --region eu-west-1
aws s3 ls s3://map015-produccion-sub/FicherosGestorIncidencias/ --profile map015 --region eu-west-1 --recursive --human-readable --summarize
CloudFront - Distribuciones
Todas en us-east-1 (certificados ACM). Origen principal en eu-west-1 (S3).
| ID | Alias / Dominio | Origen S3 | Estado |
|---|---|---|---|
| E18PJCYR3XXFQG | staging.incentivosmapfre.es | mapfre-comercial-goals-staging-sub | Deployed |
| E1RVUR943JP7KC | staging.aws.incentivosmapfre.es | mapfre-comercial-goals-staging-aws-sub | Deployed |
| EJ6DDMJUMZHW8 | staging.internal.incentivosmapfre.es | mapfre-comercial-goals-internal-sub | Deployed |
| E3FMW0SA8DSNUG | Sin alias (pendiente incentivosmapfre.es) | mapfre-comercial-goals-production-sub | Deployed; bloqueado por CF en 736497247007 |
| E2B7EYOTK0WY3T | MAP020 Plan Convencer | map020-planconvencer | Deployed |
Invalidar caché: aws cloudfront create-invalidation --distribution-id ID --paths "/*" --profile map015 --region us-east-1
Lambda - Funciones (detalle)
Funciones clave: credenciales S3, deploys, migraciones DB, autoscalers MAP015 y MAP029, APIs MAP029, gestión RDS (encendido/apagado).
| Función | Runtime | Propósito | Memoria | Timeout | Conectado a |
|---|---|---|---|---|---|
| map015-credenciales-front | Node.js 18.x | API S3 sin exponer credenciales: listObjects, getObject, putObject, deleteObject | 190 MB | 5 s | API Gateway 9dkphme809, bucket map015-produccion-sub |
| map015-stg-deploy | Python 3.13 | Despliegues MAP015 staging | 128 MB | 3 s | ECS/CI |
| map015-internal-deploy | Python 3.13 | Despliegues MAP015 internal (web + worker) | 128 MB | 60 s | ECS |
| map015-stg-db-migrate | Python 3.13 | Migraciones de base de datos staging | 128 MB | — | RDS staging |
| autoescalado-up-map015-stg | Python 3.13 | Escalar arriba recursos MAP015 staging | 128 MB | — | ECS/EventBridge |
| autoescalado-down-map015-stg | Python 3.13 | Escalar abajo MAP015 staging (ahorro costes) | 128 MB | — | ECS/EventBridge |
| map029-fargate-autoscaler-stg | Python 3.11 | Autoscaler Fargate según profundidad SQS (stg: 0/1 tasks) | 128 MB | 30 s | SQS, ECS map029-screenshots-cluster-stg |
| map029-fargate-autoscaler-pro | Python 3.11 | Autoscaler ECS producción (0/2/3/5 workers según mensajes) | 128 MB | — | SQS, ECS map029-screenshots-cluster-pro |
| MAP029-dinamizaciones-api | Python 3.9 | API gestión dinamizaciones MAP029 | 128 MB | 60 s | API Gateway 18ieaq1z4e |
| MAP029-dinamizaciones-tracking | Python 3.9 | Tracking eventos dinamizaciones | 128 MB | — | SES/eventos |
| MAP029-dinamizaciones-sender | Python 3.9 | Envío notificaciones dinamizaciones | 128 MB | — | SES/notificaciones |
| apagado-rds | Python 3.13 | Apagar RDS en horario programado | 128 MB | — | RDS |
| encendido-rds | Python 3.13 | Encender RDS en horario programado | 128 MB | — | RDS |
| new-object | Python 3.13 | Invalidar CloudFront al subir objeto (MAP020) | 128 MB | — | S3, CF E2B7EYOTK0WY3T |
Logs: aws logs tail /aws/lambda/map015-credenciales-front --follow --profile map015 --region eu-west-1
RDS - Bases de datos PostgreSQL
Tres instancias en eu-west-1, cuenta 062125469108. Clase db.m7g.large, motor PostgreSQL 17.4.
| Identificador | Endpoint | Clase | Almacenamiento | Multi-AZ | Backup | Notas |
|---|---|---|---|---|---|---|
| map015-stg-021025 | map015-stg-021025.cx8qaa0wgnxj.eu-west-1.rds.amazonaws.com:5432 | db.m7g.large | 50 GB gp3 (3000 IOPS) | No | 7 días | Staging. SG: sg-01cb789e92f1ea35b |
| map015-internal-021025 | map015-internal-021025.cx8qaa0wgnxj.eu-west-1.rds.amazonaws.com:5432 | db.m7g.large | 79 GB gp3 (3000 IOPS) | No | 0 días | Internal. Sin backups automáticos |
| map015-pro | map015-pro.cx8qaa0wgnxj.eu-west-1.rds.amazonaws.com:5432 | db.m7g.large | 50 GB gp3 (3000 IOPS) | No | 7 días | Production. Deletion Protection y Performance Insights 7 días |
Conexión: psql -h <endpoint> -U postgres -d <database> -p 5432
ECS - Clusters
Todos en eu-west-1. MAP015: web + worker para staging e internal; MAP029: screenshots (Fargate stg, EC2 pro).
| Cluster | Propósito | Tipo |
|---|---|---|
| map015-stg-web | Staging web frontend | Fargate/EC2 |
| map015-stg-worker | Staging background jobs | Fargate/EC2 |
| map015-internal-web | Internal web frontend | Fargate/EC2 |
| map015-internal-worker | Internal background jobs | Fargate/EC2 |
| map029-screenshots-cluster-stg | Screenshots staging | Fargate |
| map029-screenshots-cluster-pro | Screenshots production | EC2 (t3.medium) |
API Gateway
| API / ID | Tipo | Endpoint | Propósito |
|---|---|---|---|
| map015-credenciales-front (9dkphme809) | REGIONAL | https://9dkphme809.execute-api.eu-west-1.amazonaws.com/v1 | Operaciones S3 seguras (POST /operations). WAF: api-map015-credenciales-front |
| MAP029-dinamizaciones-api (18ieaq1z4e) | EDGE | https://18ieaq1z4e.execute-api.eu-west-1.amazonaws.com | Consultar tracking emails SES |
Migración pendiente (2%) — Pasos para llegar al 100%
El dominio incentivosmapfre.es sigue asociado al CloudFront E19D44PWJU0CWV en la cuenta 736497247007. Hasta liberar ese alias no se puede asignar el dominio al CloudFront E3FMW0SA8DSNUG en 062125469108. A continuación, los pasos pendientes por fases para que el equipo ejecute el cierre de migración.
Seguir las fases en orden. Tiempos orientativos: Fase 1 ~15 min, Fase 2 ~30 min, Fase 3 ~10 min, Fase 4 ~15 min, Fase 5 ~15 min (+ tiempos de propagación CloudFront/DNS).
FASE 1 — Liberar dominio producción (cuenta 736497247007, perfil default)
Objetivo: Deshabilitar el CloudFront origen para liberar el alias incentivosmapfre.es.
- Obtener configuración:
aws cloudfront get-distribution-config --id E19D44PWJU0CWV --profile default --region us-east-1 --output json > /tmp/cf-prod-origen.json - Extraer ETag del JSON.
- Editar JSON:
"Enabled": true→"Enabled": falseenDistributionConfig. - Actualizar:
aws cloudfront update-distribution --id E19D44PWJU0CWV --if-match <ETAG> --distribution-config file:///tmp/cf-prod-origen-disabled.json --profile default --region us-east-1 - Esperar 15–20 minutos a que se libere el dominio.
FASE 2 — Configurar CloudFront destino (cuenta 062125469108, perfil map015)
Objetivo: Añadir alias incentivosmapfre.es y certificado SSL al CloudFront E3FMW0SA8DSNUG.
- Obtener configuración:
aws cloudfront get-distribution-config --id E3FMW0SA8DSNUG --profile map015 --region us-east-1 --output json > /tmp/cf-prod-destino.json - Editar JSON: añadir
Aliases.Items: ["incentivosmapfre.es"]yViewerCertificatecon certificado ACMarn:aws:acm:us-east-1:062125469108:certificate/8a695758-9f0c-48e7-bec8-5ac13df3b310. - Actualizar distribución con
update-distributiony el ETag correspondiente. - Esperar 15–20 minutos propagación.
FASE 3 — Actualizar DNS Route53 (cuenta 736497247007, perfil default)
Objetivo: Apuntar el registro A de incentivosmapfre.es al nuevo CloudFront.
- Obtener Hosted Zone ID de
incentivosmapfre.es. - UPSERT registro A tipo Alias:
HostedZoneId: Z2FDTNDATAQYW2,DNSName: d3omba23mj1mha.cloudfront.net. - Aplicar change batch con
aws route53 change-resource-record-sets. - Verificar con
dig incentivosmapfre.es(propagación hasta 48 h).
FASE 4 — Actualizar frontend (código)
Objetivo: Usar el endpoint API de la cuenta 062125469108.
- Buscar en código:
grep -r "tdwhs7i002" ./src(API antigua). - Reemplazar por:
https://9dkphme809.execute-api.eu-west-1.amazonaws.com/v1/operations. - Compilar y desplegar frontend production a S3/CloudFront (map015, production).
FASE 5 — Verificación final
curl -I https://incentivosmapfre.es— comprobar 200 y certificado.- Probar API:
curl -X POST https://9dkphme809.execute-api.eu-west-1.amazonaws.com/v1/operations -H "Content-Type: application/json" -d '{"operation":"listObjects","bucket":"map015-produccion-sub"}' - Probar subida desde el gestor de incidencias en el frontend.
- Revisar logs:
aws logs tail /aws/lambda/map015-credenciales-front --follow --profile map015 --region eu-west-1
Comandos esenciales (MAP015)
# Configurar perfil
aws configure --profile map015
# S3
aws s3 ls --profile map015 --region eu-west-1
# CloudFront (us-east-1)
aws cloudfront list-distributions --profile map015 --region us-east-1 --query 'DistributionList.Items[*].[Id,DomainName,Aliases.Items[0],Status]' --output table
# Lambda
aws lambda list-functions --profile map015 --region eu-west-1 --query 'Functions[*].[FunctionName,Runtime]' --output table
# RDS
aws rds describe-db-instances --profile map015 --region eu-west-1 --query 'DBInstances[*].[DBInstanceIdentifier,DBInstanceClass,Endpoint.Address]' --output table
# ECS
aws ecs list-clusters --profile map015 --region eu-west-1
# Logs Lambda
aws logs tail /aws/lambda/map015-credenciales-front --follow --profile map015 --region eu-west-1
Costes mensuales estimados (cuenta 062125469108)
| Servicio | Detalle | Estimado |
|---|---|---|
| RDS | 3× db.m7g.large | ~300–400 USD |
| ECS | 6 clusters (Fargate + EC2) | ~50–100 USD |
| CloudFront + S3 | 5 distribuciones, ~500 MB | ~5–15 USD |
| Lambda + API Gateway | 14 funciones, 2 APIs | ~5–10 USD |
| CloudWatch Logs / Data Transfer | — | ~10–30 USD |
| Total | ~380–570 USD/mes |
RDS representa ~75% del coste. Oportunidades: apagar RDS staging/internal fuera de horario; instancias más pequeñas en staging.
Troubleshooting
| Síntoma | Causa probable | Acción |
|---|---|---|
| 403 AccessDenied en CloudFront | Bucket policy S3 o permisos CloudFront | Revisar get-bucket-policy y política pública para CloudFront OAI |
| Lambda timeout al acceder a RDS | Security Group no permite Lambda | Añadir regla entrada SG RDS (puerto 5432) desde SG de Lambda |
| ECS task no arranca | Imagen ECR no encontrada o permisos | Comprobar ecr describe-images y rol de ejecución ECS |
| 502 Bad Gateway en API Gateway | Respuesta Lambda mal formada o timeout | Revisar logs Lambda; respuesta debe incluir statusCode, headers, body |
Enlaces consola AWS (eu-west-1 salvo indicado)
S3 · CloudFront (us-east-1) · Lambda · API Gateway · ECS · RDS · ECR · SQS · IAM · ACM (us-east-1)
Documentación completa de referencia: documentacion_aws/GUIA_INFRAESTRUCTURA_MAP015.md y RESUMEN_EJECUTIVO_MAP015.md.
MP029 - Dinamizaciones
Sistema de procesamiento de screenshots de emails en paralelo: SQS (cola), ECS (workers) y Lambda (autoscaler según profundidad de cola). Reduce tiempos de ~5 h a 20–30 min para ~3000 emails.
Cuenta: 062125469108 · Región: eu-west-1 · Perfil CLI: map015
Ubicación de recursos
- 736497247007: Backend Rails (envía mensajes a SQS), S3 legacy.
- 062125469108: SQS, ECS workers (Fargate stg / EC2 pro), Lambda autoscalers.
Entornos
| Entorno | Sufijo | Cola SQS principal | DLQ | Cluster ECS |
|---|---|---|---|---|
| Staging | -stg | map029-dynamization-screenshots-stg | map029-dynamization-screenshots-dlq-stg | map029-screenshots-cluster-stg |
| Producción | -pro | map029-dynamization-screenshots-pro | map029-dynamization-screenshots-dlq-pro | map029-screenshots-cluster-pro |
Lambda autoscaler
| Entorno | Función | Lógica |
|---|---|---|
| stg | map029-fargate-autoscaler-stg | Mensajes en SQS → desired-count 1; sin mensajes → 0 |
| pro | map029-fargate-autoscaler-pro | 0 msg → 0; 1–500 → 2; 501–1500 → 3; 1501+ → 5 workers |
Comandos útiles MP029
# Mensajes en cola (stg)
aws sqs get-queue-attributes --queue-url https://sqs.eu-west-1.amazonaws.com/062125469108/map029-dynamization-screenshots-stg --attribute-names ApproximateNumberOfMessages --profile map015 --region eu-west-1
# Estado del servicio (stg)
aws ecs describe-services --cluster map029-screenshots-cluster-stg --services map029-screenshots-service-stg --query 'services[0].{Desired:desiredCount,Running:runningCount}' --profile map015 --region eu-west-1
# Logs worker (stg)
aws logs tail /ecs/map029-screenshots-stg --follow --profile map015 --region eu-west-1
# Forzar arranque 1 worker (stg)
aws ecs update-service --cluster map029-screenshots-cluster-stg --service map029-screenshots-service-stg --desired-count 1 --profile map015 --region eu-west-1
Enlaces consola (eu-west-1)
SQS cola stg · ECS map029-screenshots-cluster-stg · Lambda map029-fargate-autoscaler-stg
Guía detallada: documentacion_aws/MAP029_PLAN_IMPLEMENTACION/.