> **Experimental**
>
> `@aws-cdk/aws-imagebuilder-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# ImageRecipe

Represents an EC2 Image Builder Image Recipe.

Extends: Construct › Resource › ImageRecipe
Implements: IImageRecipe, IRecipeBase, IResource, IEnvironmentAware, IConstruct, IDependable

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/image-recipe.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0-alpha.0/packages/@aws-cdk/aws-imagebuilder-alpha/lib/image-recipe.ts#L236)

## Example

```ts
const parameterizedComponent = imagebuilder.Component.fromComponentName(
  this,
  'ParameterizedComponent',
  'my-parameterized-component'
);

const imageRecipe = new imagebuilder.ImageRecipe(this, 'ParameterizedImageRecipe', {
  baseImage: imagebuilder.BaseImage.fromSsmParameterName(
    '/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64'
  ),
  components: [
    {
      component: parameterizedComponent,
      parameters: {
        environment: imagebuilder.ComponentParameterValue.fromString('production'),
        version: imagebuilder.ComponentParameterValue.fromString('1.0.0')
      }
    }
  ]
});
```

## Initializer

```ts
new ImageRecipe(scope: Construct, id: string, props: ImageRecipeProps)
```

## Construct Props

- `amiTags`: { [key: string]: string } = None — The additional tags to assign to the output AMI generated by the build.

- `baseImage`: [BaseImage](/cdk/api/v2/docs/@aws-cdk_aws-imagebuilder-alpha.BaseImage.html) (required) — The base image for customizations specified in the image recipe.

- `blockDevices`: [BlockDevice](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.BlockDevice.html)[] = None — The block devices to attach to the instance used for building the image.

- `components`: [ComponentConfiguration](/cdk/api/v2/docs/@aws-cdk_aws-imagebuilder-alpha.ComponentConfiguration.html)[] = None — The list of component configurations to apply in the image build.

- `description`: string = None — The description of the image recipe.

- `imageRecipeName`: string — The name of the image recipe.

  **Default:** a name is generated

- `imageRecipeVersion`: string = 1.0.x — The version of the image recipe.

- `tags`: { [key: string]: string } = None — The tags to apply to the image recipe.

- `uninstallSsmAgentAfterBuild`: boolean — Whether to uninstall the Systems Manager agent from your final build image, prior to creating the new AMI.

  **Default:** this is false if the Systems Manager agent is pre-installed on the base image. Otherwise, this is true.

- `userDataOverride`: [UserData](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.UserData.html) = None — The user data commands to pass to Image Builder build and test EC2 instances.

  For Linux and macOS, Image Builder
  uses a default user data script to install the Systems Manager agent. If you override the user data, you must
  ensure to add commands to install Systems Manager agent, if it is not pre-installed on your base image.

- `workingDirectory`: string — The working directory for use during build and test workflows.

  **Default:** the Image Builder default working directory is used. For Linux and macOS builds, this would be /tmp. For Windows builds, this would be C:/

## Properties

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `imageRecipeArn`: string (required) — The ARN of the image recipe.

- `imageRecipeName`: string (required) — The name of the image recipe.

- `imageRecipeVersion`: string (required) — The version of the image recipe.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `PROPERTY_INJECTION_ID`: string (required) (static) — Uniquely identifies this class.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) (required) — The stack in which this resource is defined.

## Methods

- `addBlockDevice(...blockDevices: BlockDevice[]): void` — Adds block devices to attach to the instance used for building the image.

  **Parameters**

  - `blockDevices` — The list of block devices to attach.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromImageRecipeArn(scope: Construct, id: string, imageRecipeArn: string): IImageRecipe` (static) — Import an existing image recipe given its ARN.

- `fromImageRecipeAttributes(scope: Construct, id: string, attrs: ImageRecipeAttributes): IImageRecipe` (static) — Import an existing image recipe by providing its attributes.

  If the image recipe name is provided as an attribute,
  it must be normalized by converting all alphabetical characters to lowercase, and replacing all spaces and
  underscores with hyphens.

- `fromImageRecipeName(scope: Construct, id: string, imageRecipeName: string): IImageRecipe` (static) — Import the latest version of an existing image recipe given its name.

  The provided name must be normalized by
  converting all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens.

- `grant(grantee: IGrantable, ...actions: string[]): Grant` — Grant custom actions to the given grantee for the image recipe [disable-awslint:no-grants].

  **Parameters**

  - `grantee` — The principal.
  - `actions` — The list of actions.

- `grantRead(grantee: IGrantable): Grant` — Grant read permissions to the given grantee for the image recipe [disable-awslint:no-grants].

  **Parameters**

  - `grantee` — The principal.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isImageRecipe(x: any): boolean` (static) — Return whether the given object is an ImageRecipe.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
