Skip to content

Commit b86e7b5

Browse files
authored
chore: log cmd to create default cluster on task run error (#2035)
When we don't set `--env` flags, [Copilot run task on default cluster](https://github.com/aws/copilot-cli/blob/mainline/internal/pkg/cli/task_run.go#L197). In the old description, it is difficult to understand what happens if we don't set `--default` flag. Copilot allows to deploy the service to another region(environment) without changing profile's region, but task run without `--env` use default region only (perhaps) so I added description about region. I think it is better to add `--region` option in `run task` command but there is a workaround so I can't say it should be done 🤔 Therefore, I added only the explanation first.
1 parent f32310c commit b86e7b5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

internal/pkg/cli/task_run.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ func (o *runTaskOpts) Execute() error {
404404
return fmt.Errorf(`find "default" cluster to deploy the task to: %v`, err)
405405
}
406406
if !hasDefaultCluster {
407+
log.Errorf(
408+
"Looks like there is no \"default\" cluster in your region!\nPlease run %s to create the cluster first, and then re-run %s.\n",
409+
color.HighlightCode("aws ecs create-cluster"),
410+
color.HighlightCode("copilot task run"),
411+
)
407412
return errors.New(`cannot find a "default" cluster to deploy the task to`)
408413
}
409414
}

site/content/docs/commands/task-run.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ Generally, the steps involved in task run are:
1616
!!!info
1717
1. Tasks with the same group name share the same set of resources, including the CloudFormation stack, ECR repository, CloudWatch log group and task definition.
1818
2. If the tasks are deployed to a Copilot environment (i.e. by specifying `--env`), only public subnets that are created by that environment will be used.
19-
3. The `--env` flag only works with environments created with v0.3.0 of Copilot or later. Customers using environments created with v0.2.0 or earlier can update their environment manager role with [this](https://github.com/aws/copilot-cli/blob/mainline/templates/environment/cf/environment-manager-role.yml) policy.
20-
4. If you are using the `--default` flag and get an error saying there's no default cluster, run `aws ecs create-cluster` and then re-run the Copilot command.
19+
3. If you are using the `--default` flag and get an error saying there's no default cluster, run `aws ecs create-cluster` and then re-run the Copilot command.
2120

2221
## What are the flags?
2322
```

0 commit comments

Comments
 (0)