> For the complete documentation index, see [llms.txt](https://docs.mechcloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mechcloud.io/cloud-computing/stateless-iac/aws/examples-resources-with-cost/ecs.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
