Comments (12)
I'm looking for the same functionality on Fargate type task
for migration. I also want to wait until a one-off task is finished.
from amazon-ecs-deploy-task-definition.
While this is not a thing, this is how I've done:
release:
runs-on: ubuntu-latest
needs:
- build-application
- build-migrations
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS CLI
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-to-assume: ${{ secrets.aws_role_arn }}
- name: Run database migrations
run: |
aws ecs run-task --task-definition ${{ secrets.AWS_ECS_DB_MIGRATIONS_TASK_NAME}} --cluster ${{ secrets.AWS_ECS_CLUSTER_NAME }} --launch-type="FARGATE" --network-configuration '${{ secrets.ECS_TASK_RUN_NETWORK_CONFIG }}'
- name: Wait for migrations run to finish
run: aws ecs wait tasks-stopped --cluster ${{ secrets.AWS_ECS_CLUSTER_NAME }} --tasks $(aws ecs list-tasks --cluster ${{ secrets.AWS_ECS_CLUSTER_NAME }} --family ${{ secrets.AWS_ECS_DB_MIGRATIONS_TASK_NAME}} --query 'taskArns' --output text)
- name: Download application task definition
run: |
aws ecs describe-task-definition --task-definition ${{ secrets.AWS_ECS_SERVICE_NAME }} \
--query taskDefinition > task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: ${{ secrets.AWS_ECS_CONTAINER_NAME }}
image: ${{ needs.build-application.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ secrets.AWS_ECS_SERVICE_NAME }}
cluster: ${{ secrets.AWS_ECS_CLUSTER_NAME }}
wait-for-service-stability: true
from amazon-ecs-deploy-task-definition.
Here is my simple work around.
In the task-definition.json, define one more container to be used for migration. Use this container as a dependency of the app-container to ensure that migration must be done before deploying.
// task-definition.json
{
"containerDefinitions": [
{
"name": "app-container",
"image": "{my-image}:latest",
"essential": true,
"dependsOn":[
{
"containerName":"migration",
"condition":"SUCCESS"
}
]
},
{
"name":"migration",
"image":"{my-image}:latest",
"essential":false,
"command":[
"npm",
"run",
"migrate"
]
}
]
}
And in the GitHub workflow, fill the latest image into both containers and deploy it.
- name: Render Amazon ECS task definition for app
id: task-def-app
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.TASK_DEFINITION }}
container-name: app-container
image: ${{ steps.build-image.outputs.image }}
- name: Render Amazon ECS task definition for migration
id: task-def-migration
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.task-def-app.outputs.task-definition }}
container-name: migration
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def-migration.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
from amazon-ecs-deploy-task-definition.
Recently created this: https://github.com/muya/amazon-ecs-run-task, which allows:
- setting of launch type OR capacity provider strategy (so you can use
FARGATE
,FARGATE_SPOT
,EC2
or whatever) - setting of appropriate network configuration (subnets, security groups, public IP)
- waiting until a task is finished
It builds upon several other implementations to bring the functionality together. More details in this blog post.
from amazon-ecs-deploy-task-definition.
Any update other workaround on this? Specifically looking to run a step after registering the new task definition and before deploying it.
from amazon-ecs-deploy-task-definition.
This has been sitting in the feature request path for over 3 years!
Kinda expected this feature to just exist... I'll have to look at one of the work arounds
from amazon-ecs-deploy-task-definition.
I think I'm interested in the same functionality. I'd like to deploy a task and just run it on an ECS Cluster without defining a service. After the task runs, it shuts itself down. I don't need it to run indefinitely. Is this possible?
from amazon-ecs-deploy-task-definition.
@cainlevy Not sure if you already figured this out...I ended up creating a github workflow that doesn't use this action at all. Instead, I install the Amazon.ECS.Tools cli and use that (which is what Visual Studio uses).
Example:
name: Deploy to dev environment
on:
push:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Install dependencies
run: dotnet restore {your project name here}
- name: Install AWS command line tools
run: dotnet tool install -g Amazon.ECS.Tools
- name: Deploy to AWS
run: dotnet ecs deploy-task
--region us-east-2
--aws-access-key-id ${{ secrets.AWS_ACCESS_KEY_ID }}
--aws-secret-key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
--container-environment-variables 'ASPNETCORE_ENVIRONMENT=Production;DB_SERVER=${{ secrets.DB_SERVER }};DB_PORT=${{ secrets.DB_PORT }};DB=${{ secrets.DB }};DB_PASSWORD=${{ secrets.DB_PASSWORD }};'
I had to play with the various options of the ecs deploy-task command which are available by typing dotnet ecs help deploy-task
in the cli
from amazon-ecs-deploy-task-definition.
This is what i use for migrations and test on ecs fargate.
https://github.com/noelzubin/aws-ecs-run-task
from amazon-ecs-deploy-task-definition.
any news on this? will it be supported on this action?
from amazon-ecs-deploy-task-definition.
I need this feature as well, use case is: run Prisma migrations before running new tasks
from amazon-ecs-deploy-task-definition.
@DucNguyenVan unfortunately this only works if you have migrations that are under 3 hours.
If you ever have a long migration, AWS will clean up the service because it is still considered pending and re run the process. This would be controllable by ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION
, however this did not seem alterable for FARGATE.
A separate one-off task is required in these cases.
from amazon-ecs-deploy-task-definition.
Related Issues (20)
- Deployment fails immediately without waiting, and CodeDeploy console shows nothing HOT 1
- Support adding docker labels to the rendered task HOT 1
- Add support for DesiredCount HOT 3
- Feature Request: retry upon Rate exceeded error
- Runner connect error: The HTTP request timed out after 00:01:00. . Retrying until reconnected HOT 1
- Unable to cancel workflow
- Create a new task revision with deploying the service HOT 3
- Service reports Error: Resource is not in the state servicesStable after 60 min even with wait-for-minutes set to greater than 60 HOT 1
- Deployment URLs for CodeDeploy always redirect to us-east-2
- Is it possible to register a task definition without deploying the service? HOT 1
- Node 16 Deprecation Warning HOT 8
- Add support for tagging my ECS service
- "arn:aws:ecs:ap-northeast-1:***:service/*******task is MISSING" when deploy dotnet8 to aws ecs HOT 1
- How to define task_definition_task_role_name and task_definition_task_execution_role_name?
- AWS SDK deprecation HOT 1
- Upgrade to newer version of AWS Javascript SDK HOT 6
- Unmasking the URL of ALB HOT 2
- Support passing deployment configuration HOT 1
- Broken Examples with ECS Updates HOT 1
- v1.6.0: STRING_VALUE cannot be converted to Integer HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-ecs-deploy-task-definition.