Class SharedResourceRegistry

java.lang.Object
com.cloudforgeci.api.observability.SharedResourceRegistry

public class SharedResourceRegistry extends Object
Registry for shared/account-level resources that should be reused across stacks. Uses SSM Parameter Store to track resources, with stack-scoped naming to prevent conflicts when deploying multiple independent stacks in the same region. Supported resources: - CloudTrail (stack-scoped) - S3 buckets (stack-scoped, with RETAIN policy) - AWS Config Recorder/Delivery Channel (region-scoped, NOT stack-scoped) - Cognito User Pools (stack-scoped, with RETAIN policy) SSM parameter naming: - Stack-scoped: /cloudforge/shared/{region}/stack/{stackName}/{resource} - Region-scoped: /cloudforge/shared/{region}/{resource} Pattern: 1. Check if SSM parameter exists with resource ARN/ID 2. If exists, import existing resource 3. If not, create new resource and store in SSM
  • Constructor Details

    • SharedResourceRegistry

      public SharedResourceRegistry(software.constructs.Construct scope, String region, String stackName)
  • Method Details

    • getCloudTrailParameterName

      public String getCloudTrailParameterName()
      Get SSM parameter name for CloudTrail in this stack. Stack-scoped to allow multiple independent stacks.
    • getConfigRecorderParameterName

      public String getConfigRecorderParameterName()
      Get SSM parameter name for Config Recorder in this region. AWS Config allows only one recorder per region - NOT stack-scoped.
    • getConfigDeliveryChannelParameterName

      public String getConfigDeliveryChannelParameterName()
      Get SSM parameter name for Config Delivery Channel in this region. AWS Config allows only one delivery channel per region - NOT stack-scoped.
    • getBucketParameterName

      public String getBucketParameterName(String purpose)
      Get SSM parameter name for a retained S3 bucket. Stack-scoped to prevent conflicts between stacks.
      Parameters:
      purpose - Bucket purpose (e.g., "cloudtrail", "config", "alb-logs")
    • getCognitoUserPoolParameterName

      public String getCognitoUserPoolParameterName(String poolName)
      Get SSM parameter name for a Cognito User Pool. Stack-scoped to allow independent user pools per stack.
      Parameters:
      poolName - The user pool name
    • tryReadParameter

      public String tryReadParameter(String parameterName)
      Try to read a shared resource ID from SSM Parameter Store. Returns null if parameter doesn't exist.
      Parameters:
      parameterName - The SSM parameter name
      Returns:
      The resource ID/ARN, or null if not found
    • storeParameter

      public void storeParameter(String parameterName, String value, String description)
      Store a shared resource ID in SSM Parameter Store for future reuse.
      Parameters:
      parameterName - The SSM parameter name
      value - The resource ID/ARN to store
      description - Human-readable description