-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ECS] [request]: Add ability to update task definition #2058
Comments
I've tagged this ECS and edited the issue for service to improve tracking. |
Please prioritize this, because now I have to do the following in my CI yml just to update an image:
|
I have slightly modified this that doesn't need 'jq' but can use custom tag #!/bin/sh
# Define the full image name with tag
FULL_IMAGE="registry/project:mycustomtag"
# Retrieve details of the existing ECS task definition
TASK_DEFINITION=$(aws ecs describe-task-definition \
--task-definition "$TASK_DEFINATION_NAME" \
--region "$REGISTRY_REGION" \
--query '{ containerDefinitions: taskDefinition.containerDefinitions,
family: taskDefinition.family,
executionRoleArn: taskDefinition.executionRoleArn,
volumes: taskDefinition.volumes,
placementConstraints: taskDefinition.placementConstraints,
cpu: taskDefinition.cpu,
memory: taskDefinition.memory
}')
# Modify the task definition to update the image name with the provided full image
NEW_TASK_DEFINITION=$(echo "$TASK_DEFINITION" | sed "s|\"image\": \".*\"|\"image\": \"$FULL_IMAGE\"|")
echo $NEW_TASK_DEFINITION
# Register the modified task definition
NEW_TASK_INFO=$(aws ecs register-task-definition \
--region "$REGISTRY_REGION" \
--cli-input-json "$NEW_TASK_DEFINITION")
echo $NEW_TASK_INFO
# Extract the revision number of the newly registered task definition
REVISION=$(echo "$NEW_TASK_INFO" | grep -o '"revision":[^,]*' | cut -d':' -f2)
# Remove leading and trailing whitespaces from the revision number
NEW_REVISION=$(echo $REVISION | tr -d ' ')
echo $NEW_REVISION
# Update ecs service
UPDATE_SERVICE=$(aws ecs update-service \
--region $REGISTRY_REGION \
--cluster ${CLUSTER_NAME} \
--service ${SERVICE_NAME} \
--task-definition ${TASK_DEFINATION_NAME}:${NEW_REVISION})
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please see aws/aws-sdk#406 for background and discussion.
Community Note
Tell us about your request
What do you want us to build?
Which service(s) is this request for?
ECS [edited]
Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?
What outcome are you trying to achieve, ultimately, and why is it hard/impossible to do right now? What is the impact of not having this problem solved? The more details you can provide, the better we'll be able to understand and solve the problem.
Are you currently working around this issue?
How are you currently solving this problem?
Additional context
Anything else we should know?
Attachments
If you think you might have additional information that you'd like to include via an attachment, please do - we'll take a look. (Remember to remove any personally-identifiable information.)
The text was updated successfully, but these errors were encountered: