AWS Service Catalog Validation Pipeline
AWS Service Catalog Validation Pipeline

Appendix B: Custom Testing

To add a custom test to the validation pipeline, first add it to the Central Microservices template (central-microservices-sc.template) and then reference it in the Main Pipeline template (main-sc-pipeline.template) as follows.


The AWS Service Catalog Validation Pipeline provides a framework for tests run using AWS Lambda functions, however you can create custom tests using any technology that integrates with AWS CodePipeline actions. See Integrations with AWS CodePipeline Action Types for detailed information.

  1. In the Main Pipeline template, find the section for the AWS CodePipeline resource.

  2. Under Properties > Stages > Pre/PostCreateTests, add the new test Action, as applicable. The action should point to an existing AWS Lambda function or other test script.

  3. For a new pre-create test (PreCreateTests), set the InputArtifact to TemplateArtifact.

    For a new post-create test (PostCreateTests), set the InputArtifact to StackArtifact.

  4. The solution includes a class library (cfnpipeline) that you can reference in custom test actions (see the Validate_Template and Subnet_Name functions as examples). If you call this library, the action’s UserParameters should be valid JSON and include the following JSON key pairs:

    PreCreate: "UserParameters": { "Fn::Sub": [ "{ \"CleanupPrevious\": \"${CleanupPrevious}\", \"CleanupNonFailed\": \"${CleanupNonFailed}\", \"CleanupFailed\": \"${CleanupFailed}\", \"CITestPath\": \"${CITestPath}\", \"ScratchBucket\": \"${ScratchBucket}\", \"StackCreationRoleArn\": \"${StackCreationRoleArn}\", \"KeyBucket\": \"${KeyBucket}\" }", { "CITestPath": { "Fn::FindInMap": [ "General", "CIConfig", "CITestPath" ] } } ] } PostCreate: "UserParameters": { "Fn::Sub": [ "{ \"CITestPath\": \"${CITestPath}\", \"ScratchBucket\": \"${ScratchBucket}\" }", { "CITestPath": { "Fn::FindInMap": [ "General", "CIConfig", "CITestPath" ] } } ] }