Skip to content

Interface Definitions #36

Open
Open
@ambsw-technology

Description

@ambsw-technology

I'd like to suggest a centralized place for interface definitions and a more use-oriented scheme for Outputs naming. I assume you were trying to simplify/standardize the interfaces when creating cfn-modules, but I've already run into a case that worries me. I bring it up since interface design gets harder and harder to fix the longer you wait.

Background: The next ECS Service I need to integrate requires an inbound TCP connection so I'm forced to implement an NLB stack in addition to our "existing" ALB stack.

Issue: This lead me to use/compare alb-listener and ecs-nlb-listener-and-target. While both expose an -Arn output,

  • In alb-listener the ARN is the Listener
  • In ecs-nlb-listener-and-target the ARN is the TargetGroup

The ambiguity is especially pronounced since ecs-nlb-listener-and-target also has a Listener with an Arn that could be exposed. Technically, the interface for the two is different (i.e. ExposeArn vs Target) so they're not "incompatible", but I don't think the ExposeArn interface is useful/scalable.

Proposal: It seems to me that interfaces should not just indicate but enforce compatibility. E.G. a parameter named TargetModule should (in theory) accept any module that implements the Target interface. Like a puzzle piece, this relationship is enforced by ensuring that exports should only be compatible with each other (e.g. TargetArn and TargetSg).

If a Resource can be used in multiple ways, it can be exposed at several endpoints. For example,

  • An ECS Service would exposed its Security Group at IngressSg to indicate where to attach an Ingress rule for access to the service.
  • The ECS Service would expose the same Security Group at EgressSg as the group that gets authorized e.g. access to the RDS database.
  • An AlbListener could expose the ALB's -LoadBalancerSg at IngressSg since this is the group that would be used to access the listener
  • An AlbTarget would expose the same -LoadBalancerSg at EgressSg since this group would be authorized to e.g. the ECS Service as the source of traffic.
  • A more complex module (e.g. ALB + ECS) could expose the ALB SG at IngressSg and the ECS SG at EgressSg

Obviously, it'd be easier to see/plan/enforce these relationships if they were listed e.g. here in the docs module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions