EXPERIMENTAL: AWS IP Ranges Context Provider Plugin
An experimental plugin to dynamically fetch and filter the published IP ranges for AWS services within a CDK app.
It is based off the example specified in the comments of the plugins API
Installation
- Install the plugin
npm i aws-ip-ranges-construct aws-ip-ranges-plugin
- Register the plugin in
cdk.json
{
"app": "npx ts-node --prefer-ts-exts bin/app.ts",
"plugin": ["aws-ip-ranges-plugin"]
}
Usage
import { ContextProvider } from 'aws-cdk-lib'
import { query } from 'aws-ip-ranges-plugin'
import type { AwsIpRangesResult } from 'aws-ip-ranges-plugin/lib/types'
const filters = {
regions: ['us-east-1'],
services: ['EC2_INSTANCE_CONNECT'],
}
const ranges = ContextProvider.getValue(this, query(filters))
.value as AwsIpRangesResult