Skip to main content

Library to generate DRAW.IO compatible diagrams to represent Cloud infrastructure. AWS Cloud supported.

Project description

MultiCloud Diagrams

license PyPI version python version Run tests

Generate and render Diagrams-As-a-Code (DAG) in popular drawio vector format for multiple Cloud providers. This is graph not static, so you can move, edit, position nodes like you want.

Buy Me A Coffee

Supported Nodes Landscape:

landscape.png

Cloud Provides:

Supported:

aws provider on premise provider

Planned to be added:

azure provider gcp provider

Features:

  • allows to generate drawio diagram with predefined styles for popular aws services, support graph-based connection with named edges
  • supports single and batch elements append to diagram
  • duplicates detection to prevent ball of mud in file format and diagram
  • verification that both vertices present on diagram when adding edge connection between them
  • if the node is not present, fallback to default icon when rendering
  • read previous version of drawio file and reuses existing vertices coordinates when generating a new version
  • generate diagram from YAML definition
  • mix and augment Diagram-as-code, real infra crawler, static yaml-based content to diagram

Library usage samples:

1. Generating AWS DynamoDB Details drawio diagram based on library, http, awscli, etc. Example based on boto3 DynamoDB response

{
        'AttributeDefinitions': [
            {
                'AttributeName': 'first',
                'AttributeType': 'S'
            },
            {
                'AttributeName': 'second',
                'AttributeType': 'N'
            },
            {
                'AttributeName': 'third',
                'AttributeType': 'B'
            },
        ],
        'TableName': 'prod-dynamo-table',
        'KeySchema': [
            {
                'AttributeName': 'string',
                'KeyType': 'HASH'
            },
        ],
        'TableSizeBytes': 123,
        'ItemCount': 123,
        'TableArn': 'arn:aws:dynamodb:eu-west-1:123456789:table/prod-dynamo-table',
        'LocalSecondaryIndexes': [{
...       
...
...
          
          'SSEDescription': {
            'Status': 'ENABLED',
            'SSEType': 'KMS',
            'KMSMasterKeyArn': 'string',
          },
          'DeletionProtectionEnabled': True
        }

output.prod.dynamo.png

2. Diagrams as a Code. DAG. Generating AWS IAM Graph from the code based on DAG declaration:

    producer_func_arn = 'arn:aws:lambda:eu-west-1:123456789:function:producer-lambda'
metadata = {
    "CodeSize": 1234,
    "Handler": "main",
    "Layers": 0,
    "Memory": 128,
    "PackageType": "Zip",
    "Runtime": "go1.x",
    "Timeout": 30,
    "TracingConfig": "{'Mode': 'Active'}",
    "Version": "$LATEST"
}
mcd.add_vertex(node_id=producer_func_arn, node_name='producer-lambda', arn=producer_func_arn, node_type='lambda_function', metadata=metadata)

consumer_func_arn = 'arn:aws:lambda:eu-west-1:123456789:function:consumer-lambda'
mcd.add_vertex(node_id=consumer_func_arn, node_name='consumer-lambda', arn=consumer_func_arn, node_type='lambda_function')

dynamo_arn = 'arn:aws:dynamodb:eu-west-1:123456789:table/table1'
mcd.add_vertex(node_id=dynamo_arn, node_name='table1', arn=dynamo_arn, node_type='dynamo')

sns_arn = 'arn:aws:sns:eu-west-1:123456789:internal.fifo'
metadata = {
    "Owner": 123456789,
    "SubscriptionsConfirmed": 3,
    "SubscriptionsPending": 0
}
mcd.add_vertex(node_id=sns_arn, node_name='internal', arn=sns_arn, node_type='sns', metadata=metadata)

sqs_arn = 'arn:aws:sqs:eu-west-1:123456789:int-eu-live-events.fifo'
metadata = {
    "DelaySeconds": 0,
    "FifoQueue": "TRUE",
    "ReceiveMessageWaitTimeSeconds": 0,
    "SqsManagedSseEnabled": "false",
    "VisibilityTimeout": 30
}
mcd.add_vertex(node_id=sqs_arn, node_name='events', arn=sqs_arn, node_type='sqs', metadata=metadata)

sqs_arn2 = 'arn:aws:sqs:eu-west-1:123456789:int-eu-live-events2.fifo'
mcd.add_vertex(node_id=sqs_arn2, node_name='events2', arn=sqs_arn2, node_type='sqs')

s3_arn = 'arn:aws:s3:::bucket_name/key_name'
mcd.add_vertex(node_id=s3_arn, node_name='key_name', arn=s3_arn, node_type='s3')

mcd.add_link(src_node_id=f'lambda_function:{producer_func_arn}', dst_node_id=f'sns:{sns_arn}')
mcd.add_link(src_node_id=f'lambda_function:{producer_func_arn}', dst_node_id=f's3:{s3_arn}')
mcd.add_link(src_node_id=f'sns:{sns_arn}', dst_node_id=f'sqs:{sqs_arn}')
mcd.add_link(src_node_id=f'sns:{sns_arn}', dst_node_id=f'sqs:{sqs_arn2}')
mcd.add_link(src_node_id=f'sqs:{sqs_arn}', dst_node_id=f'lambda_function:{consumer_func_arn}')
mcd.add_link(src_node_id=f'lambda_function:{consumer_func_arn}', dst_node_id=f'dynamo:{dynamo_arn}')

output.prod.iam-roles.png

3. Generating Diagram from YAML source

vertices:
  - name: prod-lambda-name
    type: lambda_function
    arn: arn:aws:lambda:eu-west-1:123456789:function:prod-lambda-name
  - name: role-lambda-name
    type: iam_role
    arn: arn:aws:iam::123456789:role/prod-lambda-name
  - name: prod-cloudwatch-policy
    icon: broker
    type: iam_policy
    arn: arn:aws:iam::123456789:policy/prod-cloudwatch-policy
  - name: prod-s3-policy
    type: iam_policy
    arn: arn:aws:iam::123456789:policy/prod-s3-policy
  - name: prod-dynamodb-policy
    type: iam_policy
    arn: arn:aws:iam::123456789:policy/prod-dynamo-policy
edges:
#  1st approach src/dst are linked to yaml vertices by name
  - { src: prod-lambda-name, dst: role-lambda-name, label: HasRole, link_type: none }
  - { src: role-lambda-name, dst: prod-cloudwatch-policy, label: Allow CloudWatch logs, link_type: none }
#  2nd approach src/dst are linked by ARN (ARN can be present in same yaml, or loaded programmatically)
  - {
    src_arn: arn:aws:iam::123456789:role/prod-lambda-name,
    src_type: iam_role,
    dst_arn: arn:aws:iam::123456789:policy/prod-s3-policy,
    dst_type: iam_policy,
    label: Allow S3 access,
    link_type: none }
# 3rd approach is mixed of 1st and 2nd
  - {
    src_arn: arn:aws:iam::123456789:role/prod-lambda-name,
    src_type: iam_role,
    dst: prod-dynamodb-policy,
    label: Allow DynamoDB read access,
    link_type: none }

Publishing

poetry build
export PYPI_USERNAME=
export PYPI_PASSWORD=
poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD

cd samples/samples
poetry install
poetry run python aws_iam_roles_from_code_with_enum.py
poetry run flakehell plugins
NAME        | VERSION  | CODES            | RULES
mccabe      | 0.6.1    | C90              | +*
pycodestyle | 2.7.0    | E, W             | +*, -E501
pyflakes    | 2.3.1    | F                | +*
pylint      | 0.0.0    | C, E, F, I, R, W | +*

poetry run flakehell lint
poetry run git-changelog -c angular -s docs,feat,test --output CHANGELOG.MD
git push --tags

Contribution Guide:

OpenSource Guide, How to contribute to opensource

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multicloud_diagrams-0.3.11.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

multicloud_diagrams-0.3.11-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file multicloud_diagrams-0.3.11.tar.gz.

File metadata

  • Download URL: multicloud_diagrams-0.3.11.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-1042-azure

File hashes

Hashes for multicloud_diagrams-0.3.11.tar.gz
Algorithm Hash digest
SHA256 c26f48f1a41079952e4897d23c1ea4e65d3a793d0a654e9e0c8869e4be1e66f9
MD5 272fc4e45d2d9e21812b7de967352911
BLAKE2b-256 ab33000a552a3df4df60e00596c42f58e51feb02df1d61b52c0ffd750a198421

See more details on using hashes here.

File details

Details for the file multicloud_diagrams-0.3.11-py3-none-any.whl.

File metadata

File hashes

Hashes for multicloud_diagrams-0.3.11-py3-none-any.whl
Algorithm Hash digest
SHA256 2a1cfa6bae6a52d34a61f065d22b26e2cf0bb0a72992fe05045756d7e1b4f6e3
MD5 8ee3b030027478fc1381e063f71dae29
BLAKE2b-256 fd446eba51afb29e346523564972a42d5236a3fca6cb9a9f6326f486c88d9cee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page