Skip to main content

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

Project description

MultiCloud Diagrams is a package for generating and rendering Diagrams-As-a-Code (DAG) in popular drawio format for different Cloud providers.

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

Supported AWS services:

  • lambda_function
  • sqs
  • sns
  • iam_role/iam_policy/iam_permission
  • dynamo/dynamo_stream
  • api_gw
  • s3
  • kms
  • ssm

Library can be used with different approaches and even mix all of them. Samples and usage:

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:

    func_arn = 'arn:aws:lambda:eu-west-1:123456789:function:prod-lambda-name'
    mcd.add_vertex(id=func_arn, node_name='prod-lambda-name', arn=func_arn, node_type='lambda_function')
    
    role_arn = 'arn:aws:iam::123456789:role/prod-lambda-name'
    mcd.add_vertex(id=role_arn, node_name='role-lambda-name', arn=role_arn, node_type='iam_role')
    mcd.add_link(src_node_id="lambda_function:" + func_arn, dst_node_id="iam_role:" + role_arn)

    cw_policy_arn = "arn:aws:iam::123456789:policy/prod-cloudwatch-policy"
    mcd.add_vertex(id=cw_policy_arn, node_name='prod-cloudwatch-policy', arn=cw_policy_arn, node_type='iam_policy')
    mcd.add_link("iam_role:" + role_arn, "iam_policy:" + cw_policy_arn)

    s3_policy_arn = "arn:aws:iam::123456789:policy/prod-s3-policy"
    mcd.add_vertex(id=s3_policy_arn, node_name='prod-s3-policy', arn=s3_policy_arn, node_type='iam_policy')
    mcd.add_link("iam_role:" + role_arn, "iam_policy:" + s3_policy_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 }

output.prod.iam-roles.png

FYI:

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.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

multicloud_diagrams-0.3.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: multicloud_diagrams-0.3.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.2 Darwin/21.6.0

File hashes

Hashes for multicloud_diagrams-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6a1053b9bafa09c4d9a350a7d87ccaa1d9be09042d23c0569fb3ed137b42503f
MD5 2714339d4be7327de26096f387fefd6c
BLAKE2b-256 3a2dab509761f1f49a98a41dd594ea28c56fdbf4e29cf2c2ceb98c643261b23b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for multicloud_diagrams-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e3c792f47732ea39912db2427a94ccecb8edf62b688c6d4e09c68f51fcc1c56
MD5 610e8e4ae63e14698e07f1cafb53aa19
BLAKE2b-256 c3fea26e8965358fd78d8ba09a911ea119620e1a2366b488668b65de1b8196de

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