Created
March 22, 2023 21:05
-
-
Save nathanpeck/d0abaf13b1a0baeec80fcb166ac84f87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IMAGE_URL="httpd:2.4" | |
CPU=256 | |
MEMORY=512 | |
export TASK_DEFINITION=$(cat << EOF | |
{ | |
"containerDefinitions": [ | |
{ | |
"command": [ | |
"/bin/sh -c \"echo '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p> </div></body></html>' > /usr/local/apache2/htdocs/index.html && httpd-foreground\"" | |
], | |
"entryPoint": [ | |
"sh", | |
"-c" | |
], | |
"essential": true, | |
"image": "$IMAGE_URL", | |
"logConfiguration": { | |
"logDriver": "awslogs", | |
"options": { | |
"awslogs-group" : "/ecs/fargate-task-definition", | |
"awslogs-region": "us-east-1", | |
"awslogs-stream-prefix": "ecs" | |
} | |
}, | |
"name": "sample-fargate-app", | |
"portMappings": [ | |
{ | |
"containerPort": 80, | |
"hostPort": 80, | |
"protocol": "tcp" | |
} | |
] | |
} | |
], | |
"cpu": "$CPU", | |
"executionRoleArn": "arn:aws:iam::012345678910:role/ecsTaskExecutionRole", | |
"family": "fargate-task-definition", | |
"memory": "$MEMORY", | |
"networkMode": "awsvpc", | |
"requiresCompatibilities": [ | |
"FARGATE" | |
] | |
} | |
EOF | |
) | |
aws ecs register-task-definition --cli-input-json "$TASK_DEFINITION" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment