# (c) 2022 Amazon Web Services, Inc. or its affiliates. All Rights Reserved. This AWS Content is provided subject to the terms of the AWS Customer # Agreement available at https://aws.amazon.com/agreement/ or other written agreement between Customer and Amazon Web Services, Inc. AWSTemplateFormatVersion: '2010-09-09' Description: 'Creates a Service Catalog Product and assigns it to a portfolio' Parameters: PortfolioId: Description: PortfolioId for the product Type: String AllowedPattern: ".+" ConstraintDescription: "This is a required parameter" ProductOwner: Description: The owner of the product Type: String AllowedPattern: ".+" ConstraintDescription: "This is a required parameter" ProductDescription: Description: A description of the product Type: String AllowedPattern: ".+" ConstraintDescription: "This is a required parameter" VersionDescription: Description: A Description of the product version Type: String AllowedPattern: ".+" ConstraintDescription: "This is a required parameter" ProductName: Description: Name of the Service Catalog Product Type: String AllowedPattern: ".+" ConstraintDescription: "This is a required parameter" ProductUrl: Description: The S3 Url of the template Type: String AllowedPattern: ".+" ConstraintDescription: "This is a required parameter" ServiceCatalogRoleName: Description: The name of the role used by Service Catalog to deploy a product Type: String AllowedPattern: ".+" ConstraintDescription: "This is a required parameter" Resources: #Ugly hack: on create, LaunchRoleConstraint is started before the #ProductId is available. #This forces a 20 second sleep before the LaunchRoleConstraint creation #process is called based on the DependsOn WaitForProduct: Type: 'AWS::CloudFormation::CustomResource' Properties: DependsOn: ServiceCatalogPortfolioProductAssociation ServiceToken: !ImportValue CFNSleep SleepSeconds: 30 LaunchRoleConstraint: Type: AWS::ServiceCatalog::LaunchRoleConstraint DependsOn: - WaitForProduct Properties: LocalRoleName: !Ref ServiceCatalogRoleName PortfolioId: !Ref PortfolioId ProductId: !Ref 'ServiceCatalogCloudFormationProduct' ServiceCatalogCloudFormationProduct: Type: "AWS::ServiceCatalog::CloudFormationProduct" Properties: Name: !Ref 'ProductName' Description: !Ref ProductDescription Owner: !Ref ProductOwner ProvisioningArtifactParameters: - Name: !Sub '${VersionDescription}' Info: LoadTemplateFromURL: !Ref ProductUrl ServiceCatalogPortfolioProductAssociation: Type: "AWS::ServiceCatalog::PortfolioProductAssociation" Properties: PortfolioId: !Ref PortfolioId ProductId: !Ref 'ServiceCatalogCloudFormationProduct' Outputs: ServiceCatalogPortfolioId: Value: !Ref PortfolioId ServiceCatalogProductId: Value: !Ref ServiceCatalogCloudFormationProduct