I've been trying to replace the existing LexBot Alias(named LATEST
) with a newly created bot version.
Now, according to aws documentation
When you want to update a bot alias, set the checksum field to the checksum of the most recent revision of the $LATEST version.
I can see the Alias LATEST
is using bot version 12
in the Lex Console.
I have tried getting the checksum using the following (I am using getBot(...)
of LexModelBuildingService to get checksum of the bot):
LATEST
.getBot
method params as '$LATEST'.12
in getBot(..)
.I have used checksum from the above scenarios, but the error seems to be same as
PreconditionFailedException: The checksum value doesn't match for the resource named 'LATEST'.
Here's code snippet
async putBotAlias(botVersionResponse){
let checksum;
await this.getBot(botVersionResponse.name,'12').then(botRes=>{ // have used 12, LATEST, $LATEST with same error
console.log("Checksum For Latest: " + botRes.checksum);
checksum = botRes.checksum;
});
var params = {
botName: botVersionResponse.name,
botVersion: (parseInt(botVersionResponse.version,10)).toString(),
name: 'LATEST',
checksum : checksum
};
// checksum: checksum
console.log("Params in putBotAlias : " + JSON.stringify(params));
return new Promise((resolve,reject)=>{
this.modelBuildingService.putBotAlias(params, function(err, data) {
if (err){
reject(err);
} // an error occurred
else{
console.log("Put Alias Response :::" + JSON.stringify(data));
resolve(data);
} // successful response
});
});
}
I am really at lost here as to what version exactly it wants.
Any help is greatly appreciated.
PS: Please mention any additional required information in comments.
Apparantly I was putting checksum of 'Bot' and not of the 'BotAlias' which I was trying to put.
Updated code gets the checksum of bot Alias :
async putBotAlias(botVersionResponse,aliasName){
let checksum;
if(typeof aliasName != "undefined"){
await this.getBotAlias(botVersionResponse.name,aliasName).then(res=>{
console.log("Checksum For Latest ALIAS : " + res.checksum);
checksum = res.checksum;
}).catch((err)=>{
console.log(" Unable to getBotAlias checksum " + err);
});
}
Silly mistake, but hope it helps anyone making it. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With