GSM Infrastructure ships with a layered cost-control strategy that combines an AWS Budget ceiling, real-time SNS email alerts, and an automated EC2/ECS start-stop scheduler. Together these controls provide visibility into spend before it exceeds your target and eliminate idle instance-hours during off-hours — all configured declaratively through CloudFormation parameters so each environment can carry its own limit.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ti-infinite/GSMInfrastructure/llms.txt
Use this file to discover all available pages before exploring further.
AWS Budget
TheAwsCostBudget CloudFormation resource provisions a monthly COST budget automatically named:
BudgetLimitUSD parameter value. The default limit is $30 USD, but you should override this per environment in your GitHub Actions variables (BUDGET_LIMIT).
AWS Budgets evaluates spend up to three times per day. The alert may not fire the instant you cross the threshold — expect a delay of several hours at most.
SNS Notification Topic
The infrastructure stack creates an SNS topic named:AlertEmail CloudFormation parameter (set via the ALERT_EMAIL GitHub variable). AWS sends a subscription confirmation email to that address immediately after the stack is created or updated.
The SNS topic also carries an IAM topic policy that allows events.amazonaws.com to publish to it, keeping the door open for future EventBridge-to-SNS integrations.
Automated Scheduler
The start/stop scheduler is the single largest lever for cost reduction. A pair of EventBridge Schedules invoke Lambda functions on a weekday cron to:- Stop — scale all four ECS services to
desiredCount=0, disassociate the Elastic IP, then stop the EC2 instance. - Start — start the EC2 instance, wait until it is running, reassociate the Elastic IP, then scale ECS services back to
desiredCount=1.
Cost Optimization Tips
Use t4g.medium (arm64)
The default
Ec2InstanceType is t4g.medium. Graviton-based instances offer roughly 20% better price-performance than equivalent x86 instance types. Both Lambda functions in the scheduler stack are also deployed on arm64 to stay consistent.CloudFront PriceClass_100
The CloudFront distribution uses
PriceClass_100, restricting edge locations to North America and Europe. This is the lowest-cost price class. If your users are in other regions, evaluate whether the latency trade-off justifies upgrading to PriceClass_200 or PriceClass_All.Short CloudWatch log retention
Backend ECS logs (
/ecs/{env}-{appName}-backend) are retained for 7 days. Scheduler Lambda logs are retained for 14 days. CloudWatch Logs storage is billed per GB — keeping retention windows short prevents unbounded accumulation.Per-environment budget limits
Set a conservative
BudgetLimitUSD in development and QA (e.g., $15) and a higher value in production. This way, unexpected spend in lower environments triggers an alert before it silently balloons.