Class Ec2ContextImpl

java.lang.Object
com.cloudforgeci.api.core.Ec2ContextImpl
All Implemented Interfaces:
Ec2Context

public class Ec2ContextImpl extends Object implements Ec2Context
Implementation of Ec2Context providing runtime information for UserData configuration.
  • Constructor Details

    • Ec2ContextImpl

      public Ec2ContextImpl(String stackName, String runtimeType, String securityProfile, boolean hasEfs, String efsId, String accessPointId)
    • Ec2ContextImpl

      public Ec2ContextImpl(String stackName, String runtimeType, String securityProfile, boolean hasEfs, String efsId, String accessPointId, String authMode, String fqdn, boolean sslEnabled)
    • Ec2ContextImpl

      public Ec2ContextImpl(String stackName, String runtimeType, String securityProfile, boolean hasEfs, String efsId, String accessPointId, String authMode, String fqdn, boolean sslEnabled, String autoAdminPasswordSecretArn)
  • Method Details

    • stackName

      public String stackName()
      Description copied from interface: Ec2Context
      Returns the CloudFormation stack name. Used for resource naming and CloudWatch log group names.
      Specified by:
      stackName in interface Ec2Context
      Returns:
      stack name (e.g., "jenkins-prod")
    • runtimeType

      public String runtimeType()
      Description copied from interface: Ec2Context
      Returns the runtime type as a string. Typically "EC2" or "FARGATE".
      Specified by:
      runtimeType in interface Ec2Context
      Returns:
      runtime type in lowercase (e.g., "ec2")
    • securityProfile

      public String securityProfile()
      Description copied from interface: Ec2Context
      Returns the security profile as a string. Used for compliance-aware logging and configuration.
      Specified by:
      securityProfile in interface Ec2Context
      Returns:
      security profile in lowercase (e.g., "dev", "staging", "production")
    • hasEfs

      public boolean hasEfs()
      Description copied from interface: Ec2Context
      Returns whether EFS is available in this deployment. If true, applications should use EFS for storage. If false, applications should use EBS for storage.
      Specified by:
      hasEfs in interface Ec2Context
      Returns:
      true if EFS is configured and available
    • efsId

      public Optional<String> efsId()
      Description copied from interface: Ec2Context
      Returns the EFS filesystem ID if EFS is available.
      Specified by:
      efsId in interface Ec2Context
      Returns:
      EFS filesystem ID (e.g., "fs-12345678"), or empty if EFS is not available
    • accessPointId

      public Optional<String> accessPointId()
      Description copied from interface: Ec2Context
      Returns the EFS access point ID if EFS is available.
      Specified by:
      accessPointId in interface Ec2Context
      Returns:
      EFS access point ID (e.g., "fsap-12345678"), or empty if EFS is not available
    • authMode

      public String authMode()
      Description copied from interface: Ec2Context
      Returns the configured authentication mode ("none", "alb-oidc", or "application-oidc") — the same value ApplicationSpec.containerEnvironmentVariables receives for Fargate/ECS, so EC2 UserData can reach auth/env parity with the ECS task definition.

      Default "none" for implementations predating this method (source compatibility).

      Specified by:
      authMode in interface Ec2Context
      Returns:
      auth mode string, e.g. "none"
    • fqdn

      public String fqdn()
      Description copied from interface: Ec2Context
      Returns the fully-qualified domain name for this deployment, if a domain is configured.
      Specified by:
      fqdn in interface Ec2Context
      Returns:
      FQDN (e.g., "manager.example.com"), or null if no domain is configured
    • sslEnabled

      public boolean sslEnabled()
      Description copied from interface: Ec2Context
      Returns whether TLS/SSL is enabled for this deployment (affects the scheme used when building a public URL for the application, e.g. https:// vs http://).
      Specified by:
      sslEnabled in interface Ec2Context
      Returns:
      true if SSL is enabled
    • autoAdminPasswordSecretArn

      public String autoAdminPasswordSecretArn()
      Description copied from interface: Ec2Context
      The ARN of the initial-admin-password secret ApplicationFactory provisions when ApplicationSpec.autoAdminPasswordEnvVar() is non-null, or null if that method returns null (no such secret exists for this application) or the secret hasn't been provisioned yet at the point configureUserData runs.

      UserData scripts that need this app's own generated admin password should fetch it via aws secretsmanager get-secret-value --secret-id <this ARN> using the EC2 instance role's own IAM permissions (granted automatically by Ec2Factory whenever this is non-null) — not a guessed secret name/path, which will not match the provisioned secret.

      Specified by:
      autoAdminPasswordSecretArn in interface Ec2Context
      Returns:
      the secret ARN, or null