エラー内容
CannotPullContainerError: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
解決策
タスク実行時にPublicIPを付与する
resource "aws_cloudwatch_event_target" "example_batch" {
target_id = "example-batch"
rule = aws_cloudwatch_event_rule.example_batch.name
role_arn = module.ecs_events_role.iam_role_arn
arn = aws_ecs_cluster.example.arn
ecs_target {
launch_type = "FARGATE"
task_count = 1
platform_version = "1.3.0"
# ターゲットをarnで設定
task_definition_arn = aws_ecs_task_definition.example_batch.arn
network_configuration {
assign_public_ip = "true" ★
subnets = [aws_subnet.public_subnet_1a.id]
}
}
}
private subnetで使いたいならNATゲートウェイを使う