Skip to content

adds support for AWS KMS#1141

Open
ChrisJBurns wants to merge 12 commits intoocto-sts:mainfrom
ChrisJBurns:main
Open

adds support for AWS KMS#1141
ChrisJBurns wants to merge 12 commits intoocto-sts:mainfrom
ChrisJBurns:main

Conversation

@ChrisJBurns
Copy link

@ChrisJBurns ChrisJBurns commented Nov 16, 2025

Recreates #892

For some reason the underlying repo that had the original PR code was deleted. This PR restores that contribution because like others I would still very much be interested in hosting a version of the OctoSTS app on AWS using AWS KMS and Secrets Manager.

implements #438

Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
@ChrisJBurns
Copy link
Author

ChrisJBurns commented Nov 30, 2025

@cpanato @wlynch @wwsean08 @imjasonh @mattmoor Apologies for the ping once again on this, am aiming for AWS Support for Octo-STS as an early Christmas present 😆

@cpanato
Copy link
Collaborator

cpanato commented Dec 9, 2025

need a rebase

Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
@ChrisJBurns
Copy link
Author

@cpanato Thanks for the above, just rebased and reverted the copyright date back to 2024.

cpanato
cpanato previously approved these changes Dec 10, 2025
Copy link
Collaborator

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

lgtm

seems ok
thank you
would like to have another pair of 👀

@cpanato cpanato requested review from mattmoor and wlynch December 10, 2025 10:18
@ChrisJBurns
Copy link
Author

Amazing, thank you @cpanato much appreciated! 🚀

Copy link
Collaborator

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

Some minor comments, but overall looks good!

Comment on lines +55 to +76
// Set up the fake server.
impl := &fakeSecretManager{}
l, err := net.Listen("tcp", "localhost:0")
assert.NoError(t, err)

gsrv := grpc.NewServer()
secretmanagerpb.RegisterSecretManagerServiceServer(gsrv, impl)
fakeServerAddr := l.Addr().String()
go func() {
if err := gsrv.Serve(l); err != nil {
panic(err)
}
}()
defer gsrv.Stop()

// Create a client.
client, err := secretmanager.NewClient(ctx,
option.WithEndpoint(fakeServerAddr),
option.WithoutAuthentication(),
option.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
)
assert.NoError(t, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pull this into a func (use t.Cleanup instead of defer for closing the client)

Copy link
Author

Choose a reason for hiding this comment

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

addressed in commit 1a4be64

awsSecretManager *awsSM.Client
}

func (s *secretProvider) GetSecret(keyID string) ([]byte, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we plumb the context through here instead of embedding it in the struct?

We only do this for the signers in order to comply with the jwt.SigningMethod interface, but otherwise the preference would be to plumb the context through so it can be configured per-call.

Copy link
Author

Choose a reason for hiding this comment

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

Addressed in commit 44ccfcd

Comment on lines +66 to +69
// NewSigner returns a new signer for the provider.
func (p *Provider) NewSigner() (ghinstallation.Signer, error) {
return p, nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can delete this - this isn't really adding anything except proving *Provider implements Signer (which we could also do with var _ ghinstallation.Signer = &Provider{}

Copy link
Author

Choose a reason for hiding this comment

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

Addressed in commit 57d1b72

key string
}

func New(_ context.Context, client *kms.KeyManagementClient, key string) (ghinstallation.Signer, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if anyone is using this externally - keep the function signature in place as a wrapper around NewProvider (you probably need to add a NewProviderWithClient) and mark this as deprecated.

Copy link
Author

Choose a reason for hiding this comment

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

Addressed as part of 12bd48a

@ChrisJBurns
Copy link
Author

Much appreciated @wlynch ❤️ I'll get right on addressing the PR comments. Wondering if you had a chance to merge a fix for #892 (comment). As far as I know it still happened the last time I checked. I'll be trying it all again anyways with an updated version of OctoSTS incase there were fixes that were merged more recently that resolved it.

@ChrisJBurns
Copy link
Author

@wlynch I can confirm that I have got this working in AWS now! Not sure if the infinite-loop issue that was detailed in the original PR has been fixed on main or whether it was the fact that I disabled all events except for PR event and push events. Either way - it works!!

I'll get right on the addressing of PR comments above, in addition, I'm not sure if you'd like me to submit an "example" AWS Terraform setup using AWS ECS, Secrets Manager and KMS. I'm happy to do so, but it will obviously likely get outdated as time goes by and the Terraform modules/AWS APIs evolve.

Co-authored-by: Billy Lynch <1844673+wlynch@users.noreply.github.com>
Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
Co-authored-by: Billy Lynch <1844673+wlynch@users.noreply.github.com>
Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
@wlynch
Copy link
Collaborator

wlynch commented Dec 19, 2025

I haven't attempted again since #988 - I'll probably have some time over the break to look at this again though! Glad to hear it's working for you now though :)

…erServiceServer

Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
@ChrisJBurns
Copy link
Author

@wlynch No problems, I've just pushed up several commits that address your review comments, let me know what you think! - Happy Christmas 🎅

@jgrumboe
Copy link

Hi @ChrisJBurns
This PR is really great. I'm also looking into hosting the app on AWS.
Will you also update the IaC in the iac and modules/app folder?

@ChrisJBurns
Copy link
Author

@jgrumboe I can certainly submit an extra PR after this one if the folks at Chainguard are happy. However I feel it may get outdated as the Terraform and AWS APIs evolve, but maybe as an initial reference its ok.

Signed-off-by: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com>
@ChrisJBurns
Copy link
Author

Hey @wlynch, hope you had a great Christmas and New Year, any chance of a lil review of my new changes?

Copy link

@lf- lf- left a comment

Choose a reason for hiding this comment

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

A bit of absolutely non-blocking feedback: you can integration test the crypto of the AWS KMS using https://github.com/nsmithuk/local-kms if you'd like :)

I don't, however, think the code is especially possible to screw up, so integration tests aren't necessarily very critical. The reason I know a bit about this is because I just wrote another KMS integration, from which one might be able to borrow some ideas for such an integration test: indygreg/apple-platform-rs#274

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.

5 participants