Amplify Toolbox
    Preparing search index...

    Type Alias AmplifyHostingConstructProps

    Props for the HostingConstruct.

    This construct is FRAMEWORK-AGNOSTIC. It reads a DeployManifest and provisions infrastructure accordingly. It never imports Next.js or OpenNext.

    type AmplifyHostingConstructProps = {
        buildCache?: { bucket?: s3.IBucket; enabled: boolean };
        cdn?: {
            contentSecurityPolicy?: string;
            geoRestriction?: { countries: string[]; type: "whitelist" | "blacklist" };
            priceClass?: PriceClass;
            quotas?: QuotaOverrides;
            responseHeadersPolicy?: IResponseHeadersPolicy;
            ssrDefaultTtl?: Duration;
            webAclArn?: string;
        };
        compute?: {
            environment?: Record<string, string>;
            imageOptimization?: { reservedConcurrency?: number };
            logRetention?: RetentionDays;
            memorySize?: number;
            provisionedConcurrency?: number;
            reservedConcurrency?: number;
            timeout?: Duration | number;
            tracing?: {
                otelEndpoint: string;
                otelHeaders?: string;
                serviceName?: string;
            };
            warmup?: { rate: Duration };
        };
        configStore?: KindStoreOptions;
        domain?: HostingDomainConfig;
        environment?: Record<string, EnvValue>;
        errorPages?: { notFound?: string; serverError?: string };
        logging?: { enabled: boolean; retentionDays?: number };
        manifest: DeployManifest;
        monitoring?: { enabled?: boolean; snsTopicArn?: string };
        secretStore?: KindStoreOptions;
        skewProtection?: { enabled: boolean; maxAge?: number };
        skipRegionValidation?: boolean;
        storage?: {
            buildRetentionDays?: number;
            deployIntervalDays?: number;
            deployment?: { ephemeralStorageMiB?: number; memoryLimit?: number };
            encryption?: "S3_MANAGED" | "KMS";
            encryptionKey?: IKey;
            inventory?: { enabled: boolean };
            retainOnDelete?: boolean;
        };
        waf?: HostingWafConfig;
    }
    Index

    Properties

    buildCache?: { bucket?: s3.IBucket; enabled: boolean }

    Build cache configuration. When enabled, provisions an S3 bucket for framework build caches and exports the bucket name.

    Type Declaration

    • Optionalbucket?: s3.IBucket

      BYO S3 bucket for build cache storage. Creates one if not provided.

    • enabled: boolean
    cdn?: {
        contentSecurityPolicy?: string;
        geoRestriction?: { countries: string[]; type: "whitelist" | "blacklist" };
        priceClass?: PriceClass;
        quotas?: QuotaOverrides;
        responseHeadersPolicy?: IResponseHeadersPolicy;
        ssrDefaultTtl?: Duration;
        webAclArn?: string;
    }

    CDN (CloudFront) configuration.

    Type Declaration

    • OptionalcontentSecurityPolicy?: string
    • OptionalgeoRestriction?: { countries: string[]; type: "whitelist" | "blacklist" }
    • OptionalpriceClass?: PriceClass
    • Optionalquotas?: QuotaOverrides

      Overrides for the adjustable AWS Service Quotas this distribution draws on — cacheBehaviors (CloudFront behaviors per distribution), edgeFunctions (Lambda@Edge associations), and headerPolicies (response-headers policies per account). Omitted fields use AWS defaults.

      Set a field ONLY to match a quota increase AWS has actually granted: synth cannot verify your real quota, so an over-set value does not raise the AWS ceiling — it just moves the failure from a clear synth error to an opaque CloudFormation rollback at deploy.

    • OptionalresponseHeadersPolicy?: IResponseHeadersPolicy

      Bring-your-own ResponseHeadersPolicy. When provided, the construct skips creating its own policy — use this to share a single policy across multiple hosting stacks and avoid the account-level limit (default 20, max 200 via service-quota increase).

      Create a shared policy once (e.g. in a shared-infra stack):

      const sharedPolicy = new ResponseHeadersPolicy(sharedStack, 'SharedPolicy', { ... });
      

      Then import by ID in each hosting stack:

      cdn: { responseHeadersPolicy: ResponseHeadersPolicy.fromResponseHeadersPolicyId(this, 'Imported', policyId) }
      
    • OptionalssrDefaultTtl?: Duration

      Default TTL for SSR/compute cache behaviors when the origin response does not include a Cache-Control header. Set this to enable CloudFront edge caching of SSR responses and improve hit ratio.

      When set, SSR responses without an explicit Cache-Control header are cached at the edge for this duration. The origin can always override via s-maxage or no-store.

      Duration.seconds(0) — no caching unless origin opts in
      
    • OptionalwebAclArn?: string

      ARN of an existing WAFv2 WebACL to associate with the CloudFront distribution. Use this when you manage WAF rules externally (e.g. via a shared security account) or need advanced WAF features beyond the built-in waf.enabled rate-limiting.

      Takes precedence over waf.enabled — when set, the built-in WAF construct is not created.

    compute?: {
        environment?: Record<string, string>;
        imageOptimization?: { reservedConcurrency?: number };
        logRetention?: RetentionDays;
        memorySize?: number;
        provisionedConcurrency?: number;
        reservedConcurrency?: number;
        timeout?: Duration | number;
        tracing?: {
            otelEndpoint: string;
            otelHeaders?: string;
            serviceName?: string;
        };
        warmup?: { rate: Duration };
    }

    Compute (Lambda) overrides for all compute resources.

    Type Declaration

    • Optionalenvironment?: Record<string, string>

      Additional environment variables to inject into all compute Lambda functions. Merged with (and overrides) any environment variables declared in the deploy manifest's compute resources.

    • OptionalimageOptimization?: { reservedConcurrency?: number }

      Reserved concurrent executions for the image-optimization Lambda. Default: undefined (no reservation).

      Historically this was hardcoded to 10, which broke cdk deploy on fresh AWS accounts: the default account-level unreserved-concurrency limit is 10, so reserving all 10 for image-opt drops the account below its required minimum and Lambda rejects the stack with a 400. Defaulting to no reservation keeps deploys working out of the box while still letting operators cap image-opt explicitly.

    • OptionallogRetention?: RetentionDays
    • OptionalmemorySize?: number
    • OptionalprovisionedConcurrency?: number

      Provisioned concurrency for the SSR Lambda (cold-start elimination). When > 0, the construct creates a live alias with this many always-warm execution environments and points the SSR REST API integration at the alias. Default: undefined (no provisioning).

    • OptionalreservedConcurrency?: number
    • Optionaltimeout?: Duration | number

      Lambda timeout. Accepts either a cdk.Duration (preferred) or a number of seconds for ergonomics — the L3 normalizes both to Duration before handing them to the Lambda construct. A plain number used to slip through the type at the user-facing API surface (e.g. when consumed via JS-compiled wrappers) and crash synth deep inside aws-cdk-lib with props.timeout.toSeconds is not a function. Coercing here makes that surface forgiving.

    • Optionaltracing?: { otelEndpoint: string; otelHeaders?: string; serviceName?: string }

      4.1 — OpenTelemetry env hooks for SSR / image-opt / revalidation Lambdas.

    • Optionalwarmup?: { rate: Duration }

      2.1 — synthetic warmup schedule.

    configStore?: KindStoreOptions

    Namespace/cache config for config values (SSM Parameter Store). Defaults to the neutral /hosting/config prefix. Governs prefix, stage, cacheTtlSeconds.

    Custom domain configuration.

    environment?: Record<string, EnvValue>

    Custom environment variables for all compute functions. A value may be:

    • a plain string (injected verbatim),
    • a secret('K') marker → wired at runtime from Secrets Manager (read via getSecret('K')),
    • a config('K') marker → wired at runtime from SSM Parameter Store (read via getConfig('K')),
    • a BYO ISecret / IParameter handle → granted + wired identically (read via getSecret/getConfig).

    For each managed/BYO value the store LOCATOR (never the value) is injected and the compute role granted read+decrypt. Domain markers resolve at synth and must go through the async wrapper (e.g. Hosting.create()).

    errorPages?: { notFound?: string; serverError?: string }

    Custom error page configuration. Provide paths to HTML files for custom 404 and 500 error responses.

    Type Declaration

    • OptionalnotFound?: string

      Path to a custom 404 HTML file (relative to project root).

    • OptionalserverError?: string

      Path to a custom 500 HTML file (relative to project root).

    logging?: { enabled: boolean; retentionDays?: number }

    CloudFront access logging configuration.

    manifest: DeployManifest

    Deploy manifest produced by the framework adapter.

    monitoring?: { enabled?: boolean; snsTopicArn?: string }

    Default CloudWatch alarms (P3.1 + P3.2). On by default. When enabled, the L3 wires CloudFront 5xx, Lambda error / throttle, and revalidation-DLQ alarms to an SNS topic. Opt out with { enabled: false }. See MonitoringConstruct.

    Type Declaration

    • Optionalenabled?: boolean
      true
      
    • OptionalsnsTopicArn?: string
    secretStore?: KindStoreOptions

    Namespace/cache config for secret values (Secrets Manager). Defaults to the neutral /hosting/secrets prefix; a branded consumer overrides it (e.g. Blocks passes /blocks/secrets). Governs prefix, stage, cacheTtlSeconds.

    skewProtection?: { enabled: boolean; maxAge?: number }

    Cookie-based skew protection. When enabled, users mid-session keep receiving assets from their original build, preventing asset mismatches during rolling deployments.

    Type Declaration

    • enabled: boolean
    • OptionalmaxAge?: number

      How long to honor old build cookies (seconds). Default: 86400 (24h)

    { enabled: true } — skew protection is enabled by default. Set \{ enabled: false \} to disable.

    skipRegionValidation?: boolean

    Skips region validation for WAF WebACL (must be us-east-1 for CloudFront), ACM certificates (must be us-east-1 for CloudFront), and Lambda Web Adapter compatibility checks. Useful for testing.

    storage?: {
        buildRetentionDays?: number;
        deployIntervalDays?: number;
        deployment?: { ephemeralStorageMiB?: number; memoryLimit?: number };
        encryption?: "S3_MANAGED" | "KMS";
        encryptionKey?: IKey;
        inventory?: { enabled: boolean };
        retainOnDelete?: boolean;
    }

    S3 storage configuration.

    Type Declaration

    • OptionalbuildRetentionDays?: number
    • OptionaldeployIntervalDays?: number

      Advisory hint used at synth to warn when deploy cadence ≥ retention (#480).

    • Optionaldeployment?: { ephemeralStorageMiB?: number; memoryLimit?: number }

      Resources for the Lambda that uploads static assets to S3 (CDK's BucketDeployment). CDK defaults this Lambda to 128 MB memory and a 512 MiB /tmp — too small for large static sites, which then OOM or run out of disk with an opaque CloudFormation error at deploy time. The L3 raises the defaults to 1024 MB / 1024 MiB; override here if a very large build still hits the ceiling.

      • OptionalephemeralStorageMiB?: number

        /tmp size (MiB) for the asset-upload Lambda.

        1024
        
      • OptionalmemoryLimit?: number

        Memory (MiB) for the asset-upload Lambda.

        1024
        
    • Optionalencryption?: "S3_MANAGED" | "KMS"
    • OptionalencryptionKey?: IKey
    • Optionalinventory?: { enabled: boolean }

      3.3 — opt-in daily S3 inventory of builds/.

    • OptionalretainOnDelete?: boolean

    WAF configuration.