Jeremy Fisher
07/23/2021, 7:34 PMTiri Georgiou
07/23/2021, 8:26 PM#!/bin/bash
echo ECS_CLUSTER=your_cluster_name >> /etc/ecs/ecs.config
^^ have you added this into your launch_template resource?Jeremy Fisher
07/23/2021, 8:27 PM// Autoscaling configs
// Launch an EC2
resource "aws_launch_configuration" "ecs_dagster_launch_config" {
name_prefix = "ecs_dagster_launch_config"
image_id = "ami-00129b193dc81bc31"
instance_type = "t2.small"
security_groups = [aws_security_group.jeremy_sg.id]
// Must be the same name as the ecs-cluster.name created
user_data = <<EOF
#!/bin/bash
echo ECS_CLUSTER=${var.ecs_dagster_cluster} >> /etc/ecs/ecs.config
EOF
// Updates require destroying orginal resource
lifecycle {
create_before_destroy = true
}
depends_on = [
<http://aws_db_instance.pg|aws_db_instance.pg>
]
}
"ecs_dagster_cluster"
Tiri Georgiou
07/23/2021, 8:29 PMresource "aws_ecs_cluster" "dagster" {
name = var.ecs_dagster_cluster
// other stuff..
}
Jeremy Fisher
07/23/2021, 8:29 PMcapacity_provider_strategy {
capacity_provider = aws_ecs_capacity_provider.dagster_cp.name
weight = 100
}
That seemed to make the "No Container Instances were found in your cluster" disappear, but now the task seems to be stuck in "provisioning"Tiri Georgiou
07/23/2021, 8:31 PMJeremy Fisher
07/23/2021, 8:31 PMTiri Georgiou
07/23/2021, 8:31 PMJeremy Fisher
07/23/2021, 8:31 PMresource "aws_ecs_cluster" "dagster" {
// Name must be the same given under ecs_dagster_launch_config.user_data
name = var.ecs_dagster_cluster
Tiri Georgiou
07/23/2021, 8:33 PMJeremy Fisher
07/23/2021, 8:35 PMaws_ecs_capacity_provider.dagster_cp
resource?Tiri Georgiou
07/23/2021, 8:36 PMJeremy Fisher
07/23/2021, 8:36 PMTiri Georgiou
07/23/2021, 8:37 PMresource "aws_autoscaling_group" "dagster_asg" {
name = "${var.infra_role}-asg-${var.infra_env}"
vpc_zone_identifier = var.subnet_private_ids
launch_template {
id = aws_launch_template.launch_template.id
version = aws_launch_template.launch_template.latest_version
}
force_delete = true
desired_capacity = var.desired_capacity
min_size = var.desired_capacity
max_size = var.desired_capacity * 2
health_check_grace_period = 60
health_check_type = "EC2"
default_cooldown = 10
// This prevents all instances running tasks from being terminated during scale-in
protect_from_scale_in = var.protect_from_scale_in
lifecycle {
create_before_destroy = true
}
tag {
key = "AmazonECSManaged"
value = ""
propagate_at_launch = true
}
}
Jeremy Fisher
07/23/2021, 8:38 PMterraform destroy && terraform apply
and try thatTiri Georgiou
07/23/2021, 8:39 PM################################################
//-------------- ECS CLUSTER ----------------//
################################################
resource "aws_ecs_cluster" "dagster" {
// Name must be the same given under ecs_dagster_launch_config.user_data
name = var.ecs_dagster_cluster
capacity_providers = [aws_ecs_capacity_provider.dagster_cp.name]
default_capacity_provider_strategy {
capacity_provider = aws_ecs_capacity_provider.dagster_cp.name
weight = 1
base = 1
}
tags = {
Name = "data-${var.infra_env}-${var.infra_role}"
Role = var.infra_role
Environment = var.infra_env
ManagedBy = "terraform"
}
}
####################################################
// ------- Autoscaling capacity provider -------- //
####################################################
resource "aws_ecs_capacity_provider" "dagster_cp" {
name = "${var.infra_role}-cp-${var.infra_env}"
auto_scaling_group_provider {
auto_scaling_group_arn = aws_autoscaling_group.dagster_asg.arn
managed_termination_protection = var.managed_termination_protection
managed_scaling {
minimum_scaling_step_size = 1
maximum_scaling_step_size = 5
instance_warmup_period = 10
status = "ENABLED"
target_capacity = var.target_capacity
}
}
tags = {
Name = "data-${var.infra_env}-${var.infra_role}"
Role = var.infra_role
Environment = var.infra_env
ManagedBy = "terraform"
}
}
Jeremy Fisher
07/23/2021, 8:40 PMTiri Georgiou
07/23/2021, 8:41 PMJeremy Fisher
07/23/2021, 8:41 PMaws_launch_configuration
resource with the aws_launch_template
one?Tiri Georgiou
07/23/2021, 9:13 PMWe recommend that you create Auto Scaling groups from launch templates to ensure that you're accessing the latest features and improvements.
Jeremy Fisher
07/23/2021, 10:15 PMtarget_capacity
or desired_capacity
variables? I have those both set to 2Tiri Georgiou
07/23/2021, 11:12 PMJeremy Fisher
07/23/2021, 11:18 PMenvironment.yml
Tiri Georgiou
07/24/2021, 11:03 AMJeremy Fisher
07/26/2021, 5:01 PMlevel=info time=2021-07-26T18:35:29Z msg="Creating root ecs cgroup: /ecs" module=init_linux.go
level=info time=2021-07-26T18:35:29Z msg="Creating cgroup /ecs" module=cgroup_controller_linux.go
level=info time=2021-07-26T18:35:29Z msg="Loading state!" module=state_manager.go
level=info time=2021-07-26T18:35:29Z msg="Event stream ContainerChange start listening..." module=eventstream.go
level=error time=2021-07-26T18:35:30Z msg="Error getting valid credentials: NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors" module=agent.go
level=info time=2021-07-26T18:35:30Z msg="Registering Instance with ECS" module=agent.go
level=info time=2021-07-26T18:35:30Z msg="Remaining mem: 1993" module=client.go
level=error time=2021-07-26T18:35:30Z msg="Unable to register as a container instance with ECS: NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors" module=client.go
aws_iam_role_policy_attachment.ecs_dagster
role attached to itiam_instance_profile {
name = aws_iam_instance_profile.ecs_dagster.name
}
PROVISIONING
curl "$container_instance_ip_address":3000
, I just get
curl: (7) Failed to connect to --.---.---.-- port 3000: Connection refused
[ec2-user@ip-10-38-31-120 ~]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b341b1b0ed16 <http://211883317150.dkr.ecr.us-east-1.amazonaws.com/ecr_dagit:latest|211883317150.dkr.ecr.us-east-1.amazonaws.com/ecr_dagit:latest> "dagster-daemon run" 40 seconds ago Exited (1) 35 seconds ago ecs-ecs_dagster_cluster-task-3-daemon-fc98e88183fcec8a2b00
6f54d42f87ee <http://211883317150.dkr.ecr.us-east-1.amazonaws.com/ecr_dagit:latest|211883317150.dkr.ecr.us-east-1.amazonaws.com/ecr_dagit:latest> "dagit -h 0.0.0.0 -p…" 40 seconds ago Exited (1) 33 seconds ago ecs-ecs_dagster_cluster-task-3-dagit-b093acb295d6c2a4ae01
658259970bf4 <http://211883317150.dkr.ecr.us-east-1.amazonaws.com/ecr_dagster_pipeline:latest|211883317150.dkr.ecr.us-east-1.amazonaws.com/ecr_dagster_pipeline:latest> "dagster api grpc -h…" 40 seconds ago Exited (137) 4 seconds ago
botocore.exceptions.NoRegionError: You must specify a region.
Tiri Georgiou
07/27/2021, 8:40 AMJeremy Fisher
07/27/2021, 1:47 PM/usr/local/lib/python3.8/site-packages/dagster/core/workspace/context.py:485: UserWarning: Error loading repository location example_pipelines:grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "DNS resolution failed for service: docker-example-pipelines:4000"
debug_error_string = "{"created":"@1627393453.385512190","description":"Resolver transient failure","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":1360,"referenced_errors":[{"created":"@1627393453.385510578","description":"DNS resolution failed for service: docker-example-pipelines:4000","file":"src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc","file_line":359,"grpc_status":14,"referenced_errors":[{"created":"@1627393453.385478570","description":"C-ares status is not ARES_SUCCESS qtype=A name=docker-example-pipelines is_balancer=0: Could not contact DNS servers","file":"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc","file_line":724}]}]}"
>
network_mode = "awsvpc"
?network_mode = "host"
and setting the workspace.yaml host to localhost
. This works!— The task bypasses Docker's built-in virtual network and maps container ports directly to the ENI of the Amazon EC2 instance hosting the task. As a result, you can't run multiple instantiations of the same task on a single Amazon EC2 instance when port mappings are used.host
Tiri Georgiou
07/28/2021, 7:35 AM