-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding deployment for workers (services without ALB attachment)
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash -e | ||
|
||
if [[ ! -f "task-definition.tpl.json" ]]; then | ||
echo "---> ERROR: task-definition.tpl.json not found" | ||
exit 0 | ||
fi | ||
|
||
ERROR=0 | ||
if [[ -z "$AWS_DEFAULT_REGION" ]]; then echo "---> ERROR: Missing variable AWS_DEFAULT_REGION"; ERROR=1; fi | ||
if [[ -z "$APP_NAME" ]]; then echo "---> ERROR: Missing variable APP_NAME"; ERROR=1; fi | ||
if [[ -z "$CLUSTER_NAME" ]]; then echo "---> ERROR: Missing variable CLUSTER_NAME"; ERROR=1; fi | ||
if [[ -z "$IMAGE_NAME" ]]; then echo "---> ERROR: Missing variable IMAGE_NAME"; ERROR=1; fi | ||
if [[ "$ERROR" == "1" ]]; then exit 1; fi | ||
|
||
envsubst < task-definition.tpl.json > task-definition.json | ||
echo "---> Task Definition" | ||
cat task-definition.json | ||
|
||
echo "" | ||
echo "---> Registering Task Definition" | ||
|
||
# Update the ECS service to use the updated Task version | ||
|
||
TASK_ARN=$(aws ecs register-task-definition \ | ||
--cli-input-json file://task-definition.json \ | ||
--query="taskDefinition.taskDefinitionArn" \ | ||
--output=text) | ||
|
||
echo "---> Updating ECS Service" | ||
echo " CLUSTER_NAME: ${CLUSTER_NAME}" | ||
echo " APP_NAME: ${APP_NAME}" | ||
echo " TASK_ARN: ${TASK_ARN}" | ||
|
||
aws ecs update-service \ | ||
--cluster $CLUSTER_NAME \ | ||
--service $APP_NAME \ | ||
--task-definition $TASK_ARN | ||
|
||
RET=$? | ||
|
||
if [ $RET -eq 0 ]; then | ||
echo "---> Deployment completed!" | ||
else | ||
echo "---> ERROR: Deployment FAILED!" | ||
fi | ||
|
||
exit $RET |