BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeAWS Certified DevOps Engineer - Professional (DOP-C02)Hands-On Lab: Implementing Multi-Stage CI/CD Pipelines with AWS CodePipeline
Hands-On Lab1,050 words

Hands-On Lab: Implementing Multi-Stage CI/CD Pipelines with AWS CodePipeline

Implement CI/CD pipelines

Hands-On Lab: Implementing Multi-Stage CI/CD Pipelines with AWS CodePipeline

In this lab, you will architect and deploy a fully automated Continuous Integration and Continuous Delivery (CI/CD) pipeline. Following the AWS Certified DevOps Engineer - Professional curriculum, you will integrate source control, automated builds, and a manual approval gate before a simulated deployment.

[!WARNING] Remember to run the teardown commands at the end of this lab to avoid ongoing charges. AWS CodePipeline charges $1.00 per active pipeline per month after the first 30 days.

Prerequisites

  • AWS Account: An active AWS account with Administrator access.
  • AWS CLI: Installed and configured with aws configure using your credentials.
  • Region: This lab uses <YOUR_REGION> (e.g., us-east-1).
  • IAM Knowledge: Basic understanding of IAM roles and service-linked roles.

Learning Objectives

  • Configure an Amazon S3 source provider for versioned artifacts.
  • Orchestrate a build process using AWS CodeBuild.
  • Implement a Manual Approval stage to enforce governance.
  • Manage and inspect pipeline Artifacts stored in S3.

Architecture Overview

The following diagram illustrates the flow of code from source to manual approval.

Loading Diagram...
Figure 1 — Mermaid diagram
Compiling TikZ diagram…
⏳
Running TeX engine…
This may take a few seconds
Figure 2 — TikZ diagram

Step-by-Step Instructions

Step 1: Create the Source and Artifact Buckets

CodePipeline requires versioned S3 buckets to detect changes and store intermediate artifacts.

bash
# Create the source bucket aws s3 mb s3://brainybee-lab-source-<YOUR_ACCOUNT_ID> # Enable versioning (REQUIRED for CodePipeline S3 sources) aws s3api put-bucket-versioning --bucket brainybee-lab-source-<YOUR_ACCOUNT_ID> --versioning-configuration Status=Enabled
▶Console alternative
  1. Navigate to S3 > Create bucket.
  2. Name: brainybee-lab-source-<YOUR_ACCOUNT_ID>.
  3. Under Bucket Versioning, select Enable.
  4. Click Create bucket.

Step 2: Prepare the Source Artifact

You need a buildspec.yml file to tell CodeBuild how to handle your code.

  1. Create a file named index.html with simple text: <h1>Hello DevOps Pro!</h1>.
  2. Create a file named buildspec.yml with the following content:
yaml
version: 0.2 phases: build: commands: - echo Build started on `date` - cp index.html output.html artifacts: files: - output.html
  1. Zip these files and upload them to your source bucket:
bash
zip source.zip index.html buildspec.yml aws s3 cp source.zip s3://brainybee-lab-source-<YOUR_ACCOUNT_ID>/source.zip

Step 3: Create the CodeBuild Project

CodeBuild will take your source.zip, read the buildspec.yml, and generate an output artifact.

bash
# Note: In a real scenario, you'd create an IAM role first. # For this lab, assume a role named 'CodeBuildServiceRole' exists. aws codebuild create-project --name "BrainyBee-Build" \ --source "type=S3,location=brainybee-lab-source-<YOUR_ACCOUNT_ID>/source.zip" \ --artifacts "type=NO_ARTIFACTS" \ --environment "computeType=BUILD_GENERAL1_SMALL,image=aws/codebuild/standard:5.0,type=LINUX_CONTAINER" \ --service-role "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/service-role/CodeBuildServiceRole"

[!TIP] If you don't have an IAM role ready, use the Console alternative below as it creates the service role automatically.

▶Console alternative
  1. Go to CodeBuild > Create build project.
  2. Project name: BrainyBee-Build.
  3. Source provider: Amazon S3.
  4. Bucket: brainybee-lab-source-<YOUR_ACCOUNT_ID>, S3 object: source.zip.
  5. Environment: Managed image, Ubuntu, Standard runtime, Image: aws/codebuild/standard:5.0.
  6. Service role: New service role.
  7. Click Create build project.

Step 4: Create the Pipeline

Now, connect the Source and Build stages using CodePipeline.

▶Console Instructions (Recommended for Pipeline Creation)
  1. Navigate to CodePipeline > Create pipeline.
  2. Name: BrainyBee-Pipeline.
  3. Source Stage: Provider: Amazon S3. Bucket: your source bucket. S3 object key: source.zip. Change detection: AWS CloudWatch Events.
  4. Build Stage: Provider: AWS CodeBuild. Project name: BrainyBee-Build.
  5. Deploy Stage: Click Skip deploy stage (we will add a manual approval instead).
  6. Review and Create pipeline.

Step 5: Add a Manual Approval Stage

  1. In the CodePipeline console, select your pipeline and click Edit.
  2. Click + Add stage at the end of the pipeline. Name it Approval.
  3. Click + Add action group.
  4. Action name: Manager-Approval. Action provider: Manual approval.
  5. Click Done and then Save.

Checkpoints

Verification TaskExpected Result
Source CheckPipeline status changes to "In Progress" immediately after uploading source.zip.
Build CheckCodeBuild status shows "Succeeded" and output.html is created in the artifact S3 bucket.
Approval CheckPipeline stops at the Approval stage, status is "Waiting for approval".

Troubleshooting

ErrorCauseFix
The bucket does not have versioning enabledCodePipeline requires versioning for S3 sources.Run the put-bucket-versioning CLI command provided in Step 1.
AccessDenied in CodeBuildThe CodeBuild service role lacks S3 permissions.Attach AmazonS3ReadOnlyAccess to the IAM role.
Buildspec file does not existThe zip file structure is nested or the filename is wrong.Ensure buildspec.yml is in the root of the source.zip file.

Challenge

Add a Unit Test Stage: Modify your pipeline to include a second CodeBuild project called BrainyBee-Test. This project should run a simple shell script to verify the content of output.html (e.g., grep "Hello" output.html). Insert this stage between Build and Approval.

Teardown

To avoid costs, delete all resources created:

bash
# Delete the Pipeline aws codepipeline delete-pipeline --name BrainyBee-Pipeline # Delete the Build Project aws codebuild delete-project --name BrainyBee-Build # Empty and Delete S3 Buckets aws s3 rb s3://brainybee-lab-source-<YOUR_ACCOUNT_ID> --force # Note: Delete the artifact bucket created by CodePipeline as well (usually named codepipeline-<region>-...)

Cost Estimate

ServiceEstimated Cost (Monthly)
AWS CodePipeline$1.00 per active pipeline (Free tier: 1 free pipeline per month)
AWS CodeBuild$0.005 per build minute (Free tier: 100 minutes of build.general1.small)
Amazon S3$0.023 per GB (Negligible for this lab)

Concept Review

Pipeline Concepts vs. DevOps Professional Exam

TermDefinitionExam Context
RevisionA specific change in the source.Triggers the pipeline execution.
Action TypeOne of 6 types: Source, Build, Test, Deploy, Approval, Invoke.You must choose the right type for custom Lambda integrations.
ArtifactsFiles passed between stages.Stored in S3; encrypted by KMS by default.
TransitionsLinks between stages.Can be disabled to stop automated flow (e.g., during a maintenance window).
All AWS Certified DevOps Engineer - Professional (DOP-C02) Study Resources

Related Notes

  • AWS Certified DevOps Engineer Professional: Implementing CI/CD Pipelines1,150 words
  • Mastering AWS Alerting and Automated Remediation1,050 words
  • Study Guide: Analyzing Failed Deployments in AWS940 words
  • Incident Analysis: Troubleshooting Failed Processes in AWS1,050 words
  • Mastering AWS Monitoring & Security Analytics: Logs, Metrics, and Findings1,050 words
  • AWS Log Analysis: Athena, CloudWatch Insights, and OpenSearch920 words
  • Analyzing Real-Time Log Streams with Amazon Kinesis Data Streams985 words
  • CloudWatch Anomaly Detection Alarms: Professional Study Guide820 words
  • AWS Application Storage Patterns: EBS, EFS, and S31,054 words
  • Lab: Automating Security Controls and Data Protection with AWS Secrets Manager and Config942 words
  • Master Study Guide: Automating Security Controls & Data Protection (AWS DOP-C02)1,184 words
  • Mastering AWS CloudFormation StackSets: Multi-Account & Multi-Region Orchestration895 words

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up.

Start Studying

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free
AWS Certified DevOps Engineer - Professional (DOP-C02) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.

Loading Diagram...
Flowchart, left to right. Source: S3 Bucket connects to CodePipeline (Trigger). P connects to Build: CodeBuild. B connects to Manual Approval. A connects to Deploy: Simulated. P connects to S3 Bucket.