Tools and a get-dotenv plugin for working with AWS API Gateway (REST APIs), including stage cache flush and API key retrieval.
This package provides:
AwsApiGatewayToolsaws:
apiGatewayPlugin() → aws api-gateway flush-cache|pull-keysaws-api-gateway-toolsnpm i @karmaniverous/aws-api-gateway-tools
This package is ESM-only (Node >= 20).
import { AwsApiGatewayTools } from '@karmaniverous/aws-api-gateway-tools';
const tools = new AwsApiGatewayTools({
clientConfig: { region: 'us-east-1', logger: console },
xray: 'auto',
});
await tools.flushStageCache({ restApiId: 'abc123', stageName: 'dev' });
When you need AWS functionality not wrapped by this package, use the fully configured AWS SDK v3 client at tools.client (see the programmatic guide for examples).
aws-api-gateway-tools aws api-gateway flush-cache
aws-api-gateway-tools aws api-gateway pull-keys --key-names '$API_KEY_A' '$API_KEY_B'
Notes:
$VAR expansion evaluated at action time against { ...process.env, ...ctx.dotenv } (ctx.dotenv wins).X-Ray support is guarded:
xray: 'auto': capture is enabled only when AWS_XRAY_DAEMON_ADDRESS is set.aws-xray-sdkauto mode, if AWS_XRAY_DAEMON_ADDRESS is set but aws-xray-sdk is not installed, construction throws.If you embed the plugin in your own get-dotenv host (or use the shipped CLI), you can provide safe defaults in config under plugins['aws/api-gateway']:
{
"plugins": {
"aws/api-gateway": {
"apiId": "$API_ID",
"apiName": "$API_NAME",
"stageName": "$STAGE_NAME",
"templateExtension": "template",
"pullKeys": { "to": "env:private", "delimiter": ", " }
},
},
}
See the api-gateway plugin guide for supported config keys and CLI behavior.
Built for you with ❤️ on Bali! Find more great tools & templates on my GitHub Profile.