fargatecli icon indicating copy to clipboard operation
fargatecli copied to clipboard

Create default SG for Task Run and Service Create

Open senglin opened this issue 5 years ago • 0 comments

Issue #, if available:

  1. Fargate CLI currently does not check if the default security groups exist. It polls for the fargate-default security group. For fresh AWS accounts, there is no such SG. This results in a nil being returned. The CLI continues down this path to register the task/service with the SG, resulting in the following error message
  2. To reproduce this error, go to the AWS Console -> EC2> Security groups. If fargate-default is available, select it and remove it.
  3. In a terminal window, do the following:
> fargate task run web --image nginx:latest -v
...
[!] Could not run ECS task
InvalidParameterException: security group cannot be blank.
        status code: 400, request id: ce47d313-0784-4dfa-8c1b-f359f02693b0

Description of changes:

  • Added SetDefaultSecurityGroupID() call to check for default security groups for run task and create service.
  • Run task and create service creates default security group if default security group does not exist.
  • Similar function in vpc_operation.go is refactored into EC2 client and shared with service_create.go and task_run.go.
  • Added console logs in EC2 client, service_create.go, task_run.go.
  • Unit tests for refactored code. Increased EC2 module code coverage by 10%.

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

senglin avatar Jun 01 '20 06:06 senglin