I’m trying to upload a simple .yml
file when creating an ECS task via Terraform, here is the code ./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? I wasn’t sure if volume { }
could be used?
2
Answers
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
I think you have two alternatives here:
COPY datasource.yaml /usr/share/grafana/conf/provisioning/datasource.yaml
or