Skip to content

RFC: Simplifying ALB and IAM Role Configuration in modules #392

@ghost

Description

Is this related to an existing feature request or issue?

No

What part of the Cloud Game Development Toolkit does this RFC relate to?

Modules

Summary

We currently expose customization of the application load balancer that fronts the Helix Authentication Service, the Helix Swarm service, and the Unreal Horde service through module variables. This results in a significant number of variables, which requires extensive conditional creation of resources inside the module. I propose that we adopt a more opinionated and less customizable approach to ALB creation inside of the module, and support target group and service detail module outputs so extensive networking customization can be accomplished outside of the module.

The same goes for IAM roles. We support passing in an externally created role. It may make more sense to control role creation for the service inside the module, and attach permissions / policies externally by exposing the role ARN as an output.

Use case

Proposal

Currently, I control the ALB and role creation for the Helix Authentication Service through variables:

module "perforce_helix_authentication_service" {
  source                                   = "cloud-game-development-toolkit/modules/perforce/helix-authentication-service"
  ...
  # subnet specification
  helix_authentication_service_alb_subnets = aws_subnet.public_subnets[*].id
  helix_authentication_service_subnets     = aws_subnet.private_subnets[*].id
  certificate_arn                          = aws_acm_certificate.helix.arn
  ...
  # access log specification - these are wordy and confusing
  enable_helix_authentication_service_alb_access_logs = true
  helix_authentication_service_alb_access_logs_prefix = "has-access-logs"

  # Deletion protection
  enable_helix_authentication_service_alb_deletion_protection = false

  # security group attachment
  existing_security_groups = ["sg-0123456789"]
  
  # Role attachment - These also feel cumbersome
  custom_helix_authentication_service_role = "IAM ROLE ARN"
  create_helix_authentication_service_default_policy = true

  depends_on = [aws_ecs_cluster.perforce_cluster, aws_acm_certificate_validation.helix]
}

It would be simpler if these variables were not exposed. We should enable creation (turn off/on), but be opinionated on the following topics:

  1. For load balancing, we should default for access logs, deletion protection. We can enable dynamic creation and setting of these with one additional flag: debug.
  2. For IAM policies and roles we should use least privilege permissions and expose the IAM role through outputs to allow end users to extend permissions as needed.

Out of scope

The module should be responsible for creating NECESSARY resources for operating the service:

  1. ECS cluster we can turn off or on. If it is turned off, you must provide an external cluster name. We need this cluster for service definition.
  2. The service, container definitions, and supporting resources (elasticache, documentdb, efs, IAM roles, etc.) are the core of the module.
  3. A target group for the service is generally a requirement. A target group does not need any information beyond service details. It should be created by default.
  4. An ALB or NLB is a networking decision for the end user. Again, we can decide to provide simple ALB creation and provisioning through the module, but this should be a binary switch.

Potential challenges

There is nuance around how we manage security groups, both within the module and externally managed. This is something that needs further design, and probably would have holistic changes to the way we build security groups for modules.

Dependencies and Integrations

I am currently working on a sample for running Helix Core behind an NLB. This same NLB can also manage traffic for Helix Swarm and Helix Authentication Service. Currently, both Helix Swarm and Helix Authentication service create ALBs, but this is inefficient. In order to share an ALB we should be able to disable ALB creation inside of each of these modules, but pull out target groups from each for creating listeners / rules on the shared ALB and the shared NLB.

Alternative solutions

Support the injection of an externally created ALB. Then manage listener / target group attachment inside the module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCperforceterraformPull requests that update Terraform code

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions