# ECS

### Creating a task and associated service with minimal parameters

```
resources:
  - type: aws_ecs_task_definition
    name: my-task
    props:
      family: my-task-family
      cpu: "1024"
      memory: "2048"
      network_mode: awsvpc
      requires_compatibilities:
        - FARGATE
      container_definitions:
        - name: my-container
          image: nginx:latest
          port_mappings:
            - container_port: 80
              protocol: tcp
  - type: aws_ecs_service
    name: my-service
    props:
      cluster: my-existing-cluster
      task_definition: "ref:my-task"
      desired_count: 1
      launch_type: FARGATE
      network_configuration:
        awsvpc_configuration:
          subnets:
            - subnet-12345678
          security_groups:
            - sg-12345678
          assign_public_ip: ENABLED
```

#### Example price for above configuration

```
my-task (action: create)
my-service (action: create)
=> Price (vCPU cost (1.0 vCPU, x86_64, Linux) - price: $0.04048/Hrs, monthly: $30.12)
=> Price (Memory cost (2.0 GB, x86_64, Linux) - price: $0.00445/Hrs, monthly: $3.31)
```
