我如何通过Terraform在ECS计划任务上设置命令覆盖?

huangapple go评论50阅读模式
英文:

How can I set the command override on an ECS scheduled task via Terraform?

问题

我正在使用这个模块 - https://registry.terraform.io/modules/cn-terraform/ecs-fargate-scheduled-task/aws/latest

我已经成功创建了计划任务,除了容器中的命令覆盖部分。

我不能在任务定义级别设置命令覆盖,因为多个计划任务实现了相同的任务定义,所以命令覆盖需要在计划任务级别执行,因为每个计划任务都是独特的。

在模块的文档中我没有找到任何有关此的帮助,所以我在想是否有其他方式可以做到这一点,比如在创建后查询计划任务并使用不同的模块来设置命令覆盖?

英文:

I'm using this module - https://registry.terraform.io/modules/cn-terraform/ecs-fargate-scheduled-task/aws/latest

I've managed to build the scheduled task with everything except the command override on the container

I cannot set the command override at the task definition level because multiple scheduled tasks implement the same task definition so the command override needs to happen at the scheduled task level as it's unique per scheduled task

I don't see anything that helps in the modules documentation so i'm wondering if there is another way I could do this by either querying for the scheduled task once it's created and using a different module to set the command override?

答案1

得分: 1

以下是翻译好的部分:

如果您查看Terraform文档中的aws_cloudwatch_event_target,您会看到有一个用于ECS计划任务的命令覆盖的示例。请注意,他们通过input参数将覆盖传递给事件目标。

现在,如果您查看您正在使用的模块的源代码,您将看到他们将event_target_input变量中设置的任何内容传递给aws_cloudwatch_event_target资源的input参数。

因此,您需要将覆盖作为JSON字符串传递(我建议复制Terraform文档中的示例JSON字符串,然后根据您的需求进行修改),并将其放在您的模块声明中的event_target_input中。

英文:

If you look at the Terraform documentation for aws_cloudwatch_event_target, there is an example in there for an ECS scheduled task with command override. Notice how they are passing the override via the input parameter to the event target.

Now if you look at the source code for the module you are using, you will see they are passing anything you set in the event_target_input variable to the input parameter of the aws_cloudwatch_event_target resource.

So you need to pass the override as a JSON string (I would copy the example JSON string in the Terraform docs and then modify it to your needs) as event_target_input in your module declaration.

huangapple
  • 本文由 发表于 2023年2月14日 22:39:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75449397.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定