Skip to content
Closed
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Properties": {
"Name": "testProduct",
"Owner": "testOwner",
"ProductType": "CLOUD_FORMATION_TEMPLATE",
"ProvisioningArtifactParameters": [
{
"DisableTemplateValidation": true,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const product = new servicecatalog.CloudFormationProduct(stack, 'TestProduct', {
},
productStackHistory.currentVersion(),
],
productType: servicecatalog.ProductType.CLOUD_FORMATION_TEMPLATE,
});

new IntegTest(app, 'integ-product', {
Expand Down
33 changes: 33 additions & 0 deletions packages/aws-cdk-lib/aws-servicecatalog/lib/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@ import { IBucket } from '../../aws-s3';
import { ArnFormat, IResource, Resource, Stack } from '../../core';
import { addConstructMetadata } from '../../core/lib/metadata-resource';

/**
* The type of product
*/
export enum ProductType {
/**
* CloudFormation template
*/
CLOUD_FORMATION_TEMPLATE = 'CLOUD_FORMATION_TEMPLATE',
/**
* created by Amazon Web Services Marketplace
*/
MARKETPLACE = 'MARKETPLACE',
/**
* Terraform Open Source configuration file
*/
TERRAFORM_OPEN_SOURCE = 'TERRAFORM_OPEN_SOURCE',
/**
* Terraform Cloud configuration file
*/
TERRAFORM_CLOUD = 'TERRAFORM_CLOUD',
/**
* External configuration file
*/
EXTERNAL = 'EXTERNAL',
}

/**
* A Service Catalog product, currently only supports type CloudFormationProduct
*/
Expand Down Expand Up @@ -117,6 +143,12 @@ export interface CloudFormationProductProps {
*/
readonly distributor?: string;

/**
* The type of the product.
* @default - No type provided
*/
readonly productType?: ProductType;

/**
* Whether to give provisioning artifacts a new unique identifier when the product attributes or provisioning artifacts is updated
* @default false
Expand Down Expand Up @@ -201,6 +233,7 @@ export class CloudFormationProduct extends Product {
name: props.productName,
owner: props.owner,
provisioningArtifactParameters: this.renderProvisioningArtifacts(props),
productType: props.productType,
replaceProvisioningArtifacts: props.replaceProductVersionIds,
supportDescription: props.supportDescription,
supportEmail: props.supportEmail,
Expand Down
17 changes: 17 additions & 0 deletions packages/aws-cdk-lib/aws-servicecatalog/test/product.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,23 @@ describe('Product', () => {
expect(product.productArn).toEqual('arn:aws:catalog:region:account-id:product/prod-djh8932wr');
}),

test('configure the type of product', () => {
new servicecatalog.CloudFormationProduct(stack, 'MyProduct', {
productName: 'testProduct',
owner: 'testOwner',
productVersions: [
{
cloudFormationTemplate: servicecatalog.CloudFormationTemplate.fromUrl('https://awsdocs.s3.amazonaws.com/servicecatalog/development-environment.template'),
},
],
productType: servicecatalog.ProductType.TERRAFORM_OPEN_SOURCE,
});

Template.fromStack(stack).hasResourceProperties('AWS::ServiceCatalog::CloudFormationProduct', {
ProductType: 'TERRAFORM_OPEN_SOURCE',
});
});

test('fails product from attributes without resource name in arn', () => {
expect(() => {
servicecatalog.Product.fromProductArn(stack, 'MyProduct', 'arn:aws:catalog:region:account-id:product');
Expand Down
Loading