Skip to content
New issue

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

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

Already on GitHub? # to your account

Let user provide full KMS Key ARN and update descriptions #1425

Merged
merged 9 commits into from
Feb 4, 2025

Conversation

toothbrush
Copy link
Contributor

Description

(this is yet another approach to #1422 and #1424 - pick the one you prefer 😅)

We have a use case where we want to have a single KMS key that Buildkite agents in multiple accounts can use to sign and verify pipeline steps. By letting the user specify the whole key ARN rather than just the key ID, the user is free to use a key wherever they want.

This third attempt has a different set of tradeoffs to the previous two:

Copy link
Contributor

@wolfeidau wolfeidau left a comment

Choose a reason for hiding this comment

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

I prefer this solution as it matches the behaviour of the KMS APIs which also take either an KMS Key ID or KMS Key ARN.

Comment on lines 1029 to 1032
- !If
- PipelineSigningKeyIsARN
- !Ref PipelineSigningKMSKeyId
- !Sub arn:aws:kms:${AWS::Region}:${AWS::AccountId}:key/${PipelineSigningKMSKeyId}
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't neccessary as the API call in the Agent can take either KMS Key identifer or ARN. So there is no need to do anything special for the ARN https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/kms#SignInput

And there is a precedent in the API for taking either in the same field, so you can remove the fancy ARN detection logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @wolfeidau, thanks for getting back to us. You are quite right that the agent will have no trouble accepting either the Key ID or full ARN format. We put this fancy conditional here because to specify a KMS key in an IAM policy statement, you must use its key ARN, that's my understanding of the documentation at least.

I'm definitely open to suggestions to simplify this stanza though.

Comment on lines 1470 to 1473
- !If
- PipelineSigningKeyIsARN
- !Ref PipelineSigningKMSKeyId
- !Sub arn:aws:kms:${AWS::Region}:${AWS::AccountId}:key/${PipelineSigningKMSKeyId}
Copy link
Contributor

Choose a reason for hiding this comment

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

As above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could remove the conditional here. Although given what is described in #1425 (comment), i still believe we'd need the PipelineSigningKeyIsARN check.

Slightly unrelated, but looking at the documentation at https://buildkite.com/docs/agent/v3/elastic-ci-aws/parameters#signed-pipelines-configuration i would suggest clarifying the exact format expected in PipelineSigningKMSKeyId. E.g., do not provide key/abcd-1234 but only abcd-1234 - that kind of thing.

@toothbrush
Copy link
Contributor Author

I've pushed f1d7439 and 9e6f34e – let me know if you think now.

@wolfeidau
Copy link
Contributor

@toothbrush this looks great, I will wait for this build to go green and then merge it.

I will work with the team to update the documentation as you suggested as well.

Thanks for bearing with us.

@wolfeidau wolfeidau enabled auto-merge February 4, 2025 05:56
@wolfeidau wolfeidau changed the title Let user provide full KMS Key ARN, take 3 Let user provide full KMS Key ARN and update descriptions Feb 4, 2025
@wolfeidau wolfeidau merged commit ad62d68 into buildkite:main Feb 4, 2025
1 check passed
@wolfeidau
Copy link
Contributor

@toothbrush this change can be tested using refs/pull/1425/head/aws-stack.yml if you were interested in sanity checking.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants