-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addressed comments and created ProductStackHistory
- Loading branch information
Showing
17 changed files
with
290 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
*.d.ts | ||
tsconfig.json | ||
node_modules | ||
product-stack-snapshots | ||
*.generated.ts | ||
dist | ||
.jsii | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
packages/@aws-cdk/aws-servicecatalog/lib/product-stack-history.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { Construct } from 'constructs'; | ||
import { CloudFormationTemplate } from './cloudformation-template'; | ||
import { CloudFormationProductVersion } from './product'; | ||
import { ProductStack } from './product-stack'; | ||
|
||
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main | ||
// eslint-disable-next-line no-duplicate-imports, import/order | ||
import { Construct as CoreConstruct } from '@aws-cdk/core'; | ||
|
||
/** | ||
* Properties for a ProductStackHistory. | ||
*/ | ||
export interface ProductStackHistoryProps { | ||
/** | ||
* The base Product Stack. | ||
*/ | ||
readonly productStack: ProductStack; | ||
/** | ||
* The current version name of the ProductStack. | ||
*/ | ||
readonly currentVersionName: string; | ||
/** | ||
* If this is set to true, the ProductStack will not be overwritten if a snapshot is found for the currentVersionName. | ||
*/ | ||
readonly locked: boolean | ||
/** | ||
* The description of the product version | ||
* @default - No description provided | ||
*/ | ||
readonly description?: string; | ||
/** | ||
* Whether the specified product template will be validated by CloudFormation. | ||
* If turned off, an invalid template configuration can be stored. | ||
* @default true | ||
*/ | ||
readonly validateTemplate?: boolean; | ||
/** | ||
* The directory where template snapshots will be stored | ||
* @default - product-stack-snapshots | ||
*/ | ||
readonly directory?: string | ||
} | ||
|
||
/** | ||
* A Construct that contains a Service Catalog product stack with its previous deployments maintained. | ||
*/ | ||
export class ProductStackHistory extends CoreConstruct { | ||
private readonly props: ProductStackHistoryProps | ||
constructor(scope: Construct, id: string, props: ProductStackHistoryProps) { | ||
super(scope, id); | ||
this.props = props; | ||
} | ||
|
||
/** | ||
* Retains product stack template as a snapshot when deployed and | ||
* retrieves a CloudFormationProductVersion for the current product version. | ||
*/ | ||
public currentVersion() : CloudFormationProductVersion { | ||
return { | ||
cloudFormationTemplate: CloudFormationTemplate.fromProductStackHistory( | ||
this.props.productStack, this.props.locked, this.props.directory), | ||
productVersionName: this.props.currentVersionName, | ||
description: this.props.description, | ||
}; | ||
} | ||
|
||
/** | ||
* Retrieves a CloudFormationProductVersion from a previously deployed productVersionName. | ||
*/ | ||
public versionFromSnapshot(versionName: string) : CloudFormationProductVersion { | ||
return { | ||
cloudFormationTemplate: CloudFormationTemplate.fromProductStackSnapshot( | ||
this.props.productStack, this.props.directory), | ||
productVersionName: versionName, | ||
description: this.props.description, | ||
}; | ||
} | ||
} |
Oops, something went wrong.