Open jkcdarunday opened 4 years ago
Tried to do this in the AWS web interface. It seems that VPC, security group, and subnet are required even though I'm running with EC2.
I was able to successfully run a task with a command override using the web interface.
Hi @jkcdarunday,
when running a task in network mode "awsvpc", you have to provide the subnet and the security group - like you do in the web (in your screenshot). You can provide those in the call with:
--subnet
--securitygroup
All details and options you can see via ecs run --help
.
Best Fabian
Hi @fabfuel I have tried that as well. However, it did not seem to work and threw the same error.
% ecs run staging projects -c projects "npm run initdb" --launch-type EC2 --securitygroup sg-xxxxxxxxx --subnet subnet-xxxxxxxxx
Using task definition: projects
Changed command of container "projects" to: "npm run initdb" (was: "[]")
An error occurred (InvalidParameterException) when calling the RunTask operation: Network Configuration must be provided when networkMode 'awsvpc' is specified.
Looking at the code, it seems that no networkConfiguration value is being passed if the launch type is EC2 (it is only added on Fargate).
Perhaps networkConfiguration should be passed for the EC2 launch type as well as EC2 also supports awsvpc? https://github.com/fabfuel/ecs-deploy/blob/fe7447af8afb36461bfd5605ed965d8ead514201/ecs_deploy/ecs.py#L93-L124
Indeed, you're right
I have tried to edit the code to always pass networkConfiguration regardless of launch type and it seems to be working with my fork's commit at https://github.com/jkcdarunday/ecs-deploy/commit/6e8ee0d4098858ec3f6618d66586c709bd5f792a
Should I do a pull request? I am not sure if specifying an awsvpcConfiguration affects task definitions that don't use awsvpc though as all of my services currently use awsvpc.
% python ecs_deploy/cli.py run staging projects -c projects "npm run initdb" --securitygroup sg-xxxxxxxx --subnet subnet-xxxxxxxx
Using task definition: projects
Changed command of container "projects" to: "npm run initdb" (was: "[]")
Successfully started 1 instances of task: projects:4
- arn:aws:ecs:ap-southeast-1:xxxxxxxxx:task/staging/xxxxx
Thanks @jkcdarunday, I think the safes way is to add a new argument for the network mode and to require and add the network config to the task definition only, if it is set to awsvpc
.
Best Fabian
Hi,
I get the following when I try to use the run command on a task that use the EC2 launch type and awsvpc as the network mode:
Notes:
61 might be related, however, that issue is with using Fargate. Mine uses EC2 with awsvpc instead.