awslabs / diagram-as-code

Diagram-as-code for AWS architecture.
Apache License 2.0
405 stars 22 forks source link

Generate a yaml template (not CloudFormation template) for creating a diagram from CloudFormation template #75

Closed a2ush closed 1 month ago

a2ush commented 1 month ago

Is your feature request related to a problem? Please describe.

Currently, awsdac creates a diagram from CloudFormation template without user customs. Therefore, you cannot modify this diagram. If you want to edit the diagram, you need to create a yaml template (not CloudFormation template).

Describe the solution you'd like

Generate a yaml template (not CloudFormation template) for creating a diagram from CloudFormation template.

Describe alternatives you've considered

Generate a yaml template from scratch.

Additional context

CloudFormation templates have various dependencies, and there is no simple parent-child relationship between resources. It seems difficult to generate the desired diagram using only existing CloudFormation template formats.

I considered utilizing Metadata or comments within the CloudFormation templates to include additional information, but this approach would make the templates excessively long, and CloudFormation templates are intended for resource creation and management rather than diagram generation. Additionally, combining different lifecycle components into a single CloudFormation template would make it difficult to manage and maintain.

CloudFormation template --[awsdac]--> yaml template --[user custom]--> your desired diagram :)

Based on the challenges mentioned, instead of directly generating diagrams from CloudFormation templates, we propose an approach where we create a separate YAML file from the CloudFormation template. This YAML file can then be customized by users and used as input for awsdac to generate the desired architecture diagrams. This approach decouples the diagram generation process from the CloudFormation template structure, allowing for more flexibility and customization while leveraging the strengths of specialized awsdac.

a2ush commented 1 month ago

Now, you can generate a yaml file from CloudFormation template with --yaml option.

Resources:
  SampleFargateCluster:
    Type: AWS::ECS::Cluster
    Properties:
      ClusterName: !Ref ClusterName
Diagram:
    DefinitionFiles:
        - Type: URL
          Url: https://raw.githubusercontent.com/awslabs/diagram-as-code/main/definitions/definition-for-aws-icons-light.yaml
          LocalFile: ""
          Embed:
            Definitions: {}
    Resources:
        AWSCloud:
            Type: AWS::Diagram::Cloud
            Icon: ""
            Direction: ""
            Preset: AWSCloudNoLogo
            Align: center
            FillColor: ""
            Title: ""
            TitleColor: ""
            Font: ""
            Children:
                - SampleFargateCluster
        Canvas:
            Type: AWS::Diagram::Canvas
            Icon: ""
            Direction: ""
            Preset: ""
            Align: ""
            FillColor: ""
            Title: ""
            TitleColor: ""
            Font: ""
            Children:
                - AWSCloud
        SampleFargateCluster:
            Type: AWS::ECS::Cluster
            Icon: ""
            Direction: ""
            Preset: ""
            Align: ""
            FillColor: ""
            Title: ""
            TitleColor: ""
            Font: ""
            Children: []
    Links: []