Skip to content

Commit

Permalink
feat: add ecs task node
Browse files Browse the repository at this point in the history
  • Loading branch information
tsypuk committed Jan 7, 2024
1 parent a8651dc commit 2849514
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/docs/aws-components/ecs_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="vertex:ecs_service:arn:aws:ecs:us-west-1:123456789012:service/fargate-cluster/service-fg-svc" value="&lt;b&gt;Name&lt;/b&gt;: Nginx_Container&lt;BR&gt;&lt;b&gt;ARN&lt;/b&gt;: arn:aws:ecs:us-west-1:123456789012:service/fargate-cluster/service-fg-svc&lt;BR&gt;-----------&lt;BR&gt;&lt;b&gt;serviceName&lt;/b&gt;: service-fg-svc&lt;BR&gt;&lt;b&gt;clusterArn&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:cluster/rules-dev-fargate-cluster&lt;BR&gt;&lt;b&gt;serviceRegistries&lt;/b&gt;: arn:aws:servicediscovery:eu-west-1:123456789012:service/srv-t&lt;BR&gt;&lt;b&gt;status&lt;/b&gt;: ACTIVE&lt;BR&gt;&lt;b&gt;desiredCount&lt;/b&gt;: 1&lt;BR&gt;&lt;b&gt;runningCount&lt;/b&gt;: 1&lt;BR&gt;&lt;b&gt;pendingCount&lt;/b&gt;: 0&lt;BR&gt;&lt;b&gt;launchType&lt;/b&gt;: FARGATE&lt;BR&gt;&lt;b&gt;platformVersion&lt;/b&gt;: LATEST&lt;BR&gt;&lt;b&gt;platformFamily&lt;/b&gt;: Linux&lt;BR&gt;&lt;b&gt;taskDefinition&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:task-definition/service-fg-task:15" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#D45B07;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.ecs_service;" parent="1" vertex="1">
<mxCell id="vertex:ecs_service:arn:aws:ecs:us-west-1:123456789012:service/fargate-cluster/service-fg-svc" value="&lt;b&gt;Name&lt;/b&gt;: Nginx_Service&lt;BR&gt;&lt;b&gt;ARN&lt;/b&gt;: arn:aws:ecs:us-west-1:123456789012:service/fargate-cluster/service-fg-svc&lt;BR&gt;-----------&lt;BR&gt;&lt;b&gt;serviceName&lt;/b&gt;: service-fg-svc&lt;BR&gt;&lt;b&gt;clusterArn&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:cluster/rules-dev-fargate-cluster&lt;BR&gt;&lt;b&gt;serviceRegistries&lt;/b&gt;: arn:aws:servicediscovery:eu-west-1:123456789012:service/srv-t&lt;BR&gt;&lt;b&gt;status&lt;/b&gt;: ACTIVE&lt;BR&gt;&lt;b&gt;desiredCount&lt;/b&gt;: 1&lt;BR&gt;&lt;b&gt;runningCount&lt;/b&gt;: 1&lt;BR&gt;&lt;b&gt;pendingCount&lt;/b&gt;: 0&lt;BR&gt;&lt;b&gt;launchType&lt;/b&gt;: FARGATE&lt;BR&gt;&lt;b&gt;platformVersion&lt;/b&gt;: LATEST&lt;BR&gt;&lt;b&gt;platformFamily&lt;/b&gt;: Linux&lt;BR&gt;&lt;b&gt;taskDefinition&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:task-definition/service-fg-task:15" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#D45B07;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.ecs_service;" parent="1" vertex="1">
<mxGeometry width="39" height="48" as="geometry"/>
</mxCell>
</root>
Expand Down
99 changes: 99 additions & 0 deletions docs/docs/aws-components/ecs_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
layout: default
title: ECS Task
parent: AWS Components
nav_order: 3
date: 2024-01-07
---

# ECS Task
{: .d-inline-block .no_toc }

New (v0.3.19)
{: .label .label-green }

## Table of contents
{: .no_toc .text-delta }

1. TOC
{:toc}

---


## Node Type: ``ecs_task``

## Rendering:

![lambda](output/jpg/ecs_task.jpg)

## Code Snippet:

```python
{% root_include_snippet ../tests/aws/test_ecs_task.py %}
```

## drawio ecs_task vertex:

```xml
<mxCell id="vertex:ecs_task:arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94" parent="1" vertex="1">
<mxGeometry width="37" height="48" as="geometry"/>
</mxCell>
```
---

## Advanced for Geeks:

### Style:
```html
style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#D45B07;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.ecs_task;"
```

| attribute | value |
|:----------|:------|
|align| left |
|aspect| fixed |
|dashed| 0 |
|fillColor| #D45B07 |
|fontColor| #232F3E |
|fontSize| 12 |
|fontStyle| 0 |
|gradientColor| none |
|html| 1 |
|outlineConnect| 0 |
|pointerEvents| 1 |
|shape| mxgraph.aws4.ecs_task |
|sketch| 0 |
|strokeColor| none |
|verticalAlign| top |
|verticalLabelPosition| bottom |

### Vertex size:

| attribute | value |
|:---------|:-----------|
| width | 37 |
| height |48|

### Full XML dump:
```xml
<mxfile host="multicloud-diagrams" agent="PIP package multicloud-diagrams. Generate resources in draw.io compatible format for Cloud infrastructure. Copyrights @ Roman Tsypuk 2023. MIT license." type="MultiCloud">
<diagram id="diagram_1" name="AWS components">
<mxGraphModel dx="1015" dy="661" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="1">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="vertex:ecs_task:arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94" value="&lt;b&gt;Name&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94&lt;BR&gt;&lt;b&gt;ARN&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94&lt;BR&gt;-----------&lt;BR&gt;&lt;b&gt;ecs.cpu-architecture&lt;/b&gt;: x86_64&lt;BR&gt;&lt;b&gt;availabilityZone&lt;/b&gt;: eu-west-1a&lt;BR&gt;&lt;b&gt;connectivity&lt;/b&gt;: CONNECTED&lt;BR&gt;&lt;b&gt;cpu&lt;/b&gt;: 512&lt;BR&gt;&lt;b&gt;memory&lt;/b&gt;: 2048&lt;BR&gt;&lt;b&gt;platformVersion&lt;/b&gt;: 1.4.0&lt;BR&gt;&lt;b&gt;platformFamily&lt;/b&gt;: Linux&lt;BR&gt;&lt;b&gt;version&lt;/b&gt;: 5&lt;BR&gt;&lt;b&gt;ephemeralStorage_sizeInGiB&lt;/b&gt;: 20" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#D45B07;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.ecs_task;" parent="1" vertex="1">
<mxGeometry width="37" height="48" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
```

### drawio file:

Download generated ``ecs_task.drawio``:

[Download](output/drawio/ecs_task.drawio){: .btn .btn-purple }
2 changes: 1 addition & 1 deletion docs/docs/aws-components/output/drawio/ecs_service.drawio
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="vertex:ecs_service:arn:aws:ecs:us-west-1:123456789012:service/fargate-cluster/service-fg-svc" value="&lt;b&gt;Name&lt;/b&gt;: Nginx_Container&lt;BR&gt;&lt;b&gt;ARN&lt;/b&gt;: arn:aws:ecs:us-west-1:123456789012:service/fargate-cluster/service-fg-svc&lt;BR&gt;-----------&lt;BR&gt;&lt;b&gt;serviceName&lt;/b&gt;: service-fg-svc&lt;BR&gt;&lt;b&gt;clusterArn&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:cluster/rules-dev-fargate-cluster&lt;BR&gt;&lt;b&gt;serviceRegistries&lt;/b&gt;: arn:aws:servicediscovery:eu-west-1:123456789012:service/srv-t&lt;BR&gt;&lt;b&gt;status&lt;/b&gt;: ACTIVE&lt;BR&gt;&lt;b&gt;desiredCount&lt;/b&gt;: 1&lt;BR&gt;&lt;b&gt;runningCount&lt;/b&gt;: 1&lt;BR&gt;&lt;b&gt;pendingCount&lt;/b&gt;: 0&lt;BR&gt;&lt;b&gt;launchType&lt;/b&gt;: FARGATE&lt;BR&gt;&lt;b&gt;platformVersion&lt;/b&gt;: LATEST&lt;BR&gt;&lt;b&gt;platformFamily&lt;/b&gt;: Linux&lt;BR&gt;&lt;b&gt;taskDefinition&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:task-definition/service-fg-task:15" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#D45B07;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.ecs_service;" parent="1" vertex="1">
<mxCell id="vertex:ecs_service:arn:aws:ecs:us-west-1:123456789012:service/fargate-cluster/service-fg-svc" value="&lt;b&gt;Name&lt;/b&gt;: Nginx_Service&lt;BR&gt;&lt;b&gt;ARN&lt;/b&gt;: arn:aws:ecs:us-west-1:123456789012:service/fargate-cluster/service-fg-svc&lt;BR&gt;-----------&lt;BR&gt;&lt;b&gt;serviceName&lt;/b&gt;: service-fg-svc&lt;BR&gt;&lt;b&gt;clusterArn&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:cluster/rules-dev-fargate-cluster&lt;BR&gt;&lt;b&gt;serviceRegistries&lt;/b&gt;: arn:aws:servicediscovery:eu-west-1:123456789012:service/srv-t&lt;BR&gt;&lt;b&gt;status&lt;/b&gt;: ACTIVE&lt;BR&gt;&lt;b&gt;desiredCount&lt;/b&gt;: 1&lt;BR&gt;&lt;b&gt;runningCount&lt;/b&gt;: 1&lt;BR&gt;&lt;b&gt;pendingCount&lt;/b&gt;: 0&lt;BR&gt;&lt;b&gt;launchType&lt;/b&gt;: FARGATE&lt;BR&gt;&lt;b&gt;platformVersion&lt;/b&gt;: LATEST&lt;BR&gt;&lt;b&gt;platformFamily&lt;/b&gt;: Linux&lt;BR&gt;&lt;b&gt;taskDefinition&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:task-definition/service-fg-task:15" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#D45B07;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.ecs_service;" parent="1" vertex="1">
<mxGeometry width="39" height="48" as="geometry"/>
</mxCell>
</root>
Expand Down
13 changes: 13 additions & 0 deletions docs/docs/aws-components/output/drawio/ecs_task.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<mxfile host="multicloud-diagrams" agent="PIP package multicloud-diagrams. Generate resources in draw.io compatible format for Cloud infrastructure. Copyrights @ Roman Tsypuk 2023. MIT license." type="MultiCloud">
<diagram id="diagram_1" name="AWS components">
<mxGraphModel dx="1015" dy="661" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="1">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="vertex:ecs_task:arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94" value="&lt;b&gt;Name&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94&lt;BR&gt;&lt;b&gt;ARN&lt;/b&gt;: arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94&lt;BR&gt;-----------&lt;BR&gt;&lt;b&gt;ecs.cpu-architecture&lt;/b&gt;: x86_64&lt;BR&gt;&lt;b&gt;availabilityZone&lt;/b&gt;: eu-west-1a&lt;BR&gt;&lt;b&gt;connectivity&lt;/b&gt;: CONNECTED&lt;BR&gt;&lt;b&gt;cpu&lt;/b&gt;: 512&lt;BR&gt;&lt;b&gt;memory&lt;/b&gt;: 2048&lt;BR&gt;&lt;b&gt;platformVersion&lt;/b&gt;: 1.4.0&lt;BR&gt;&lt;b&gt;platformFamily&lt;/b&gt;: Linux&lt;BR&gt;&lt;b&gt;version&lt;/b&gt;: 5&lt;BR&gt;&lt;b&gt;ephemeralStorage_sizeInGiB&lt;/b&gt;: 20" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#D45B07;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.ecs_task;" parent="1" vertex="1">
<mxGeometry width="37" height="48" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Binary file modified docs/docs/aws-components/output/jpg/ecs_service.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/aws-components/output/jpg/ecs_task.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions tests/aws/test_ecs_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from multicloud_diagrams import MultiCloudDiagrams
from utils.templating import TestRendering


class TestAWSVertexInIsolation(TestRendering):

def test_ecs_service(self):
# docs
self.node_type = 'ecs_task'

# given
mcd = MultiCloudDiagrams()

# when
ecs_task_arn = 'arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94'
ecs_task_name = 'arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94'
metadata = {
"ecs.cpu-architecture": "x86_64",
"availabilityZone": "eu-west-1a",
"connectivity": "CONNECTED",
"cpu": "512",
"memory": "2048",
"platformVersion": '1.4.0',
"platformFamily": 'Linux',
"version": 5,
"ephemeralStorage_sizeInGiB": 20,
}
mcd.add_vertex(node_id=ecs_task_arn, node_name=ecs_task_name, node_type='ecs_task', metadata=metadata)

# then
expected = {'id': 'vertex:ecs_task:arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94',
'parent': '1',
'style': 'sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#D45B07;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.ecs_task;',
'value': '<b>Name</b>: '
'arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94<BR><b>ARN</b>: '
'arn:aws:ecs:eu-west-1:123456789012:task/fargate-cluster/562320f29dbdc94<BR>-----------<BR><b>ecs.cpu-architecture</b>: '
'x86_64<BR><b>availabilityZone</b>: '
'eu-west-1a<BR><b>connectivity</b>: CONNECTED<BR><b>cpu</b>: '
'512<BR><b>memory</b>: 2048<BR><b>platformVersion</b>: '
'1.4.0<BR><b>platformFamily</b>: Linux<BR><b>version</b>: '
'5<BR><b>ephemeralStorage_sizeInGiB</b>: 20',
'vertex': '1'}
self.verify_resource(expected, mcd.mx_file, 'ecs_task', self.node_type)

# docs
self.mcd = mcd

0 comments on commit 2849514

Please sign in to comment.