user389955
user389955

Reputation: 10467

How to use AWS CodePipeline to control scheduled EC2

I have created an AWS codepipeline to deploy code to EC2. the codepipeline has stages including source (from s3), codedeploy_to_test, approval, codedeploy_to_prod, etc. but the EC2 to be deployed only run a few hours like 7am-9pm every day. They stop at other time.

The codepipeline is started by a cloudwatch whenever code is committed to the s3.

How do I enhance the codepipeline so that it deploys code to the EC2 only btw. 7am-9pm, Other time it waits or ignores the change of source(s3)?

I am thinking maybe I can do sth. before each codedeploy so that if the time is 7am-9pm, go ahead, otherwise, do nothing. but I do not know what I can do to achieve that.

Upvotes: 1

Views: 400

Answers (1)

TimB
TimB

Reputation: 1577

CodePipeline does not currently have built-in support for this, however it's possible to use a Lambda function combined with either an approval actions or stage transitions to do this.

Here's an example of a Lambda function which will automatically approve a manual approval action during certain hours: https://github.com/aws-samples/aws-codepipeline-time-windows

Upvotes: 2

Related Questions