Skip to content

Any way to add a custom header to a presigned sts:GetCallerIdentity request? #1789

Answered by nklaassen
nklaassen asked this question in Q&A
Discussion options

You must be logged in to vote

Oh it turns out you can use a custom EndpointResolverV2, or add a Serializer to the middleware stack. I need a custom endpoint resolver anyway, so doing it like this.

type customResolver struct {
	defaultResolver sts.EndpointResolverV2
	challenge       string
}

func newCustomResolver(challenge string) *customResolver {
	return &customResolver{
		defaultResolver: sts.NewDefaultEndpointResolverV2(),
		challenge:       challenge,
	}
}

func (r customResolver) ResolveEndpoint(ctx context.Context, params sts.EndpointParameters) (smithyendpoints.Endpoint, error) {
	endpoint, err := r.defaultResolver.ResolveEndpoint(ctx, params)
	if err != nil {
		return endpoint, err
	}
	endpoint.Headers.Add(c…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@nklaassen
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by nklaassen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants