Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Writing policies for testing Pulumi programs

An example of writing tests based on Policy as Code ("CrossGuard") with both infrastructure definition and tests written in TypeScript.

Prerequisites

  1. Install Pulumi
  2. Configure AWS credentials
  3. Install Node.js

Running the tests

The tests will run while Pulumi deploys the code, right before the deployment of each resource.

  1. Install dependencies:

    npm install
  2. Create a new stack, which is an isolated deployment target for this example:

    pulumi stack init
  3. Set the AWS region for this program:

    pulumi config set aws:region us-west-2
  4. Run pulumi up with the tests folder as the policy pack:

    pulumi up --policy-pack tests

    The preview displays that the Policy Pack will run:

    Policy Packs run:
    Name                Version
    tests-pack (tests)  (local)
    

    Confirm the preview with yes and watch the deployment happen with tests running in parallel. If a test fails, the deployment will stop.

  5. Tear down your stack's resources by destroying and removing it:

    pulumi destroy --yes
    pulumi stack rm --yes

Learn more

Learn more about testing Pulumi programs: