Skip to content

can't change direction of cluster to TB #1139

@markeenrw

Description

@markeenrw

Hi ALL,

I've been playing around with this tool and came up with a simple use case. Using TF statefiles create an OU structure diagram.

Image

As you can see that works fine.

What's falling apart is when I introduce accounts.

Image

It looks like a mess. There are few possible ideas I've had for fixing this, though to me the easiest would be to change the cluster direction from the default LR to TB, but I can't seem to get this working.

# Generate Organisation Structure
with Diagram(filename="Org", show=False, curvestyle='curved'):
    
    data_ou_resources = []
    root_ou_id = data['org']['outputs']['ou_root_id']['value']
    root_ou = OU('root')

    # get a list of OU Resources
    for resource in data['org']['resources']:
        if resource['type'] == "aws_organizations_organizational_unit":
            data_ou_resources.append(resource['instances'][0]['attributes'])

    # Draw them
    for ou in data_ou_resources:
        ou.update({"diagram_obj" : OU(ou['name'])} )

    # Setup the relationships between the objects
    for ou in data_ou_resources:
        if ou['parent_id'] != root_ou_id:
            for obj in data_ou_resources:
                if obj['id'] == ou['parent_id']:
                    obj['diagram_obj'] >> ou['diagram_obj']
                    break
        else:
             root_ou >> ou['diagram_obj']

    for ou in data_ou_resources:
        with Cluster(ou['name'], direction='TB'):
            for account in ou['accounts']:
                ou['diagram_obj'] - ACC(account['name'])

Any ideas?


UPDATE:

I am a moron. Who realised too late that already am in TB and what I want is LR.

Image

So with that change, the accounts are now stacked like I want, but it's not perfect.

I would much prefer it if it looked something like this.

Image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions