Skip to content

Commit

Permalink
docs: add EC2 instance
Browse files Browse the repository at this point in the history
  • Loading branch information
tsypuk committed Oct 24, 2023
1 parent 7c1dd85 commit ee72646
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 0 deletions.
100 changes: 100 additions & 0 deletions docs/docs/aws-components/ec2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
layout: default
title: Elastic Compute Cloud
parent: AWS Components
nav_order: 3
date: 2023-10-24
---

# Elastic Compute Cloud
{: .d-inline-block .no_toc }

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

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

1. TOC
{:toc}

---


## Node Type: ``ec2``

## Rendering:

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

## Code Snippet:

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

## drawio ec2 vertex:

```xml
<mxCell id="vertex:ec2:arn:i-1234567890abcdef0" parent="1" vertex="1">
<mxGeometry width="78" height="78" as="geometry"/>
</mxCell>
```
---

## Advanced for Geeks:

### Style:
```html
style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=#F78E04;gradientDirection=north;fillColor=#D05C17;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.ec2;"
```

| attribute | value |
|:----------|:------|
|align| left |
|aspect| fixed |
|dashed| 0 |
|fillColor| #D05C17 |
|fontColor| #232F3E |
|fontSize| 12 |
|fontStyle| 0 |
|gradientColor| #F78E04 |
|gradientDirection| north |
|html| 1 |
|outlineConnect| 0 |
|resIcon| mxgraph.aws4.ec2 |
|shape| mxgraph.aws4.resourceIcon |
|sketch| 0 |
|strokeColor| #ffffff |
|verticalAlign| top |
|verticalLabelPosition| bottom |

### Vertex size:

| attribute | value |
|:---------|:-----------|
| width | 78 |
| height |78|

### 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:ec2:arn:i-1234567890abcdef0" value="&lt;b&gt;Name&lt;/b&gt;: Test Instance&lt;BR&gt;&lt;b&gt;ARN&lt;/b&gt;: arn:i-1234567890abcdef0&lt;BR&gt;-----------&lt;BR&gt;&lt;b&gt;AmiLaunchIndex&lt;/b&gt;: 0&lt;BR&gt;&lt;b&gt;ImageId&lt;/b&gt;: ami-0abcdef1234567890&lt;BR&gt;&lt;b&gt;InstanceId&lt;/b&gt;: i-1234567890abcdef0&lt;BR&gt;&lt;b&gt;InstanceType&lt;/b&gt;: t3.nano&lt;BR&gt;&lt;b&gt;KeyName&lt;/b&gt;: my-key-pair&lt;BR&gt;&lt;b&gt;LaunchTime&lt;/b&gt;: 2022-11-15T10:48:59+00:00&lt;BR&gt;&lt;b&gt;Monitoring&lt;/b&gt;: {'State': 'disabled'}&lt;BR&gt;&lt;b&gt;Placement&lt;/b&gt;: {'AvailabilityZone': 'us-east-2a', 'GroupName': '', 'Tenancy': 'default'}&lt;BR&gt;&lt;b&gt;PrivateDnsName&lt;/b&gt;: ip-10-0-0-157.us-east-2.compute.internal&lt;BR&gt;&lt;b&gt;PrivateIpAddress&lt;/b&gt;: 10-0-0-157&lt;BR&gt;&lt;b&gt;ProductCodes&lt;/b&gt;: []&lt;BR&gt;&lt;b&gt;PublicDnsName&lt;/b&gt;: ec2-34-253-223-13.us-east-2.compute.amazonaws.com&lt;BR&gt;&lt;b&gt;PublicIpAddress&lt;/b&gt;: 34.253.223.13&lt;BR&gt;&lt;b&gt;SubnetId&lt;/b&gt;: subnet-04a636d18e83cfacb&lt;BR&gt;&lt;b&gt;VpcId&lt;/b&gt;: vpc-1234567890abcdef0&lt;BR&gt;&lt;b&gt;Architecture&lt;/b&gt;: x86_64&lt;BR&gt;&lt;b&gt;Hypervisor&lt;/b&gt;: xen" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=#F78E04;gradientDirection=north;fillColor=#D05C17;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.ec2;" parent="1" vertex="1">
<mxGeometry width="78" height="78" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
```

### drawio file:

Download generated ``ec2.drawio``:

[Download](output/drawio/ec2.drawio){: .btn .btn-purple }
13 changes: 13 additions & 0 deletions docs/docs/aws-components/output/drawio/ec2.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:ec2:arn:i-1234567890abcdef0" value="&lt;b&gt;Name&lt;/b&gt;: Test Instance&lt;BR&gt;&lt;b&gt;ARN&lt;/b&gt;: arn:i-1234567890abcdef0&lt;BR&gt;-----------&lt;BR&gt;&lt;b&gt;AmiLaunchIndex&lt;/b&gt;: 0&lt;BR&gt;&lt;b&gt;ImageId&lt;/b&gt;: ami-0abcdef1234567890&lt;BR&gt;&lt;b&gt;InstanceId&lt;/b&gt;: i-1234567890abcdef0&lt;BR&gt;&lt;b&gt;InstanceType&lt;/b&gt;: t3.nano&lt;BR&gt;&lt;b&gt;KeyName&lt;/b&gt;: my-key-pair&lt;BR&gt;&lt;b&gt;LaunchTime&lt;/b&gt;: 2022-11-15T10:48:59+00:00&lt;BR&gt;&lt;b&gt;Monitoring&lt;/b&gt;: {'State': 'disabled'}&lt;BR&gt;&lt;b&gt;Placement&lt;/b&gt;: {'AvailabilityZone': 'us-east-2a', 'GroupName': '', 'Tenancy': 'default'}&lt;BR&gt;&lt;b&gt;PrivateDnsName&lt;/b&gt;: ip-10-0-0-157.us-east-2.compute.internal&lt;BR&gt;&lt;b&gt;PrivateIpAddress&lt;/b&gt;: 10-0-0-157&lt;BR&gt;&lt;b&gt;ProductCodes&lt;/b&gt;: []&lt;BR&gt;&lt;b&gt;PublicDnsName&lt;/b&gt;: ec2-34-253-223-13.us-east-2.compute.amazonaws.com&lt;BR&gt;&lt;b&gt;PublicIpAddress&lt;/b&gt;: 34.253.223.13&lt;BR&gt;&lt;b&gt;SubnetId&lt;/b&gt;: subnet-04a636d18e83cfacb&lt;BR&gt;&lt;b&gt;VpcId&lt;/b&gt;: vpc-1234567890abcdef0&lt;BR&gt;&lt;b&gt;Architecture&lt;/b&gt;: x86_64&lt;BR&gt;&lt;b&gt;Hypervisor&lt;/b&gt;: xen" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=#F78E04;gradientDirection=north;fillColor=#D05C17;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.ec2;" parent="1" vertex="1">
<mxGeometry width="78" height="78" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Binary file added docs/docs/aws-components/output/jpg/ec2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions multicloud_diagrams/providers/aws.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,12 @@
"height": "78",
"version": "0.3.17",
"desc": "Elastic Container Service"
},
"ec2": {
"style": "sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=#F78E04;gradientDirection=north;fillColor=#D05C17;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.ec2;",
"width": "78",
"height": "78",
"version": "0.3.17",
"desc": "Elastic Compute Cloud"
}
}
67 changes: 67 additions & 0 deletions tests/aws/test_ec2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from multicloud_diagrams import MultiCloudDiagrams
from utils.templating import TestRendering


class TestAWSVertexInIsolation(TestRendering):

def test_ec2(self):
# docs
self.node_type = 'ec2'

# given
mcd = MultiCloudDiagrams()

# when
ec2_arn = 'arn:i-1234567890abcdef0'
ec2_name = 'Test Instance'
metadata = {
"AmiLaunchIndex": 0,
"ImageId": "ami-0abcdef1234567890",
"InstanceId": "i-1234567890abcdef0",
"InstanceType": "t3.nano",
"KeyName": "my-key-pair",
"LaunchTime": "2022-11-15T10:48:59+00:00",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "us-east-2a",
"GroupName": "",
"Tenancy": "default"
},
"PrivateDnsName": "ip-10-0-0-157.us-east-2.compute.internal",
"PrivateIpAddress": "10-0-0-157",
"ProductCodes": [],
"PublicDnsName": "ec2-34-253-223-13.us-east-2.compute.amazonaws.com",
"PublicIpAddress": "34.253.223.13",
"SubnetId": "subnet-04a636d18e83cfacb",
"VpcId": "vpc-1234567890abcdef0",
"Architecture": "x86_64",
"Hypervisor": "xen"
}
mcd.add_vertex(node_id=ec2_arn, node_name=ec2_name, node_type='ec2', metadata=metadata)

# then
expected = {'id': 'vertex:ec2:arn:i-1234567890abcdef0',
'parent': '1',
'style': 'sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=#F78E04;gradientDirection=north;fillColor=#D05C17;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.ec2;',
'value': '<b>Name</b>: Test Instance<BR><b>ARN</b>: '
'arn:i-1234567890abcdef0<BR>-----------<BR><b>AmiLaunchIndex</b>: '
'0<BR><b>ImageId</b>: ami-0abcdef1234567890<BR><b>InstanceId</b>: '
'i-1234567890abcdef0<BR><b>InstanceType</b>: '
't3.nano<BR><b>KeyName</b>: my-key-pair<BR><b>LaunchTime</b>: '
"2022-11-15T10:48:59+00:00<BR><b>Monitoring</b>: {'State': "
"'disabled'}<BR><b>Placement</b>: {'AvailabilityZone': 'us-east-2a', "
"'GroupName': '', 'Tenancy': 'default'}<BR><b>PrivateDnsName</b>: "
'ip-10-0-0-157.us-east-2.compute.internal<BR><b>PrivateIpAddress</b>: '
'10-0-0-157<BR><b>ProductCodes</b>: []<BR><b>PublicDnsName</b>: '
'ec2-34-253-223-13.us-east-2.compute.amazonaws.com<BR><b>PublicIpAddress</b>: '
'34.253.223.13<BR><b>SubnetId</b>: '
'subnet-04a636d18e83cfacb<BR><b>VpcId</b>: '
'vpc-1234567890abcdef0<BR><b>Architecture</b>: '
'x86_64<BR><b>Hypervisor</b>: xen',
'vertex': '1'}
self.verify_resource(expected, mcd.mx_file, 'Client Certificate', self.node_type)

# docs
self.mcd = mcd

0 comments on commit ee72646

Please sign in to comment.