awslabs / aws-icons-for-plantuml

PlantUML sprites, macros, and other includes for Amazon Web Services services and resources
Other
908 stars 155 forks source link

Add support for Groups #47

Closed mcwarman closed 2 years ago

mcwarman commented 2 years ago

Issue #, if available: N/A

Description of changes:

Adds the support for Groups. Some example usage below.

Groups

@startuml
'Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
'SPDX-License-Identifier: MIT (For details, see https://github.com/awslabs/aws-icons-for-plantuml/blob/master/LICENSE)

!define AWSPuml https://raw.githubusercontent.com/mcwarman/aws-icons-for-plantuml/groups/dist

!include AWSPuml/AWSCommon.puml
!include AWSPuml/AWSSimplified.puml
!include AWSPuml/AWSGroups.puml

!include AWSPuml/GroupIcons/all.puml

CloudGroup(CloudGroup, "AWS Cloud")
CloudaltGroup(CloudaltGroup, "AWS Cloud")
RegionGroup(RegionGroup, "Region")
AvailabilityZoneGroup(something, "Availability Zone")
SecurityGroupGroup(SecurityGroupGroup, "Security Group")
AutoScalingGroupGroup(AutoScalingGroupGroup, "Auto Scaling Group")
VirtualPrivateCloudVPCGroup(VirtualPrivateCloudVPCGroup, "VPC")
VPCSubnetPrivateGroup(VPCSubnetPrivateGroup, "Private Subnet")
VPCSubnetPublicGroup(VPCSubnetPublicGroup, "Public Subnet")
ServerContentsGroup(ServerContentsGroup, "Server Contents")
CorporateDataCenterGroup(CorporateDataCenterGroup, "Corporate Data Center")
EC2InstanceContainerGroup(EC2InstanceContainerGroup, "EC2 Instance Container")
SpotFleetGroup(SpotFleetGroup, "Spot Fleet")
ElasticBeanstalkContainerGroup(ElasticBeanstalkContainerGroup, "Elastic Beanstalk Container")
StepFunctionGroup(StepFunctionGroup, "AWS Step Functions workflow")
GenericGroup(GenericGroup, "Generic group")
GenericAltGroup(GenericAltGroup, "Generic group")
@enduml

Examples

VPC

VPC

@startuml
'Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
'SPDX-License-Identifier: MIT (For details, see https://github.com/awslabs/aws-icons-for-plantuml/blob/master/LICENSE)

!define AWSPuml https://raw.githubusercontent.com/mcwarman/aws-icons-for-plantuml/groups/dist

!include AWSPuml/AWSCommon.puml
!include AWSPuml/AWSSimplified.puml
!include AWSPuml/AWSGroups.puml

!include AWSPuml/Compute/EC2.puml

!include AWSPuml/GroupIcons/Cloud.puml
!include AWSPuml/GroupIcons/VirtualPrivateCloudVPC.puml
!include AWSPuml/GroupIcons/VPCSubnetPublic.puml
!include AWSPuml/GroupIcons/VPCSubnetPrivate.puml

!include AWSPuml/NetworkingContentDelivery/VPCNATGateway.puml
!include AWSPuml/NetworkingContentDelivery/VPCInternetGateway.puml

CloudGroup(cloud, "AWS Cloud") {
  VirtualPrivateCloudVPCGroup(vpc, "VPC") {

    VPCInternetGateway(internet_gateway, "Internet Gateway", "")

    AvailabilityZoneGroup(az_1, "Availability Zone 1") {
      VPCSubnetPublicGroup(az_1_public, "Public Subnet") {
        VPCNATGateway(az_1_nat_gateway, "NAT Gateway", "")
      }
      VPCSubnetPrivateGroup(az_1_private, "Private Subnet") {
        EC2(az_1_ec2_1, "EC2", "")
      }

      az_1_ec2_1 .u..> az_1_nat_gateway
    }

    AvailabilityZoneGroup(az_2, "Availability Zone 2") {
      VPCSubnetPublicGroup(az_2_public, "Public Subnet") {
        VPCNATGateway(az_2_nat_gateway, "NAT Gateway", "")
      }
      VPCSubnetPrivateGroup(az_2_private, "Private Subnet") {
        EC2(az_2_ec2_1, "EC2", "")
      }

      az_2_ec2_1 .u..> az_2_nat_gateway
    }

    az_2_nat_gateway .u..> internet_gateway
    az_1_nat_gateway .u..> internet_gateway

  }
}
@enduml

Auto Scaling Groups

Auto Scaling Groups

@startuml
'Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
'SPDX-License-Identifier: MIT (For details, see https://github.com/awslabs/aws-icons-for-plantuml/blob/master/LICENSE)

!define AWSPuml https://raw.githubusercontent.com/mcwarman/aws-icons-for-plantuml/groups/dist

!include AWSPuml/AWSCommon.puml
!include AWSPuml/AWSSimplified.puml
!include AWSPuml/AWSGroups.puml

!include AWSPuml/Compute/EC2AutoScaling.puml
!include AWSPuml/Compute/EC2Instance.puml

!include AWSPuml/GroupIcons/Cloud.puml
!include AWSPuml/GroupIcons/VirtualPrivateCloudVPC.puml
!include AWSPuml/GroupIcons/AutoScalingGroup.puml

!include AWSPuml/NetworkingContentDelivery/VPCNATGateway.puml

skinparam rectangle<<hidden>> {
  shadowing false
  BackgroundColor transparent
  BorderColor transparent
}

!unquoted procedure LayoutRectangle($p_alias)
rectangle " " as $p_alias <<hidden>>
!endprocedure

CloudGroup(cloud, "AWS Cloud") {
  VirtualPrivateCloudVPCGroup(vpc, "VPC") {

    AvailabilityZoneGroup(az_2, "Availability Zone 2") {
      VPCNATGateway(az_2_nat_gateway, "NAT Gateway", "")
      EC2Instance(az_2_ec2_1, "Instance", "")
      EC2Instance(az_2_ec2_2, "Instance", "")
      az_2_nat_gateway -[hidden]d- az_2_ec2_1
      az_2_ec2_1 -[hidden]d- az_2_ec2_2
    }

    LayoutRectangle(layout_rectangle) {
      EC2AutoScaling(ec2_auto_scaling, "Amazon EC2 Auto Scaling", "")
      AutoScalingGroup(asg_1, "Auto Scaling Group", "")
      AutoScalingGroup(asg_2, "Auto Scaling Group", "")
      ec2_auto_scaling -[hidden]d- asg_1
      asg_1 -[hidden]d- asg_2
    }

    AvailabilityZoneGroup(az_1, "Availability Zone 1") {
      VPCNATGateway(az_1_nat_gateway, "NAT Gateway", "")
      EC2Instance(az_1_ec2_1, "Instance", "")
      EC2Instance(az_1_ec2_2, "Instance", "")
      az_1_nat_gateway -[hidden]d- az_1_ec2_1
      az_1_ec2_1 -[hidden]d- az_1_ec2_2
    }

    ec2_auto_scaling -[hidden]l- az_1_nat_gateway
    ec2_auto_scaling -[hidden]r- az_2_nat_gateway

    asg_1 -[dashed,#D86613]l- az_1_ec2_1
    asg_1 -[dashed,#D86613]r- az_2_ec2_1

    asg_2 -[dashed,#D86613]l- az_1_ec2_2
    asg_2 -[dashed,#D86613]r- az_2_ec2_2

  }
}
@enduml

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

mcwarman commented 2 years ago

Rebase of #40

hakanson commented 2 years ago

I noticed a typo/spelling error with Avalability - one example is AvalabilityZoneGroup(az_1, "Availability Zone 1") { but I think there were a couple more.

mcwarman commented 2 years ago

I've update the spelling on Avalability.

hakanson commented 2 years ago

With the last release, we made new config.yml generation easier - look for create_config_template() in icon-builder.py - can you see if you can also add the new BorderStyle, BorderColor, BackgroundColor subproperties of Group similar to how Color is added?

https://github.com/awslabs/aws-icons-for-plantuml/blob/07a49ce8a63f8d95b09d1a3e25e28bd1afde6c6e/scripts/icon-builder.py#L357-L358

Can you also add the Color updates you made in config.yml to the embedded template in icon-builder.py? https://github.com/awslabs/aws-icons-for-plantuml/blob/main/scripts/icon-builder.py#L161 ?

Feel free to use defaults of these, and only config overrides in a data structure similar to GROUPICONS_COLORS

      Group:
        BorderStyle: Plain
        BorderColor: SquidInk
        BackgroundColor: White
mcwarman commented 2 years ago

@hakanson I've made some updates to the code around --create-config-template and updated how it works slightly to use defaults.

hakanson commented 2 years ago

@mcwarman thanks for the update. This is still on my radar, but it might be another week before I can take a look.

hakanson commented 2 years ago

Thanks again for this PR. I spent time over the weekend building some diagrams and made some code changes. Can you select the "Allow edits from maintainers" checkbox (see https://github.blog/2016-09-07-improving-collaboration-with-forks/) so I can push these changes into your branch so they will flow back into this PR?

As I was experimenting with example diagrams, I didn't love the macro names for creating the groups (not your fault, since you used the existing icon names). I also noticed some Group icons from the most recent AWS icons deck (like AWS Account) were missing so I extracted those images. I wanted to add default labels so just AWSAccountGroup(account) could work but still allow label as the second parameter. I created a way to use a zero-length file to trigger creation of the empty groups (Available Zone, Security Group) instead of putting them in AWSGroups.yaml. In the end, there were config overrides for every Group icon, so it ended up being easier to pre-configure all of the Groups category in YAML vs Python code + extra .puml file.

Those were great Groups examples, which I had to update with my renamed macros among other tweaks. I did end up renaming the files to be prefixed with "Groups - " and added a couple more so I could fight with PlantUML rendering. Please let me know what you think of these changes.

hakanson commented 2 years ago

@mcwarman have you had a chance to see my comment above? I'd like to get this committed next week, either on this PR, or I can also create my own PR if you don't want to grant access.

mcwarman commented 2 years ago

@hakanson sorry I missed this, it was already turned on, I've toggled it though.

hakanson commented 2 years ago

Maybe user error on my part? I was getting this error message. I'll look at the docs and see what I'm doing wrong.

To https://github.com/mcwarman/aws-icons-for-plantuml.git ! [remote rejected] mcwarman-groups -> mcwarman-groups (permission denied) error: failed to push some refs to 'https://github.com/mcwarman/aws-icons-for-plantuml.git'

hakanson commented 2 years ago

It was user error specifying branch name :( - the command below will push to the properly named groups branch

git push mcwarman mcwarman-groups:groups

mcwarman commented 2 years ago

~I think its push to origin looking at these docs~:

Actually I've just reread the instructions, I'm not sure, but this might help:

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/committing-changes-to-a-pull-request-branch-created-from-a-fork

hakanson commented 2 years ago

It looks like my commits are appearing on this PR now - take a look and let me know what you think.

mcwarman commented 2 years ago

Looks good to me.

gadams999 commented 2 years ago

Reviewed and discussed, ship it!

mcwarman commented 2 years ago

FYI @jfrconley

hakanson commented 2 years ago

@mcwarman - thanks again for the PR. We pushed a release with this yesterday.