Skip to main content

AwsCloudFrontInvalidationServiceModule

AwsCloudFrontInvalidationServiceModule is a CloudFront-based AWS module that drops what a distribution's edges hold for one bucket, every time that bucket's files change.

Without it, changed files are served from the edges' old copies until those expire.

It runs after the bucket's files are uploaded. It drops /*, which CloudFront bills as one path. One module covers one bucket; a distribution serving several buckets takes one module per bucket.

@cost

CloudFront bills invalidation paths beyond 1,000 a month at about $0.005 each, and this module sends one path, /*, each time the bucket's files change.

@downtime

None: viewers get the old files until each edge drops its copy, usually within a few minutes.

@example

TypeScript

import { type Service, stub } from '@quadnix/octo';
import { AwsCloudFrontInvalidationServiceModule } from '@quadnix/octo-aws-cdk/modules/service/aws-cloudfront-invalidation-service';

octo.loadModule(AwsCloudFrontInvalidationServiceModule, 'my-invalidation-module', {
cloudFront: stub<Service>('${{my-distribution-module.model.service}}'),
source: stub<Service>('${{my-content-module.model.service}}'),
});
@group

Modules/Service/AwsCloudFrontInvalidationService

@limit

One module covers one bucket. It drops everything the distribution holds, not only the bucket's changed files.

@losesData

Nothing.

@replaces

Nothing: each change of the bucket's files sends a new invalidation.

@see

Hierarchy

Index

Constructors

constructor

  • Parameters

    • moduleId: string

      The ID this module is loaded under.

    Returns AwsCloudFrontInvalidationServiceModule

Properties

readonlyinheritedmoduleId

moduleId: string

The ID this module was loaded under. It scopes everything the module produces, so the same module class can be loaded more than once.

staticreadonlyinheritedMODULE_PACKAGE

MODULE_PACKAGE: string

The package the module is registered under, set by Module.

staticreadonlyinheritedMODULE_SCHEMA

MODULE_SCHEMA: any

The schema of the module's inputs, set by Module.

Methods

onInit

inheritedregisterHooks

  • registerHooks(): { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }
  • To hook custom behavior into Octo's lifecycle for the duration of this module. Override it to return the callbacks you want run.

    @see

    Techniques for Hooks.


    Returns { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }

    • optionalpostCommitHooks?: PostHookSignature[]
    • optionalpostModelActionHooks?: PostHookSignature[]
    • optionalpostResourceActionHooks?: PostHookSignature[]
    • optionalpreCommitHooks?: PreHookSignature[]
    • optionalpreModelActionHooks?: PreHookSignature[]
    • optionalpreResourceActionHooks?: PreHookSignature[]

inheritedregisterMetadata

  • To derive values that both AModule.onInit and this module's actions need - typically facts resolved from another module's anchors, such as an account ID or a region's availability zones. Override it, and the returned object is handed to every action of this module as actionInputs.metadata.


    Parameters

    Returns Promise<Record<string, unknown>>