# 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)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mechcloud.io/cloud-computing/stateless-iac/aws/examples-resources-with-cost/ecs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
