Skip to main content

AwsEcrImageModule

AwsEcrImageModule creates the ECR repositories a container image is pushed to, one in each of its regions, keeping the newest imageTagsToKeep versions.

It creates the repositories and nothing else - the versions inside them are published by the AwsEcrImageTagModule, one module per version.

@cost

ECR bills about $0.10 per GB-month of images stored; pulling within the same region is free. imageTagsToKeep bounds the bill by deleting all but the newest tags.

@downtime

None for a change to imageTagsToKeep. A replacement deletes the repository with every image in it.

@example

TypeScript

import { type Region, stub } from '@quadnix/octo';
import { AwsEcrImageModule } from '@quadnix/octo-aws-cdk/modules/image/aws-ecr-image';

octo.loadModule(AwsEcrImageModule, 'my-image-module', {
imageFamily: 'quadnix',
imageName: 'nginx',
regions: [
stub<Region>('${{my-region-1-module.model.region}}'),
stub<Region>('${{my-region-2-module.model.region}}'),
],
});
@group

Modules/Image/AwsEcrImage

@limit

A tag is immutable: a version is never overwritten, only deleted and published again. Images are not scanned for vulnerabilities.

@losesData

Deleting the module, or a change that replaces the repository, deletes every image in it, even one a running service still uses. An image octo publishes can be built again from its Dockerfile, while the code it was built from still exists.

@replaces

Changing imageFamily or imageName replaces the repositories. Adding a region to regions creates a repository there, and removing one deletes that repository with its images. imageTagsToKeep changes in place.

@see

Hierarchy

Index

Constructors

constructor

  • Parameters

    • moduleId: string

      The ID this module is loaded under.

    Returns AwsEcrImageModule

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

  • Creates the image in the account of its regions, and registers one ECR repository per AWS region it is used in.


    Parameters

    Returns Promise<AwsEcrImage>

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[]

registerMetadata

  • registerMetadata(inputs: AwsEcrImageModuleSchema): Promise<{ account: Account; uniqueImageRepositories: { awsAccountId: string; awsRegionId: string }[] }>
  • Resolves the account the image sits in, and the distinct AWS regions an ECR repository is needed in.


    Parameters

    Returns Promise<{ account: Account; uniqueImageRepositories: { awsAccountId: string; awsRegionId: string }[] }>