Cron Trigger CLI

0

I am working on creating our entire CodeBuild environment through the CLI
It looks like it is not currently possible to create Cron triggers through the CLI and those have to be created via the console?
If this is correct, is this going to change?

jonwis
asked 5 years ago256 views
1 Answer
0
Accepted Answer

CodeBuild build triggers are simply CloudWatch event rules.

When creating build triggers through the console, what is actually being created is a CloudWatch event rule. You can create CloudWatch event rules using the CLI, for example:

aws events put-rule \
    --name run-codebuild \
    --schedule-expression 'rate(1 hour)' \
    --role-arn arn:aws:iam::000000000000:role/service-role/AWS_Events_Invoke_CodeBuild_124052220
                            
aws events put-targets \
    --rule run-codebuild \
    --targets '
[
    {
        "Id": "some_id",
        "Arn": "arn:aws:codebuild:us-east-1:000000000000:project/some-codebuild-project",
        "RoleArn": "arn:aws:iam::000000000000:role/service-role/codebuild-some-codebuild-project-service-role"
    }
]
'

If the CW event rule is associated with a CodeBuild project, that event rule will show up under the project's build triggers.

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions