# ProductStackHistory

A Construct that contains a Service Catalog product stack with its previous deployments maintained.

Extends: Construct › ProductStackHistory
Implements: IConstruct, IDependable

- Source: [`aws-servicecatalog/lib/product-stack-history.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-servicecatalog/lib/product-stack-history.ts#L54)
- Type last changed: v2.196.0 · 16 May 2025

## Example

```ts
class S3BucketProduct extends servicecatalog.ProductStack {
  constructor(scope: Construct, id: string) {
    super(scope, id);

    new s3.Bucket(this, 'BucketProductV2');
  }
}

const productStackHistory = new servicecatalog.ProductStackHistory(this, 'ProductStackHistory', {
  productStack: new S3BucketProduct(this, 'S3BucketProduct'),
  currentVersionName: 'v2',
  currentVersionLocked: true
});

const product = new servicecatalog.CloudFormationProduct(this, 'MyFirstProduct', {
  productName: "My Product",
  owner: "Product Owner",
  productVersions: [
    productStackHistory.currentVersion(),
  ],
});
```

## Initializer

```ts
new ProductStackHistory(scope: Construct, id: string, props: ProductStackHistoryProps)
```

## Construct Props

- `currentVersionLocked`: boolean (required) — If this is set to true, the ProductStack will not be overwritten if a snapshot is found for the currentVersionName.

- `currentVersionName`: string (required) — The current version name of the ProductStack.

- `description`: string — The description of the product version.

  **Default:** No description provided

- `directory`: string = 'product-stack-snapshots' — The directory where template snapshots will be stored.

- `productStack`: [ProductStack](/cdk/api/v2/docs/aws-cdk-lib.aws_servicecatalog.ProductStack.html) (required) — The ProductStack whose history will be retained as a snapshot.

- `validateTemplate`: boolean = true — Whether the specified product template will be validated by CloudFormation.

  If turned off, an invalid template configuration can be stored.

## Properties

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

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

## Methods

- `currentVersion(): CloudFormationProductVersion` — Retains product stack template as a snapshot when deployed and retrieves a CloudFormationProductVersion for the current product version.

- `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`.

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

- `versionFromSnapshot(productVersionName: string): CloudFormationProductVersion` — Retrieves a CloudFormationProductVersion from a previously deployed productVersionName.

- `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.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
