[英]Uploading file to ECS task
I'm trying to upload a simple .yml
file when creating an ECS task via Terraform, here is the code ./main.tf
:我在通过 Terraform 创建 ECS 任务时尝试上传一个简单的
.yml
文件,这里是代码./main.tf
:
resource "aws_ecs_task_definition" "grafana" {
family = "grafana"
cpu = "256"
memory = "512"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
container_definitions = jsonencode([
{
name = "grafana"
image = "grafana/grafana:latest"
portMappings = [
{
containerPort = 3000,
hostPort = 3000,
protocol = "tcp"
}
]
}
])
}
How do I go about adding ./datasource.yml
(located on my host machine) to the container within the task definition so that when the task runs it can use it? go 如何将
./datasource.yml
(位于我的主机上)添加到任务定义中的容器,以便在任务运行时可以使用它? I wasn't sure if volume { }
could be used?我不确定是否可以使用
volume { }
?
I think you have two alternatives here:我认为您在这里有两种选择:
COPY datasource.yaml /usr/share/grafana/conf/provisioning/datasource.yaml
or或者
mount_points = [ {
sourceVolume = "grafana"
containerPath = "/var/lib/grafana/conf/provisioning"
readOnly = false
}
]
volumes = [
{
name = "grafana"
host_path = "/ecs/grafana-provisioning"}
]
I wasn't sure if volume { } could be used?
我不确定是否可以使用volume {}?
As a matter of fact you can, check the docs https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#example-usage事实上,您可以查看文档https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#example-usage
volume {
name = "grafana-volume"
host_path = "./datasource.yml"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.