Created: 2023-10-24 | Updated: 2024-05-17

Elastic Compute Cloud

New (v0.3.17)

Table of contents

  1. Node Type: ec2
  2. Rendering:
  3. Code Snippet:
  4. drawio ec2 vertex:
  5. Advanced for Geeks:
    1. Style:
    2. Vertex size:
    3. Full XML dump:
    4. drawio file:

Node Type: ec2

Rendering:

lambda

Code Snippet:

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

drawio ec2 vertex:

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

Advanced for Geeks:

Style:

style="sketch=0;outlineConnect=0;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;"
attributevalue
alignleft
aspectfixed
dashed0
fillColor#D05C17
fontSize12
fontStyle0
gradientColor#F78E04
gradientDirectionnorth
html1
outlineConnect0
resIconmxgraph.aws4.ec2
shapemxgraph.aws4.resourceIcon
sketch0
strokeColor#ffffff
verticalAligntop
verticalLabelPositionbottom

Vertex size:

attributevalue
width78
height78

Full XML dump:

<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;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