From b61b4a595b870d701b03d7ac220ada65548be576 Mon Sep 17 00:00:00 2001 From: Jackie Wang Date: Mon, 14 Nov 2022 14:50:20 -0500 Subject: [PATCH] Updated Integ Test with manual steps for provisioning asset product --- .../aws-servicecatalog/test/integ.product.ts | 72 ++++++++++++++++--- 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/packages/@aws-cdk/aws-servicecatalog/test/integ.product.ts b/packages/@aws-cdk/aws-servicecatalog/test/integ.product.ts index c9159dd85cf9b..7362b8885e53c 100644 --- a/packages/@aws-cdk/aws-servicecatalog/test/integ.product.ts +++ b/packages/@aws-cdk/aws-servicecatalog/test/integ.product.ts @@ -6,6 +6,59 @@ import * as cdk from '@aws-cdk/core'; import * as servicecatalog from '../lib'; import { ProductStackHistory, ProductStackProps } from '../lib'; +/** + * Follow these instructions to manually test provisioning a Product with an Asset with the resources provisioned in this stack: + * + * 1. Deploy the stack: + ``` + $ cdk deploy --app "node integ.product.js" integ-servicecatalog-product + ``` + * + * 2. Obtain IAM Principal ARN that will provision product. + One way this can be done is by using + ``` + $ aws sts get-caller-identity + ``` + * + * 3. Associate your principal to your portfolio. PortfolioId is stored as an output values from the deployed stack. + ``` + $ aws servicecatalog associate-principal-with-portfolio \ + --portfolio-id= \ + --principal-arn= \ + --principal-type=IAM + ``` + * + * 4. Provision Product using the following prefilled values. + ``` + $ aws servicecatalog provision-product \ + --provisioned-product-name=testAssetProvisioningProduct \ + --product-name=testProduct \ + --provisioning-artifact-name=testAssetProduct + ``` + * + * 5. Verify Provision Product was provisioned providing the ProvisionedProductId from the previous step. + ``` + $ aws servicecatalog describe-provisioned-product --id= + ``` + * + * 6. Terminate Provisioned Product providing the ProvisionedProductId from the previous step. + ``` + $ aws servicecatalog terminate-provisioned-product --provisioned-product-id= + ``` + * + * 7. Disassociate your principal from your portfolio. + ``` + $ aws servicecatalog disassociate-principal-with-portfolio \ + --portfolio-id= \ + --principal-arn= \ + ``` + * + * 8. Destroy the stack: + ``` + $ cdk destroy --app "node integ.product.js" integ-servicecatalog-product + ``` + */ + const app = new cdk.App(); const stack = new cdk.Stack(app, 'integ-servicecatalog-product'); @@ -17,6 +70,13 @@ class TestProductStack extends servicecatalog.ProductStack { } } +const portfolio = new servicecatalog.Portfolio(stack, 'TestPortfolio', { + displayName: 'TestPortfolio', + providerName: 'TestProvider', + description: 'This is our Service Catalog Portfolio', + messageLanguage: servicecatalog.MessageLanguage.EN, +}); + class TestAssetProductStack extends servicecatalog.ProductStack { constructor(scope: any, id: string, props?: ProductStackProps) { super(scope, id, props); @@ -30,7 +90,7 @@ class TestAssetProductStack extends servicecatalog.ProductStack { const productStackHistory = new ProductStackHistory(stack, 'ProductStackHistory', { productStack: new TestProductStack(stack, 'SNSTopicProduct3'), currentVersionName: 'v1', - currentVersionLocked: true, + currentVersionLocked: false, }); const testAssetBucket = new s3.Bucket(stack, 'TestAssetBucket', { @@ -61,6 +121,7 @@ const product = new servicecatalog.CloudFormationProduct(stack, 'TestProduct', { cloudFormationTemplate: servicecatalog.CloudFormationTemplate.fromProductStack(new TestProductStack(stack, 'SNSTopicProduct2')), }, { + productVersionName: 'testAssetProduct', validateTemplate: false, cloudFormationTemplate: servicecatalog.CloudFormationTemplate.fromProductStack(new TestAssetProductStack(stack, 'S3AssetProduct', { assetBucket: testAssetBucket, @@ -70,13 +131,8 @@ const product = new servicecatalog.CloudFormationProduct(stack, 'TestProduct', { ], }); -const tagOptions = new servicecatalog.TagOptions(stack, 'TagOptions', { - allowedValuesForTags: { - key1: ['value1', 'value2'], - key2: ['value1'], - }, -}); +portfolio.addProduct(product); -product.associateTagOptions(tagOptions); +new cdk.CfnOutput(stack, 'PortfolioId', { value: portfolio.portfolioId }); app.synth();