Configuration Error: Missing Region In Config (AWS)
Answer :
The correct code of Oregon region is us-west-2
.You have set it as us-west-2a
in two places.
While mentioning identity pool id,correct the code as below and try:
AWS.config.update({region:'us-west-2'});
var myCredentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId:'us-west-2:"Identity Pool ID"'
});
If you are not passing the region for the API CognitoIdentityCredentials, then it will pull the data from AWS.config.
Also, In your code, while initializing AWS.CONFIG with region name, You have used us-west-2a
. Correct it, if you are going to use it instead of AWS.config.update.
var myConfig = new AWS.Config({
credentials: myCredentials, region: 'us-west-2'
});
Update
I have identified another issue. The issue is that, you are initializing the AWS.config with var myConfig = new AWS.Config()
but you are NOT updating the AWS.config class back with it. The missing code is : AWS.config = myConfig
.
As you are not updating it back and also you are not updating the existing default class using AWS.config.update({region:'us-west-2'});
as well, it throws the Missing region in config
error.
Correct Code snippet
var AWS = require('aws-sdk');
var myCredentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId:'us-west-2:identity-pool-id'
});
var myConfig = new AWS.Config({
credentials: myCredentials, region: 'us-west-2'
});
AWS.config = myConfig
Add region in your config like this:
AWS.config.update({
region: "REGION" //Here add you region
});
Please add it on the very top level (above the line var ec2 = new AWS.EC2();
)
Comments
Post a Comment