Courseiva
DOP-C02Chapter 16 of 18Objective 6.1

Security and Compliance Fundamentals for DevOps

Security and compliance checks in CI/CD pipelines act as automated gatekeepers that prevent insecure code from reaching production. For the DOP-C02 exam, you need to understand how to design these gates so they catch problems early, without slowing down your team. This chapter explains the core concepts, common pitfalls, and exactly what AWS expects you to know.

12 min read
Intermediate
Updated Jul 23, 2026
Reviewed by Johnson Ajibi· Senior Network & Security Engineer · MSc IT Security

A simple way to picture Security and Compliance Fundamentals for DevOps

The 37-Point Airport Security Check Analogy

37 separate checkpoints exist between the airport car park and the departure gate. Each checkpoint checks one specific thing: your ticket, your passport, your boarding pass, your liquids bag, your laptop, your shoes, your coat, your belt, your phone charger, your hand luggage dimensions, your hand luggage weight, your hand luggage contents (no scissors over 6cm), your duty-free receipt, your visa, your vaccination certificate, your ESTA authorisation, your return ticket, your onward ticket, your hotel reservation, your travel insurance, your emergency contact, your frequent flyer number (for points), your seat assignment, your meal preference (allergy check), your wheelchair request, your pet carrier paperwork, your child travel consent form, your diplomatic passport status (if applicable), your airside transfer pass, your security badge (for staff), your ramp access permit, your aircraft maintenance log (for technicians), your fuel order confirmation, your catering invoice, your de-icing certificate, and your parking receipt for the crew bus.

In DevOps, a CI/CD pipeline functions identically: it runs dozens of automated security checks (checkpoints) against every single code change before that code can reach production (the departure gate). Each check is a specific, automated rule — scanning for hardcoded passwords, verifying encryption settings, confirming someone authorised reviewed the change, checking that third-party libraries have no known vulnerabilities. If any single checkpoint fails, the pipeline stops, just as TSA stops you from boarding if your liquids bag is too big. The entire system exists to ensure nothing unsafe slips through. Without it, deploying code is like boarding a plane with zero security screening — you have no idea what dangerous item might be in the overhead locker.

How It Actually Works

Security and compliance in a CI/CD pipeline means embedding automated checks at every stage of the software delivery process so that any code change — from a tiny bug fix to a giant new feature — must pass a series of security and policy requirements before it ever touches real users.

First, let us define the key pieces. CI/CD stands for Continuous Integration and Continuous Delivery (or Continuous Deployment). Think of CI as a robot that automatically tests every code change every time a developer saves their work. CD is the next step: automatically packaging that tested code and preparing it to be sent to production. A pipeline is the sequence of steps — like a factory assembly line — that code travels through: commit, build, test, scan, deploy.

Why does security matter here? Traditionally, security checks happened at the very end — someone from a separate security team would review the finished product right before release. This was slow, expensive, and meant problems were found too late. DevOps flips this: security moves left, meaning earlier in the process. Instead of one big security review at the end, there are many small, automated checks throughout the pipeline.

The exam objective 6.1 focuses on implementing these security controls. AWS services you need to know include AWS CodePipeline (the service that builds and runs your pipeline), AWS CodeBuild (which runs your tests and scans), AWS CodeCommit (for storing code), AWS CodeDeploy (for deploying to servers), and AWS CodeStar (a dashboard to manage it all). But the most important for security are AWS Identity and Access Management (IAM) and AWS Key Management Service (KMS), which control who can do what and how encryption keys are managed.

How does a security check work inside a pipeline? Imagine a developer named Priya writes a new feature and pushes her code to the repository (CodeCommit). This push automatically triggers the pipeline. The first stage might be 'Source', where the pipeline downloads her code. The second stage is 'Build' - CodeBuild compiles the code and runs unit tests. The third stage is 'Test', where a security scanning tool like Amazon Inspector or a third-party tool like Snyk checks the code for known vulnerabilities in open-source libraries. The fourth stage is 'Deploy' - but before deployment, a compliance check runs: a tool verifies that the code includes encryption settings that meet your company's policy (for example, all S3 buckets must have encryption enabled). If any check fails, the pipeline stops automatically and notifies Priya. No human needs to manually approve or reject the change.

This automation replaces the old process where a security engineer would manually review a change request form, check a few boxes, and hope nothing was missed. Now, the checks are consistent, repeatable, and happen every single time. This is called 'infrastructure as code' or 'security as code' — writing your security rules in a file (like JSON or YAML) that the pipeline reads and enforces.

AWS provides several tools specifically for compliance: AWS Config Rules can monitor whether resources comply with company policies. AWS CloudTrail logs every action taken in your AWS account. AWS Security Hub aggregates findings from multiple security tools. In a pipeline, you might use AWS Lambda functions as custom checkpoints — for example, a Lambda function that checks whether a code change introduces an unencrypted database.

Why does this matter for DOP-C02? The exam loves to test whether you understand the order of checks, how to handle failures, and how to set up IAM roles that grant the pipeline just enough permission to do its job (principle of least privilege). You will see questions about what happens when a pipeline fails a security check — the answer is almost always to stop and notify, not to skip or override.

Common patterns include: using a 'staging' environment that mirrors production but is isolated, running dynamic security tests (like fuzzing or penetration test scripts) against the staging environment, and using approval gates where a human must manually approve the deployment after automated checks pass. However, the exam emphasises automation over manual approval — the goal is to eliminate human bottlenecks while still enforcing strict rules.

This flowchart shows the key stages in a secure CI/CD pipeline: commit, build (SAST), test (DAST), compliance check, approval, and deploy to production.

Walk-Through

1

Commit stage: push code to repository

The developer pushes code to a branch in AWS CodeCommit. This triggers the pipeline automatically. Security occurs here by checking that the commit author has an active IAM user and that the commit message is present (a policy rule). The pipeline fetches the latest code version.

2

Build stage: compile and run SAST

CodeBuild compiles the code and runs a static analysis tool (e.g., SonarQube) that scans the source code for vulnerabilities like SQL injection, hardcoded secrets, or insecure cryptographic functions. If the tool finds a critical or high-severity issue, the build fails immediately.

3

Test stage: deploy to test environment and run DAST

The pipeline deploys the built application to a sandbox AWS environment (e.g., a separate VPC). It then runs dynamic testing (e.g., Amazon Inspector or OWASP ZAP) against the running application to find runtime vulnerabilities. It also runs integration tests that verify security headers and API authentication.

4

Compliance check stage: evaluate AWS Config rules

A Lambda function runs AWS Config API calls to check that the resources created by the pipeline (like EC2 instances, S3 buckets, RDS databases) comply with company policies (e.g., encryption enabled, public access blocked). If any resource is non-compliant, the pipeline halts.

5

Approval and deploy stage: deploy to production

After all automated checks pass, a final approval gate may exist — either automatically triggered by a Lambda function (if a time window is met) or requiring a human click. The pipeline then uses AWS CodeDeploy to push the code to production, ensuring zero-downtime deployment techniques (like blue/green or canary).

What This Looks Like on the Job

Imagine you work for a healthcare startup called 'MediFlow' that builds a patient appointment system. Your company must comply with HIPAA (a strict US healthcare privacy law) and wants to use AWS DevOps services. You are responsible for setting up the CI/CD pipeline.

Here is what you actually do, step by step:

First, you create a repository in AWS CodeCommit to store all the application code. You then create a pipeline in AWS CodePipeline with four stages: Source, Build, Test, and Deploy. In the Source stage, you configure the pipeline to trigger automatically whenever Priya pushes a new commit to the main branch.

In the Build stage, you use AWS CodeBuild to compile the Java code and run unit tests. You add a 'pre-build' command that runs a SAST (Static Application Security Testing) tool like SonarQube. SAST scans the source code itself — looking for patterns like SQL injection vulnerabilities or hardcoded API keys. You configure the build to fail if any critical-severity vulnerability is found.

In the Test stage, you deploy the built application to an isolated test environment (a separate AWS account or a dedicated VPC). Here, you run a DAST (Dynamic Application Security Testing) scan using Amazon Inspector, which tests the running application for vulnerabilities like open ports or weak SSL configurations. You also run a compliance check using AWS Config: you have created a custom AWS Config rule that checks whether any S3 bucket created by the pipeline has server-side encryption enabled. If a bucket lacks encryption, the Config rule marks it as non-compliant, and a Lambda function automatically stops the pipeline and sends a notification to your security team's Slack channel.

Before the Deploy stage, you add an approval step. However, because the exam favours automation, you set up a Lambda function that automatically approves deployment if all previous checks passed and if the deployment window is within business hours (to minimise risk). If the deployment is outside business hours, the pipeline waits for a human from the on-call team to manually approve via the AWS Management Console.

You also configure IAM roles with least privilege. The CodeBuild role has permission only to write to the specific S3 bucket used for build artifacts and to read from the specific ECR repository for container images. The role cannot list IAM users or delete CloudTrail logs — those actions are blocked.

When the pipeline runs, every single action is logged by AWS CloudTrail. You set up an AWS CloudWatch Events rule that triggers if a pipeline execution fails due to a security check — this sends an email to the security team and creates an incident ticket in Jira automatically.

Finally, you document the entire pipeline configuration as infrastructure as code using AWS CloudFormation, so that if a disaster strikes, you can recreate the entire setup in minutes in another AWS region. This approach ensures that every security check is repeatable, auditable, and consistent — no matter which developer is pushing code or what time of day it is.

How DOP-C02 Actually Tests This

The DOP-C02 exam tests Security and Compliance Fundamentals for DevOps primarily through scenario-based questions. You will be given a description of a company's pipeline and asked to identify the correct way to implement a specific security control or compliance check.

Key topics the exam loves:

Pipeline security stages: Understand the order of security checks — SAST (static analysis) happens during build, DAST (dynamic analysis) happens after deployment to a test environment, and compliance checks (like AWS Config rules) happen continuously or after deployment. The exam will try to trick you into running a DAST scan on source code (wrong) or running SAST on a running application (wrong).

Pre-deployment vs post-deployment checks: Some checks must happen before code reaches production (e.g., scanning for secrets). Others happen after deployment to production (e.g., monitoring for unusual API calls). The exam tests whether you know which belongs where.

IAM roles for pipelines: The principle of least privilege is crucial. The exam will present a scenario where a pipeline has an IAM role with overly broad permissions (e.g., 's3:*' instead of 's3:GetObject' on a specific bucket) and ask you to choose the minimum permissions required. The correct answer always narrows the scope to the specific actions and resources needed.

AWS CodePipeline approval gates: The exam tests whether you know the difference between 'manual approval' (a human must click Approve) and 'automated approval' (a Lambda function or a tool decides). The exam often presents a scenario where a manual approval gate is used unnecessarily, and you must choose to replace it with an automated check to speed up delivery.

Handling pipeline failures: Multiple-choice questions ask: 'What happens when a security check fails?' The correct answer is always 'The pipeline stops and the developer is notified'. Traps include 'the check is logged but deployment continues' (wrong) or 'the issue is ignored if it's low severity' (wrong).

Common compliance frameworks: You need to know that AWS Config can enforce rules from HIPAA, PCI DSS, and GDPR. The exam might ask you to select the AWS service that checks whether an S3 bucket is publicly accessible — that is AWS Config.

Question traps to watch for:

Confusing AWS CodeCommit with GitHub or Bitbucket — the exam is AWS-specific, so always choose the AWS service when offered.

Thinking that encryption checks can wait until after deployment — they must happen before or during deployment.

Believing that a pipeline can run only one security tool — in reality, you often chain multiple tools (SAST, DAST, dependency scanning, license compliance scanning, container image scanning).

Assuming that security checks are optional — the exam treats them as mandatory for production deployments.

Key definitions to memorise:

SAST: scans source code without executing it.

DAST: scans a running application by sending test inputs.

IAM role: an identity with specific permissions that a service (like CodeBuild) can assume.

AWS Config: a service that evaluates your AWS resources against desired configurations.

CloudTrail: records API activity in your account.

Compliance check: an automated rule that verifies a resource meets a policy requirement.

Least privilege: granting only the permissions necessary to perform a task.

The exam also tests nested scenarios: for example, a pipeline deploys a container to Amazon ECS. The security check must scan the container image for vulnerabilities (using Amazon ECR scanning or a third-party tool) before the pipeline allows the deployment to proceed. You need to know that image scanning is a pre-deployment check, not a post-deployment one.

Key Takeaways

Security checks in a CI/CD pipeline must be automated and run at every stage, from code commit to production deployment.

The principle of least privilege requires that every IAM role in the pipeline has only the permissions needed for its specific task.

Static application security testing (SAST) scans source code during the build stage, never on a running application.

Dynamic application security testing (DAST) scans a running application after it is deployed to a test environment.

AWS Config rules enforce compliance by evaluating resource configurations against defined policies, and can block pipelines via Lambda integration.

When a security check fails, the correct response is to stop the pipeline and notify the developer — never to ignore or manually override.

Third-party dependencies must be scanned for known vulnerabilities in every build, not just once during initial development.

Pre-deployment compliance checks must verify encryption, access controls, and logging settings before code reaches production.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

SAST (Static Application Security Testing)

Scans source code without executing it

Runs during the build stage of the pipeline

Finds vulnerabilities like hardcoded secrets and SQL injection patterns

DAST (Dynamic Application Security Testing)

Tests a running application by sending inputs

Runs after deployment to a test environment

Finds runtime issues like open ports and insecure headers

IAM Role (for pipeline)

Assumed by an AWS service (e.g., CodeBuild)

Permissions are temporary and scoped to the task

No login password or access keys stored long-term

IAM User (for human)

Used by a human to interact with AWS console or CLI

Permissions are long-lived unless rotated

Has static credentials that can be compromised

AWS Config Rule (compliance)

Evaluates current state of resources against a policy

Proactive: can block deployment if rule fails

Checks for encryption, public access, tagging, etc.

AWS CloudTrail (audit)

Records every API call made in the account

Reactive: logs what happened after the fact

Used for forensic analysis and incident response

Pre-deployment security check

Runs before code reaches production

Blockers: stops pipeline on failure

Examples: SAST, DAST, dependency scanning

Post-deployment monitoring

Runs after code is live in production

Alerting: sends notifications on suspicious activity

Examples: Amazon GuardDuty, AWS Security Hub alerts

Watch Out for These

Mistake

Security checks in a pipeline are only needed for the production deployment, not for test environments.

Correct

Security checks should run in every environment, including test and staging, because the same vulnerabilities could be introduced in any environment and then promoted to production.

Many beginners think that security only matters for the live customer-facing system, failing to realise that an insecure test environment can be used as a stepping stone to attack production.

Mistake

You can trust that third-party libraries used in your code are safe because they are from reputable sources.

Correct

Even reputable libraries can have undiscovered vulnerabilities, so you must scan all third-party dependencies with automated tools as part of your pipeline.

This misconception stems from a false sense of security. Beginners often assume that popularity equals safety, but supply-chain attacks are a real and growing threat.

Mistake

If a security check fails, you can manually override it and proceed with the deployment because you are in a hurry.

Correct

Automated checks should block the deployment until the issue is resolved; manual overrides defeat the purpose of security automation and introduce risk.

Beginners trained in traditional IT culture may be used to having a human 'approve' exceptions, but DevOps emphasises enforcing rules consistently through automation.

Mistake

AWS Config rules only apply to resources in the same AWS account as your pipeline.

Correct

AWS Config can evaluate resources across multiple AWS accounts using AWS Organizations and aggregated views, which is common in enterprise pipelines.

This misconception arises because many tutorials focus on single-account setups, but the exam tests multi-account architectures where pipelines cross account boundaries.

Mistake

Encryption is something you configure once and never need to check again because it is set at resource creation.

Correct

Encryption settings can be changed or misconfigured after creation, so you need continuous compliance checks (like AWS Config) to detect drifts from your security policy.

This mistake comes from a static view of infrastructure — beginners assume resources are immutable once created, but in reality, manual changes can silently break security.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between SAST and DAST in a CI/CD pipeline?

SAST (Static Application Security Testing) scans your source code without running it, finding vulnerabilities like insecure functions. DAST (Dynamic Application Security Testing) tests a running application by simulating attacks, finding issues like open ports or misconfigured headers. Both are needed because they find different types of flaws.

Do I need to scan third-party libraries every time I build?

Yes. New vulnerabilities are discovered daily in popular libraries. Scanning in every build ensures that even if a library was safe last week, any newly discovered vulnerability is caught before deployment. AWS CodeBuild can run tools like Snyk or OWASP Dependency-Check during the build stage.

How do I stop a pipeline if an AWS Config rule fails?

You configure an AWS Lambda function as a custom action in your pipeline. The Lambda function calls AWS Config to evaluate a specific rule (e.g., encryption enabled). If the evaluation returns 'non-compliant', the Lambda function fails the pipeline stage, which blocks further steps.

Can I use the same IAM role for the entire pipeline?

No. Each stage should use its own IAM role with the minimum permissions needed for that stage. For example, the build role might need access to source code and build artifacts, while the deploy role needs permissions to update EC2 instances. Following least privilege reduces risk.

What happens to my pipeline if a security check fails at 3 AM?

The pipeline stops automatically and sends a notification (via Amazon SNS) to the developer and security team. The deployment is blocked until a human fixes the issue and re-runs the pipeline. There is no automatic retry for security failures — they must be addressed manually.

Is it better to have manual approval or automated approval after security checks?

Automated approval is preferred because it eliminates human delay and potential errors. Manual approval should only be used when a regulation explicitly requires a human sign-off (e.g., for PCI DSS changes). The exam favours automation to speed up delivery while maintaining security.

Terms Worth Knowing

Keep going

You've finished Security and Compliance Fundamentals for DevOps. Continue through the DOP-C02 study guide to build a complete picture of the exam.

Done with this chapter?