Simple Lambda Function to approve CodePipeline action (Manual Approval). This can be used to have time-based auto-approval functionality in CodePipeline.
index.js is a Lambda function to be triggered by CloudWatch Scheduled Event. The Lambda function polls an SQS queue containing a CodePipeline Approval Notification. The lambda function approves the CodePipeline Approval event.
You can achieve time-based autoapproval by following these two steps:
Step 1:
CodePipeline -> Manual Approval -> SNS -> SQS
Step 2:
CloudWatch Scheduled Event -> Lambda -> Poll SQS -> Auto Approve CodePipeline
- Create a new Lambda Function
- Ensure IAM Role has two permissions: SQS Read and Delete messages, and CodePipeline Approval permission.
- Copy contents from index.js to Lambda function using AWS Lambda Inline Code Editor
- Add a CloudWatch Scheduled Event trigger to your Lambda Function (select the appropriate time window that you want your codepipeline stage to get auto-approved)