Error: Cycle: module.ecr.aws_ecr_repository.app_repository, module.ecr.var.repository_names (expand), module.ecr.output.repository_urls (expand), local.applications (expand), local.app_names (expand) and what is the cost of all this
The error you're seeing is due to a circular dependency in the Terraform configuration. Let me fix that and provide a cost estimate:
I've fixed the dependency cycle by removing the circular reference between the ECR repository URLs and the application definitions. The key changes were:
local.applications map in app_config.tfThis breaks the circular dependency and should allow Terraform to properly plan and apply the configuration.
Here's an estimated monthly cost breakdown for running this infrastructure in AWS South Africa (af-south-1) region:
Development Environment:
Production Environment:
Development Environment:
Production Environment:
These estimates are based on current AWS pricing and may vary based on actual usage patterns, data transfer, and other factors. The South Africa region tends to be slightly more expensive than some other AWS regions.
Rollback Service deployment rolled back because the circuit breaker threshold was exceeded.
Started at: 06 May 2025 at 15:38 (UTC+2:00)
The error you're seeing indicates that your ECS service deployment was automatically rolled back because it couldn't stabilize. This is a safety feature in ECS called the "circuit breaker" that prevents failed deployments from continuing indefinitely.
Your containers might be failing health checks or crashing shortly after starting.
First, check the CloudWatch logs for your containers to see why they're failing:
aws logs get-log-events \
--log-group-name "/ecs/dev/hellochoice-admin" \
--log-stream-name "hellochoice-admin/latest" \
--region af-south-1Make sure your container images exist in ECR and are properly tagged:
aws ecr describe-images \
--repository-name hellochoice-admin \
--region af-south-1Pull and test your container locally to verify it works:
aws ecr get-login-password --region af-south-1 | docker login --username AWS --password-stdin YOUR_AWS_ACCOUNT_ID.dkr.ecr.af-south-1.amazonaws.com
docker pull YOUR_AWS_ACCOUNT_ID.dkr.ecr.af-south-1.amazonaws.com/hellochoice-admin:latest
docker run -p 8080:8080 YOUR_AWS_ACCOUNT_ID.dkr.ecr.af-south-1.amazonaws.com/hellochoice-admin:latestVerify that your security groups allow traffic between the Nginx container and your application containers:
aws ec2 describe-security-groups \
--group-ids sg-XXXXX \
--region af-south-1I've updated your ECS service configuration with:
If the issue persists, consider:
aws ecs update-service \
--cluster dev-hellochoice-cluster \
--service dev-hellochoice-admin-service \
--force-new-deployment \
--region af-south-1These changes should help stabilize your deployment and provide better visibility into any issues that occur.
FARGATE 1.4.0 1 vCPU 2 GB