- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
- Security
Extending an AWS Governance Pipeline with a New Control
This challenge lab requires you to apply a repeatable governance pattern by implementing an additional automated control into an existing governance validation AWS CodePipeline pipeline. Throughout this lab, you will add an additional stage to your pipeline that will scan for secrets within an artifacts file. The focus is on demonstrating how the existing architectural footprint (CodePipeline and CodeBuild) can be safely extended to include new security and compliance checks, reinforcing a governance pattern without introducing new complexity. **Note**: Ensure that you read through the additional information and resources section.
Lab Info
Table of Contents
-
Challenge
Verify AWS resources were deployed and locally clone the repository files
Verify AWS resources were deployed and locally clone the repository files
- Clone and download the repository files for the lab from https://github.com/pluralsight-cloud/Path-Proactive-Security-in-Your-AWS-CI-CD-Pipeline/tree/main
- Verify the pre-existing resources were deployed in AWS with the lab folder (see the Additional Resources' Directory Tree):
- Amazon S3 bucket (Starts with governance-lab-artifacts-)
- AWS CodePipeline pipeline (governance-pipeline)
- The pipeline contains Source, GovernanceLint, GovernanceGuard, and Deploy stages to start.
- CloudFormation stack is deployed (governance-lab-deploy).
-
Challenge
Create the new CodeBuild buildspec file
You will now create the new required buildspec file for the upcoming GovernanceSecrets CodePipeline stage and respective CodeBuild project.
- Edit the
configuration/buildspec-secrets.ymlfile to be used with the new CodeBuild project containing the following phases:install: Install TruffleHog following instructions here > https://github.com/trufflesecurity/trufflehog#using-installation-scriptpre_build: Confirm TruffleHog was installed by checking the version.build: Scan all contents within the artifacts files for hardcoded secrets.- Hint: You need to specify a specific flag when scanning to cause the error output.
Important: You can find all TruffleHog documentation and instruction at the following GitHub page: https://github.com/trufflesecurity/trufflehog
- Edit the
-
Challenge
Create the new CodeBuild project
With the buildspec file ready to go, you can now create the CodeBuild project that will use it.
- Within CodeBuild, clone the existing governance-guard project:
- Name:
governance-secrets - Source > Source 1 - Primary: AWS CodePipeline
- Use a buildspec file:
configuration/buildspec-secrets.yml - Service role permissions - Existing service role: ARN containing governance-codebuild-role
- Name:
- Within CodeBuild, clone the existing governance-guard project:
-
Challenge
Create the new CodePipeline stage
Now you can create the code pipeline stage to reference the recently created CodeBuild project for your secrets scanning.
- Edit the existing governance-pipeline within AWS CodePipeline
- Add a new stage between the GovernanceLint and GovernanceGuard stages
- Name:
GovernanceSecrets
- Name:
- Add a new stage action
- Action name:
GovernanceSecretsAction - Action provider: Build > AWS CodeBuild
- Region: United States (N. Virginia)
- Input artifacts: GovernanceLintOutputs
- Project name: governance-secrets
- Output artifacts:
GovernanceSecretsOutputs
- Action name:
Then, you need to edit the GovernanceGuard stage's DeployAction
- Input artifacts: GovernanceSecretsOutputs
-
Challenge
Update the template and test the AWS CodePipeline pipeline
With all of the pieces in place, you can now move on to testing your pipeline.
- Generate a new set of IAM access keys for your current user.
- Add your newly created access keys to the following within your
infra/template.ymlfile:OUR_AWS_ACCESS_KEY_IDOUR_AWS_SECRET_ACCESS_KEY
- Create the new
artifacts.zipfile containing the required directories:infra/configuration/cfn-guard/
- Upload the
artifacts.zipfile to the Amazon S3 artifacts bucket in your account. - Wait for the pipeline to fail at the GovernanceSecrets stage
About the author
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.