AWS S3 Multi-region Access Points (MRAP) offer a single endpoint that can serve files from S3 buckets in different regions, optimized for latency and failing over in the event of a regional outage. As such, we're interested in using them for serving OPA bundles.
What is the underlying problem you're trying to solve?
For MRAPs to serve requests from multiple regions, the requests must be signed with AWS Signature Version 4a (SigV4a). Currently OPA only signs requests using AWS Signature V4.
AWS credentials retrieved from the global STS endpoint cannot be used for v4a; you must get credentials from a regional STS endpoint. I believe AWS SDKs are or have switched to default to regional endpoints, but this might need to be taken into account as well.
Describe the ideal solution
Ideally OPA would sign using V4 when hitting a service in a single region, such as a single S3 bucket, but then use V4a when requests could be made to a multi-region AWS service like MRAP. The docs on V4a are not great but it seems that the SDKs and algorithm can take a set of regions to sign for. This can be a list of 1+ regions, or *. So perhaps if the regions set is size 1, sign with V4 and sign with V4a if it has more than 1 or is *.
Describe a "Good Enough" solution
Alternatively, you could set the signing version to v4a in the OPA config, and it would set the region header to *.
Additional Context
It seems that OPA has its own implementation of v4 signing. Rather than reimplement v4a, I looked to see if the AWS go SDK could be used to sign requests. The aws-sdk-go-v2 does have a v4a signer, but it is under an internal package, and so not available. I opened an issue there to see if they could export it, but it doesn't appear that's going to happen anytime soon (aws/aws-sdk-go-v2#1935).
That repo does use the Apache 2 license, so it seems like that code could be copied into a public module somewhere and used by OPA, if that's deemed an acceptable course.
AWS S3 Multi-region Access Points (MRAP) offer a single endpoint that can serve files from S3 buckets in different regions, optimized for latency and failing over in the event of a regional outage. As such, we're interested in using them for serving OPA bundles.
What is the underlying problem you're trying to solve?
For MRAPs to serve requests from multiple regions, the requests must be signed with AWS Signature Version 4a (SigV4a). Currently OPA only signs requests using AWS Signature V4.
AWS credentials retrieved from the global STS endpoint cannot be used for v4a; you must get credentials from a regional STS endpoint. I believe AWS SDKs are or have switched to default to regional endpoints, but this might need to be taken into account as well.
Describe the ideal solution
Ideally OPA would sign using V4 when hitting a service in a single region, such as a single S3 bucket, but then use V4a when requests could be made to a multi-region AWS service like MRAP. The docs on V4a are not great but it seems that the SDKs and algorithm can take a set of regions to sign for. This can be a list of 1+ regions, or
*. So perhaps if the regions set is size 1, sign with V4 and sign with V4a if it has more than 1 or is*.Describe a "Good Enough" solution
Alternatively, you could set the signing version to v4a in the OPA config, and it would set the region header to
*.Additional Context
It seems that OPA has its own implementation of v4 signing. Rather than reimplement v4a, I looked to see if the AWS go SDK could be used to sign requests. The aws-sdk-go-v2 does have a v4a signer, but it is under an internal package, and so not available. I opened an issue there to see if they could export it, but it doesn't appear that's going to happen anytime soon (aws/aws-sdk-go-v2#1935).
That repo does use the Apache 2 license, so it seems like that code could be copied into a public module somewhere and used by OPA, if that's deemed an acceptable course.