Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
344 changes: 270 additions & 74 deletions packages/@aws-cdk/aws-imagebuilder-alpha/README.md

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions packages/@aws-cdk/aws-imagebuilder-alpha/lib/base-image.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,66 @@
import * as ecr from 'aws-cdk-lib/aws-ecr';
import * as ssm from 'aws-cdk-lib/aws-ssm';

/**
* Represents a base image that is used to start from in EC2 Image Builder image builds
*/
export class BaseImage {
/**
* The AMI ID to use as a base image in an image recipe
*
* @param amiId The AMI ID to use as the base image
*/
public static fromAmiId(amiId: string): BaseImage {
return new BaseImage(amiId);
}

/**
* The marketplace product ID for an AMI product to use as the base image in an image recipe
*
* @param productId The Marketplace AMI product ID to use as the base image
*/
public static fromMarketplaceProductId(productId: string): BaseImage {
return new BaseImage(productId);
}

/**
* The SSM parameter to use as the base image in an image recipe
*
* @param parameter The SSM parameter to use as the base image
*/
public static fromSsmParameter(parameter: ssm.IParameter): BaseImage {
return this.fromSsmParameterName(parameter.parameterArn);
}

/**
* The parameter name for the SSM parameter to use as the base image in an image recipe
*
* @param parameterName The name of the SSM parameter to use as the base image
*/
public static fromSsmParameterName(parameterName: string): BaseImage {
return new BaseImage(`ssm:${parameterName}`);
}

/**
* The direct string value of the base image to use in an image recipe. This can be an EC2 Image Builder image ARN,
* an SSM parameter, an AWS Marketplace product ID, or an AMI ID.
*
* @param baseImageString The base image as a direct string value
*/
public static fromString(baseImageString: string): BaseImage {
return new BaseImage(baseImageString);
}

/**
* The rendered base image to use
**/
public readonly image: string;

protected constructor(image: string) {
this.image = image;
}
}

/**
* Represents a base image that is used to start from in EC2 Image Builder image builds
*/
Expand Down Expand Up @@ -108,3 +168,4 @@ export class ContainerInstanceImage {
this.image = image;
}
}

10 changes: 10 additions & 0 deletions packages/@aws-cdk/aws-imagebuilder-alpha/lib/container-recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
import { Construct } from 'constructs';
import { BaseContainerImage, ContainerInstanceImage } from './base-image';
import { Repository } from './distribution-configuration';
import { IImageRecipe } from './image-recipe';
import { OSVersion } from './os-version';
import { ComponentConfiguration, IRecipeBase } from './recipe-base';

Expand Down Expand Up @@ -378,6 +379,15 @@ export abstract class ContainerRecipeBase extends cdk.Resource implements IConta
public _isContainerRecipe(): this is IContainerRecipe {
return true;
}

/**
* Indicates whether the recipe is an Image Recipe
*
* @internal
*/
public _isImageRecipe(): this is IImageRecipe {
return true;
}
}

/**
Expand Down
Loading
Loading