I'm trying to create a JSON object in Javascript using a variable key. The object specifically is a set of AWS credentials, but I don't think knowledge of AWS is required to answer my question. I have a function that looks like this:
var AWS = require('aws-sdk');
var config = require('./config.json');
var token = 'my_token';
var key = config.DEVELOPER_PROVIDER_NAME + '/' + config.USER_POOL_ID;
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId : config.IDENTITY_POOL_ID,
Logins : {
key : token
}
});
The idea is that AWS.CognitoIdentityCredentials
needs to be instantiated with the IdentityPoolId and Logins elements, but the Logins element is an object which requires a key which changes based on the values in the config file. The current syntax would create the Logins object with an element literally named "key". I need the key to be named based on the value of my variable key.