使用ecs-cli启动fargate容器时如何指定enable_execute_command?

Ali*_*ton 8 amazon-web-services amazon-ecs aws-fargate

我运行 aws fargate 容器,它们是使用ecs-cli如下方式启动的:

ecs-cli configure --cluster ${cluster_name} --default-launch-type FARGATE --region ${AWS_REGION} --config-name ${config_name}
ecs-cli compose --project-name ${service_name} service up
Run Code Online (Sandbox Code Playgroud)

我想用来aws ecs execute在这些容器中运行命令。我可以在该主题上找到的所有示例都使用aws命令行工具,而不是ecs-cli. 该文档指定,为了使用aws ecs execute,您必须使用 启动该服务--enable-execute-command

该标志确实存在于aws命令行工具中 - 但没有相应的标志ecs-cliecs-cli通过 yaml 文件配置,ecs-params.yml. 但是,文档再次没有提及可在该文件中使用来启用执行命令的设置。这就是我的ecs-params.yml样子:

ecs-cli configure --cluster ${cluster_name} --default-launch-type FARGATE --region ${AWS_REGION} --config-name ${config_name}
ecs-cli compose --project-name ${service_name} service up
Run Code Online (Sandbox Code Playgroud)

我在存储库上找到了一个拉取请求,ecs-cli将此标志添加到命令行(请参阅: https: //github.com/aws/amazon-ecs-cli/pull/1135),这确认它当前不可用。但这并不意味着没有其他方法来指定启用执行命令。

作为替代方法,我尝试aws ecs update-service --enable-execute-command在容器启动后使用。然而,这不起作用,因为一旦容器启动,相应的任务定义就会被标记为非活动状态。

所以我的问题是:如何在使用启动的容器中启用命令执行ecs-cli

小智 13

上述命令中的一些错误

aws ecs update-service --service $SERVICE_NAME --cluster $CLUSTER \
  --region eu-west-1 \
  --enable-execute-command \
  --force-new-deployment
Run Code Online (Sandbox Code Playgroud)


And*_*sby 5

尝试强制进行新的部署,这对我来说是成功的。

aws ecs update-service <SERVICE_NAME> --cluster <CLUSTER_NAME> \
  --enable-execute-command \
  --force-new-deployment
Run Code Online (Sandbox Code Playgroud)