Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose service role to allow custom codebuild role for shellables #1476

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

colifran
Copy link
Contributor

This PR exposes the underlying role property used to specify a role to be used by the CodeBuild project created as part of creating a new Shellable


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

/**
* The service role to assume while running the build
*
* @default A role will be created
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is "a role will be created" happening?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens in the codebuild Project class - it's the behavior that happens currently. See: https://github.com/aws/aws-cdk/blob/8557c40ce3efb16cb6c6f4677540d38853937166/packages/aws-cdk-lib/aws-codebuild/lib/project.ts#L1045

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right. Okay, so the game plan is to send in our own serviceRole with similar permissions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. It would look something like this:

private addSigning() {
    const signingBucket = Bucket.fromBucketArn(this, 'SigningBucket', config.signingBucketArn);
    const signingLambda = Function.fromFunctionArn(this, 'SigningFunction', config.signingLambdaArn);
    const accessRole = Role.fromRoleArn(this, 'AccessRole', config.signingAccessRoleArn);
    const serviceRole = new Role(this, 'SeviceRole', {
      roleName: 'signing-codebuild-role',
      assumedBy: new ServicePrincipal('codebuild.amazonaws.com'),
    });
    serviceRole.addToPolicy(new PolicyStatement({
      actions: ['sts:AssumeRole'],
      resources: [accessRole.roleArn],
    }));

    this.pipeline.signNuGetWithSigner({
      signingBucket,
      signingLambda,
      accessRole,
      serviceRole,
    });
  }

@mergify mergify bot merged commit cd46efa into main Oct 12, 2023
7 checks passed
@mergify mergify bot deleted the colifran/service-role branch October 12, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants