Interface Ec2Context

All Known Implementing Classes:
Ec2ContextImpl

public interface Ec2Context
Runtime context information for EC2 UserData configuration.

This interface provides applications with the runtime information they need to make decisions during UserData script generation, such as:

  • Whether to use EFS or EBS for storage
  • Stack name for resource naming and logging
  • Runtime environment (EC2 vs Fargate)
  • Security profile for compliance requirements

Applications use this context to adapt their configuration based on the deployment environment.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the EFS access point ID if EFS is available.
    default String
    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 String
    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.
    Returns the EFS filesystem ID if EFS is available.
    default String
    Returns the fully-qualified domain name for this deployment, if a domain is configured.
    boolean
    Returns whether EFS is available in this deployment.
    Returns the runtime type as a string.
    Returns the security profile as a string.
    default boolean
    Returns whether TLS/SSL is enabled for this deployment (affects the scheme used when building a public URL for the application, e.g.
    Returns the CloudFormation stack name.
  • Method Details

    • stackName

      String stackName()
      Returns the CloudFormation stack name. Used for resource naming and CloudWatch log group names.
      Returns:
      stack name (e.g., "jenkins-prod")
    • runtimeType

      String runtimeType()
      Returns the runtime type as a string. Typically "EC2" or "FARGATE".
      Returns:
      runtime type in lowercase (e.g., "ec2")
    • securityProfile

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

      boolean hasEfs()
      Returns whether EFS is available in this deployment. If true, applications should use EFS for storage. If false, applications should use EBS for storage.
      Returns:
      true if EFS is configured and available
    • efsId

      Optional<String> efsId()
      Returns the EFS filesystem ID if EFS is available.
      Returns:
      EFS filesystem ID (e.g., "fs-12345678"), or empty if EFS is not available
    • accessPointId

      Optional<String> accessPointId()
      Returns the EFS access point ID if EFS is available.
      Returns:
      EFS access point ID (e.g., "fsap-12345678"), or empty if EFS is not available
    • authMode

      default String authMode()
      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).

      Returns:
      auth mode string, e.g. "none"
      Since:
      3.2.0
    • fqdn

      default String fqdn()
      Returns the fully-qualified domain name for this deployment, if a domain is configured.
      Returns:
      FQDN (e.g., "manager.example.com"), or null if no domain is configured
      Since:
      3.2.0
    • sslEnabled

      default boolean sslEnabled()
      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://).
      Returns:
      true if SSL is enabled
      Since:
      3.2.0
    • autoAdminPasswordSecretArn

      default String autoAdminPasswordSecretArn()
      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.

      Returns:
      the secret ARN, or null
      Since:
      3.2.18