gam*_*mer 9 amazon-web-services amazon-ecs terraform terraform-provider-aws
我的任务定义:
resource "aws_ecs_task_definition" "datadog" {
family = "${var.environment}-datadog-agent-task"
task_role_arn = "arn:aws:iam::xxxxxxxx:role/datadog-role"
container_definitions = <<EOF
[
{
"name": "${var.environment}-${var.datadog-identifier}",
"network_mode" : "awsvpc",
"image": "datadog/agent:latest",
"portMappings": [
{
...
Run Code Online (Sandbox Code Playgroud)
我的服务定义:
resource "aws_ecs_service" "datadog" {
name = "${var.environment}-${var.datadog-identifier}-datadog-ecs-service"
cluster = "${var.cluster}"
task_definition = "${aws_ecs_task_definition.datadog.arn}"
network_configuration {
subnets = flatten(["${var.private_subnet_ids}"])
}
# This allows running one for every instance
scheduling_strategy = "DAEMON"
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误 -
InvalidParameterException: Network Configuration is not valid for the given networkMode of this task definition
Run Code Online (Sandbox Code Playgroud)
我在这里缺少什么吗?查看 Terraform 文档和 GitHub 问题,这应该可行。它与将 Datadog 作为守护进程运行有关吗?
yda*_*coR 15
如果您要定义使用该任务定义的服务,则需要将aws_ecs_task_definition
'network_mode
设置为。awsvpc
network_configuration
资源参数的文档network_configuration
aws_ecs_service
中提到了这一点:
network_configuration
- (可选)服务的网络配置。对于使用awsvpc
网络模式接收其自己的弹性网络接口的任务定义来说,此参数是必需的,并且其他网络模式不支持此参数。
在您的情况下,您已将network_mode
参数添加到容器定义而不是任务定义中(任务是 n 个容器的集合,并分组在一起以共享一些资源)。容器定义架构不允许使用network_mode
参数。
归档时间: |
|
查看次数: |
10223 次 |
最近记录: |