Tiri Georgiou
05/21/2021, 1:06 PMpending
and doesn't actually run. I suppose I could share my ecs task definition
if it helps, but I was wondering if anyone could point me towards some resources on deploying to ECS? (happy to share more info on this)jordan
05/21/2021, 1:32 PMTiri Georgiou
05/21/2021, 1:40 PMresource "aws_ecs_task_definition" "dagster_task" {
family = var.ecs_dagster_cluster
execution_role_arn = aws_iam_role.ecs_dagster.arn
task_role_arn = aws_iam_role.ecs_dagster.arn // task to have permissions
network_mode = "bridge"
container_definitions = jsonencode([
{
name = "dagit"
image = "${data.aws_ecr_repository.daemon_dagit.repository_url}:latest"
cpu = 250
memory = 256
essential = false
hostname = "docker-dagit"
portMappings = [
{
protocol = "tcp"
containerPort = 3000
hostPort = 3000
}
]
environment = [
{
name = "DAGSTER_HOSTNAME"
value = aws_db_instance.pg.address
},
{
name = "DAGSTER_POSTGRES_USER"
value = "pod"
},
{
name = "DAGSTER_POSTGRES_PASSWORD"
value = local.secret
},
{
name = "DAGSTER_POSTGRES_DB"
value = "podpoint"
}
]
entryPoint = ["sh", "-c", "dagit", "-h", "0.0.0.0", "-p", "3000", "-w", "workspace.yaml"]
mount_points = [
{
containerPath = "/var/run/docker.sock"
sourceVolume = "docker_sock"
readOnly = true
}
]
},
{
name = "daemon"
image = "${data.aws_ecr_repository.daemon_dagit.repository_url}:latest"
cpu = 250
memory = 256
essential = false
hostname = "docker-daemon"
environment = [
{
name = "DAGSTER_HOSTNAME"
value = aws_db_instance.pg.address
},
{
name = "DAGSTER_POSTGRES_USER"
value = "pod"
},
{
name = "DAGSTER_POSTGRES_PASSWORD"
value = local.secret // secret value defined in <http://postgres.tf|postgres.tf>
},
{
name = "DAGSTER_POSTGRES_DB"
value = "podpoint"
}
]
entryPoint = ["sh", "-c", "dagster-daemon", "run"]
mount_points = [
{
containerPath = "/var/run/docker.sock"
sourceVolume = "docker_sock"
readOnly = true
}
]
},
{
name = "uptime"
image = "${data.aws_ecr_repository.uptime.repository_url}:latest"
cpu = 250
memory = 256
essential = true
hostname = "docker-uptime" // Same name in workspace.yml
environment = [
{
name = "DAGSTER_HOSTNAME"
value = aws_db_instance.pg.address
},
{
name = "DAGSTER_POSTGRES_USER"
value = "pod"
},
{
name = "DAGSTER_POSTGRES_PASSWORD"
value = local.secret
},
{
name = "DAGSTER_POSTGRES_DB"
value = "podpoint"
},
{
name = "DAGSTER_CURRENT_IMAGE"
value = "${data.aws_ecr_repository.uptime.repository_url}:latest"
}
]
entryPoint = ["dagster", "api", "grpc", "-h", "0.0.0.0", "-p", "4000", "-f", "uptime_dags/repository.py"]
}
])
t2.small
uptime
container isn't needed because there is a CMD in the image with the same execution. I just did wrote it there as an experiment.jordan
05/21/2021, 1:53 PMTiri Georgiou
05/21/2021, 3:10 PMjordan
05/21/2021, 3:21 PMTiri Georgiou
05/21/2021, 3:22 PMjordan
05/21/2021, 3:22 PMTiri Georgiou
05/21/2021, 3:23 PMdata "aws_iam_policy_document" "assume_role_policy_dagster" {
statement {
sid = "3"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
// <http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com> gives cluster permission to run tasks
identifiers = ["<http://ec2.amazonaws.com|ec2.amazonaws.com>", "<http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com>"]
}
}
}
^^ with ecs-tasksjordan
05/21/2021, 3:49 PMresource.aws_ecs_task_definition.dagster_task.execution_role_arn
, I used a role that has the AWS managed AmazonECSTaskExecutionRolePolicy
attached to it. I see you’re using a different managed policy - perhaps that’s related?Tiri Georgiou
05/21/2021, 3:53 PM// ---- ECS SERVICES ----
resource "aws_ecs_service" "dagster" {
name = var.ecs_dagster_cluster
cluster = aws_ecs_cluster.dagster.id
task_definition = aws_ecs_task_definition.dagster_task.arn
iam_role = aws_iam_role.ecs_dagster.arn // <<--- HERE? DIDNT ADD THIS?
desired_count = 1
depends_on = [
<http://aws_db_instance.pg|aws_db_instance.pg>
]
capacity_provider_strategy {
capacity_provider = aws_ecs_capacity_provider.dagster_cp.name
weight = 100
}
}
^^ maybe this?jordan
05/21/2021, 4:01 PMTiri Georgiou
05/21/2021, 4:02 PMjordan
05/21/2021, 7:13 PMTiri Georgiou
05/24/2021, 8:48 AMworkspace.yaml
?env
variable like you can in dagster.yaml i.e.
load_from:
- grpc_server:
host:
env: HOSTNAME
port: 4000
location_name: "server_uptime"
?daniel
05/24/2021, 2:28 PM