How to add an API key to your usage plan in AWS Getaway API

I had a problem creating an API key associated with the AWS Getaway API usage plan (using the AWS SDK for node.js).

In the AWS Console, you can attach the API key to the usage plan with this button: enter image description here

However, I could not find a similar feature in the AWS SDK Documentation

+5
source share
1 answer

This code does the magic:

var params = { keyId: 'STRING_VALUE', /* required */ keyType: 'STRING_VALUE', /* required */ usagePlanId: 'STRING_VALUE' /* required */ }; apigateway.createUsagePlanKey(params, function(err, data) { if (err) console.log(err, err.stack); // an error occurred else console.log(data); // successful response }); 

What I was missing was that keyType should be "API_KEY"

+5
source

Source: https://habr.com/ru/post/1260922/


All Articles