Skip to content

Commit 32729bd

Browse files
committed
feat: ecs issue fixed
1 parent c18f123 commit 32729bd

File tree

2 files changed

+81
-4
lines changed

2 files changed

+81
-4
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,8 @@ If you ran the seeder:
121121
- **Email**: [email protected]
122122
- **Password**: password
123123

124-
## Testing
125-
126-
The application includes comprehensive tests following the clean architecture:
127124

128125
### Run Tests
129126
```bash
130127
# Run all tests
131-
php artisan test
128+
php artisan test

aws/create-ecs-service.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
# Create ECS Service for Laravel Blog
4+
echo "🚀 Creating ECS Service for Laravel Blog..."
5+
6+
# Get AWS Account ID
7+
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
8+
echo "📋 AWS Account ID: $ACCOUNT_ID"
9+
10+
# Get CloudFormation outputs
11+
echo "📋 Getting CloudFormation outputs..."
12+
13+
PRIVATE_SUBNET_1=$(aws cloudformation describe-stacks \
14+
--stack-name laravel-blog-infrastructure \
15+
--query 'Stacks[0].Outputs[?OutputKey==`PrivateSubnet1`].OutputValue' \
16+
--output text)
17+
18+
PRIVATE_SUBNET_2=$(aws cloudformation describe-stacks \
19+
--stack-name laravel-blog-infrastructure \
20+
--query 'Stacks[0].Outputs[?OutputKey==`PrivateSubnet2`].OutputValue' \
21+
--output text)
22+
23+
ECS_SECURITY_GROUP=$(aws ec2 describe-security-groups \
24+
--filters "Name=group-name,Values=laravel-blog-ecs-sg" \
25+
--query 'SecurityGroups[0].GroupId' \
26+
--output text)
27+
28+
TARGET_GROUP_ARN=$(aws cloudformation describe-stacks \
29+
--stack-name laravel-blog-infrastructure \
30+
--query 'Stacks[0].Outputs[?OutputKey==`TargetGroup`].OutputValue' \
31+
--output text)
32+
33+
echo "📋 Infrastructure Details:"
34+
echo " Private Subnet 1: $PRIVATE_SUBNET_1"
35+
echo " Private Subnet 2: $PRIVATE_SUBNET_2"
36+
echo " Security Group: $ECS_SECURITY_GROUP"
37+
echo " Target Group: $TARGET_GROUP_ARN"
38+
39+
# First, register the task definition
40+
echo "📝 Registering ECS Task Definition..."
41+
aws ecs register-task-definition --cli-input-json file://aws/task-definition.json
42+
43+
# Create the ECS service
44+
echo "🔧 Creating ECS Service..."
45+
aws ecs create-service \
46+
--cluster laravel-blog-cluster \
47+
--service-name laravel-blog-service \
48+
--task-definition laravel-blog-task:1 \
49+
--desired-count 1 \
50+
--launch-type FARGATE \
51+
--platform-version LATEST \
52+
--network-configuration "awsvpcConfiguration={
53+
subnets=[$PRIVATE_SUBNET_1,$PRIVATE_SUBNET_2],
54+
securityGroups=[$ECS_SECURITY_GROUP],
55+
assignPublicIp=ENABLED
56+
}" \
57+
--load-balancers "targetGroupArn=$TARGET_GROUP_ARN,containerName=laravel-app,containerPort=80" \
58+
--health-check-grace-period-seconds 300
59+
60+
if [ $? -eq 0 ]; then
61+
echo "✅ ECS Service created successfully!"
62+
echo ""
63+
echo "🎉 Service Details:"
64+
echo " Cluster: laravel-blog-cluster"
65+
echo " Service: laravel-blog-service"
66+
echo " Task Definition: laravel-blog-task:1"
67+
echo " Desired Count: 1"
68+
echo ""
69+
echo "⏱️ The service is now starting up..."
70+
echo " You can monitor it in the AWS ECS Console"
71+
echo ""
72+
echo "🚀 Next steps:"
73+
echo " 1. Wait for the service to become stable (~5-10 minutes)"
74+
echo " 2. Get your application URL:"
75+
echo " aws cloudformation describe-stacks --stack-name laravel-blog-infrastructure --query 'Stacks[0].Outputs[?OutputKey==\`LoadBalancer\`].OutputValue' --output text"
76+
echo " 3. Future deployments will work automatically via GitHub Actions"
77+
else
78+
echo "❌ Failed to create ECS service"
79+
echo "Please check the AWS Console for more details"
80+
fi

0 commit comments

Comments
 (0)