Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cloudfront: Credential should be scoped to a valid region

When connecting to AWS CloudFront via the API, no matter what I do, I get the Exception:

Credential should be scoped to a valid region

The same credentials work on any other request the account has permissions for, like S3.

like image 666
Chris Moschini Avatar asked Jul 07 '14 05:07

Chris Moschini


1 Answers

The Exception is caused by accessing CloudFront with any Region set other than "us-east-1". Because CloudFront is basically regionless, it requires you to use only the default region "us-east-1" to talk to it.

http://docs.aws.amazon.com/general/latest/gr/signature-v4-troubleshooting.html

You can workaround this by using the same credentials you use elsewhere but instantiate the CloudFront client with the Region explicitly set:

AmazonCloudFrontClient client = new AmazonCloudFrontClient(Amazon.RegionEndpoint.USEast1);

Which does beg the follow-on question: Why does the API not just do this for you?

Edit: Issue posted. https://github.com/aws/aws-sdk-net/issues/115

like image 84
Chris Moschini Avatar answered Nov 20 '22 10:11

Chris Moschini