An extra 30% off every course until Sunday, October 11.Choose your certification →

Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

2.1.2.5. Invoking AWS Services for Pipeline Testing

2.1.2.5. Invoking AWS Services for Pipeline Testing

CodePipeline stages can invoke multiple AWS services to run different types of tests. The key is knowing which action type to use for each testing scenario.

CodeBuild actions (most common): Use for unit tests, integration tests, linting, security scanning, and any custom test logic. CodeBuild runs your test commands in a container and reports pass/fail based on the exit code.

Lambda invoke actions: Use for lightweight validation — schema checks, configuration validation, approval notifications. Lambda actions pass a JSON payload and expect a success/failure callback to CodePipeline via putJobSuccessResult or putJobFailureResult.

# Lambda function for CodePipeline validation
import boto3

def handler(event, context):
    cp = boto3.client('codepipeline')
    job_id = event['CodePipeline.job']['id']
    
    try:
        # Your validation logic here
        validate_deployment_config()
        cp.put_job_success_result(jobId=job_id)
    except Exception as e:
        cp.put_job_failure_result(
            jobId=job_id,
            failureDetails={'message': str(e), 'type': 'JobFailed'}
        )

Step Functions actions: Use for complex test orchestration that requires branching, parallel execution, or human approval. Example: run integration tests in parallel across 3 regions, wait for all to pass, then proceed.

Manual approval actions: Require human sign-off before proceeding. The approver receives an SNS notification with a link to approve/reject. Use for production deployments, compliance gates, or after staging validation.

Exam Trap: A Lambda function runs for at most 15 minutes, and a Lambda invoke action times out if the function sends CodePipeline no reply for 20 minutes (a continuation token keeps a long job alive, up to 24 hours). For long validation, use a CodeBuild action (up to 36 hours) or Step Functions instead. Also, the Lambda function must call back to CodePipeline — if it doesn't, the pipeline stage hangs until it times out.

See how it connects
Alvin Varughese
Written byAlvin Varughese
Founder•20 professional certifications