Skip to content
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

Add ad-hoc task runs #304

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

inhumantsar
Copy link

@inhumantsar inhumantsar commented Feb 13, 2022

Issue #, if available: #54

Description of changes: This adds the ability to run tasks outside of a service, either standalone or as an init task.

This borrows a lot from #273 but offers a slightly cleaner interface and isn't dependent on a service.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

EDIT: In case you're seeing this and want to use it, you can pull it directly from the PR in your GitHub Actions workflow (see below). We've been using it in production for months now and I'm happy to keep supporting it.

      - name: Deploy Amazon ECS task definition
        id: deploy-task-def
        uses: inhumantsar/amazon-ecs-deploy-task-definition@feat/run-task
        with:
          task-definition: ${{ steps.render-task-def.outputs.task-definition }}
          ...

@inhumantsar inhumantsar force-pushed the feat/run-task branch 2 times, most recently from 4ca14cb to 9a8a47a Compare February 19, 2022 02:08
@inhumantsar inhumantsar marked this pull request as ready for review February 19, 2022 02:08
@duggan
Copy link

duggan commented Apr 11, 2022

Thanks @inhumantsar! I've been running this in a fork for a couple of weeks, works reliably, has been very handy for running DB migrations as part of an ECS deployment flow.

Would be great to see it merged to make it generally available.

@inhumantsar
Copy link
Author

@clareliguori @mattsb42-aws sorry for the ping, just hoping to get a review on this.

@anitakrueger
Copy link

We would also very much like this feature. We've been using the amazon-ecs-deploy-task-definition action for quite a while and this will enable us to run one time tasks.

@inhumantsar
Copy link
Author

@duggan @anitakrueger FYI you can use this PR prior to merge. See the updated PR description

@andrewlynch
Copy link

andrewlynch commented Sep 23, 2022

When I create a once-off task, the ENI is being created without a public IP address. It's the same as not ticking the Public IP address box on the AWS Console when running a task. This is preventing the task from fetching keys from the secrets manager. Is it possible to specify that an IP must be created?

@redterror
Copy link

Would it be possible to adjust this so that the task definition isn't implicitly created / updated? This feature would help my team but we are managing our task defs / services via terraform and already have an ARN we could pass in.


const waitForTask = core.getInput('wait-for-task-stopped', { required: false }) || 'false';
const startedBy = core.getInput('run-task-started-by', { required: false }) || 'GitHub-Actions';
const launchType = core.getInput('run-task-launch-type', { required: false }) || 'FARGATE';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For users with a capacity provider, the launchType param is supposed to be omitted. The implicit default of FARGATE here would prevent that.

@boserup
Copy link

boserup commented Feb 1, 2023

Any progress on this @inhumantsar? I really think this would be a valuable addition to the action.

@inhumantsar
Copy link
Author

inhumantsar commented Feb 28, 2023

Any progress on this @inhumantsar? I really think this would be a valuable addition to the action.

I wouldn't count on this PR being merged anytime soon. No one from AWS seems interested in even looking at it. Even after escalating it to our TAM.

If I'm being totally honest, the scheduled and ad-hoc task operations seem like they haven't had any love from the ECS team in general, so I'm not optimistic about this execution model's future. I've been recommending that our devs leverage Lambda or Lambda+EC2 for anything like this going forward.

Edit: FWIW, we've been running this fork in production for a year now without issue.

@muzfuz
Copy link

muzfuz commented Jul 5, 2023

@inhumantsar thanks for your work on this in any case.

Quite frustrating that the AWS team won't support this package, as it's a very common use case.

@boserup
Copy link

boserup commented Jul 5, 2023

We ended up using the AWS CLI to run one-off commands after deployments from our pipeline.
The trick is to enable wait-for-service-stability when deploying the new task and afterwards use the aws ecs list-tasks command to determine the ID of the newly created task.

Then one can simply run a command as such:

aws ecs execute-command --cluster CLUSTER_NAME --task ${{ steps.ecs_task_id.outputs.TASK_ID }} --container CONTAINER_NAME --interactive --command "uname -a"

It is not as clean as I'd like, but it gets the job done in our case.

@amazreech
Copy link
Contributor

amazreech commented May 10, 2024

Hi @inhumantsar,

Thank you for your contribution, apologies on the delay. We will be working to review the changes in the Pull Request. In the meantime please ensure that below steps, if not already completed, are taken care of in your Pull Request:

  1. Verify if PR follows semantic pull request conventions.
    Example: Update the PR title to follow conventions feat: add ad-hoc task runs ...

  2. Resolve any conflicts on the PR

  3. Please run npm run package command to update dist/ folder with latest dependencies.


mockRunTask.mockImplementation(() => {
return {
promise() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mock needs to be updated as the action is now using JS SDK v3

Refer: #529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants