Skip to content

(aws-scheduler-targets-alpha): Add CodeBuildStartBuild Target #27448

@filletofish

Description

@filletofish

Describe the feature

Work to support L2 constructs for AWS Scheduler is in progress (#23394). See the approved RFC. RFC planned to add 12 templates targets, but only Lambda Invoke is currently implemented (#26575).

This issue tracks implementation of CodeBuildStartBuild target to start an AWS CodeBuild build.

Use Case

Customers would like to use templated target CodeBuildStartBuild to be able to start AWS CodeBuild build on schedule. L2 target construct should grant required permissions to the scheduler to start the CodeBuild.

Proposed Solution

The proposed solution needs to be adopted to the recent examples of LambdaInvoke (https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-scheduler-targets-alpha/lib/lambda-invoke.ts).

Solution should also include unit and integration tests.

export class CodeBuildStartBuild extends ScheduleTargetBase implements IScheduleTarget {
    constructor(
      private readonly project: codebuild.IProject,
      private readonly props: ScheduleTargetBaseProps,
    ) {
      super(props, project.projectArn)
    }

    protected addTargetActionToRole(schedule: ISchedule, role: IRole): void {
      // TODO: Check if target and schedule are in the same account and region
      // TODO: Check if target and role are in the same account

     // TODO: Check if L2 grant methods can be used
      role.addToPrincipalPolicy(new iam.PolicyStatement({
        actions: ['codebuild:StartBuild'],
        resources: [this.project.projectArn],
      }));
    }
  }

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.99.1

Environment details (OS name and version, etc.)

MacOs

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-schedulerRelated to the AWS Scheduler service@aws-cdk/aws-scheduler-targetsRelated to targets of the AWS Scheduler serviceeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions