Featured resource
2026 Tech Forecast
2026 Tech Forecast

1,500+ tech insiders, business leaders, and Pluralsight Authors share their predictions on what’s shifting fastest and how to stay ahead.

Download the forecast
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
    • Security
Google Cloud Platform icon
Labs

Validating IAM Policies as Automated Unit Tests

During this hands-on lab, you will build upon an existing AWS CodePipelien governance pipeline that contains linting stage for catching misconfigured CloudFormation templates. By integrating `cfn-guard` into an additional, separate governance stage, you will work to automate scanning against IAM policies with overly permissive policies that have been declared in your CloudFormation templates. **Important Information**: Please ensure that you read through the **Additional Information** section.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
May 30, 2026
Duration
30m

Contact sales

By clicking submit, you agree to our Privacy Policy and Terms of Use, and consent to receive marketing emails from Pluralsight.
Table of Contents
  1. Challenge

    Locally install cfn-guard

    The first thing you need to do is install CloudFormation Guard locally so that you can test it later on. To do this, you can download the pre-built binary for testing.

    • Navigate to AWS CloudShell.
    • Install Guard from a pre-built release binary (https://docs.aws.amazon.com/cfn-guard/latest/ug/setting-up-linux.html)
    • Set your path variable to include CloudFormation Guard.
    • Check the version of CloudFormation Guard to ensure that the tool is ready to go.
  2. Challenge

    Test cfn-guard locally

    Now that you've installed CloudFormation Guard locally to your CloudShell instance, you need to test it against a rule set and a template file.

    • Change to the ~/Path-Proactive-Security-in-Your-AWS-CI-CD-Pipeline/5-lab-validating-iam-policies-as-automated-unit-tests directory in AWS CloudShell.
    • Inspect the cfn-guard/iam-no-s3-wildcard.guard file.
    • Inspect the infra/template.yml CloudFormation file.
    • Validate the CloudFormation template against your cfn-guard rules using both provided templates.
    • Ensure there are no errors before moving on.
  3. Challenge

    Update the buildspec for the guard governance stage

    Your next step is to create a separate buildspec.yml file for a brand new governance stage that you'll add within your pipeline.

    • Inspect the configuration/buildspec-guard.yml file that will be used for the new stage.
    • Ensure there are three phases defined within the file.
      • install
      • pre_build
      • build
    • Recursively zip up the configuration, infra, and cfn-guard directories and their files into an artifacts.zip file.
  4. Challenge

    Test the AWS CodePipeline pipeline

    With all of the pipeline pieces in place, you can now upload your artifacts.zip file to test the pipeline runs successfully.

    • Upload the ZIP file to the Amazon S3 bucket from your AWS CloudShell window.
    • Verify the pipeline succeeds.
    • Inspect the logs for each stage within the pipeline.
  5. Challenge

    Create the new guard governance stage

    With the CodeBuild project ready to go, you can now integrate it into a brand new stage within the existing pipeline.

    • Edit the existing governance-pipeline pipeline: In the governance-pipeline pipeline, add a brand new stage called GovernanceGuard immediately after GovernanceLint
    • Add a new Add action group for the new stage:
      • Input artifacts: GovernanceLintOutputs
      • Project name: governance-guard existing CodeBuild project
      • Define buildspec override - optional: enabled and set to configuration/buildspec-guard.yml
      • Output artifacts: GovernanceGuardOutputs

    And, modify the Deploy stage as well:

    • Set Input artifacts to GovernanceGuardOutputs
    • Set Template > Artifact name to GovernanceGuardOutputs
  6. Challenge

    Create the new CodeBuild guard project

    Now that you have the guard policy rules set ready to go, and your buildpsec files ready, you need to create a new CodeBuild project as well as a new stage within your governance pipeline.

    • Clone the existing governance-lint AWS CodeBuild project and name it governance-guard.
    • For the Source 1 - Primary set it to AWS CodePipeline with no source version set.
    • Use the existing service role for the service role permissions (Example: arn:aws:iam::123456789876:role/governance-codebuild-role)
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight