
I Tried Allocating Elastic IPs for Lambda Network Connector from a Specified Pool Using a VPC IPAM Policy
This page has been translated by machine translation. View original
Introduction
On November 20, 2026, AWS Network Firewall's automated internet firewall and AWS Lambda Web Functions / MicroVMs were added as supported resources for Amazon VPC IPAM policies.
An IPAM policy allocates public IPv4 addresses for resources from a specified IPAM pool, following allocation rules. For Lambda, the target is the public IPv4 addresses used for outbound traffic via a Network Connector.
This article presents the results of trying allocation from an IPAM pool with a Lambda Network Connector.
Test Environment
- Region: Tokyo (ap-northeast-1)
- AWS CLI: 2.42.1
- IPAM: Free Tier (the operating Region is Tokyo only)
- Accounts: 1
- VPC: an internet gateway attached
- Subnets: one public subnet each in 1a and 1c
- Route: the default route goes to the internet gateway
- Pool: public scope, Amazon-provided contiguous IPv4 /30
Configuration
I created the IPAM, pool, policy, rules, and connector in that order. The two documents I referred to are as follows.
IPAM and Pool
I created the IPAM with the Free Tier, and created a pool in the public scope that was created at the same time. Since I made the pool Amazon-provided contiguous IPv4 for Elastic IPs, I specified --aws-service ec2 and --public-ip-source amazon. I matched the pool's locale to the Region where the connector is created.
aws ec2 create-ipam --tier free
aws ec2 create-ipam-pool \
--ipam-scope-id <create-ipam が返した PublicDefaultScopeId> \
--address-family ipv4 \
--locale ap-northeast-1 \
--aws-service ec2 \
--public-ip-source amazon
After confirming with describe-ipam-pools that the pool had reached create-complete, I provisioned a /30 CIDR. The pool reached create-complete within 20 seconds of creation.
aws ec2 provision-ipam-pool-cidr \
--ipam-pool-id <プール ID> \
--netmask-length 30
With get-ipam-pool-cidrs, I confirmed that the CIDR state had become provisioned, and checked the address range it was allocated from. It changed to provisioned within 14 seconds of starting provisioning.
aws ec2 get-ipam-pool-cidrs --ipam-pool-id <プール ID>
{
"IpamPoolCidrs": [
{
"Cidr": "203.0.113.132/30",
"State": "provisioned",
"IpamPoolCidrId": "ipam-pool-cidr-0123456789abcdef0",
"NetmaskLength": 30
}
]
}
Policy and Rules
I created a policy, and after it reached create-complete, added a rule for the resource type lambda-network-connector and enabled the policy. The policy reached create-complete within 20 seconds of creation. I also matched the rule's locale to the connector's Region.
aws ec2 create-ipam-policy --ipam-id <IPAM ID>
aws ec2 modify-ipam-policy-allocation-rules \
--ipam-policy-id <policy ID> \
--locale ap-northeast-1 \
--resource-type lambda-network-connector \
--allocation-rules SourceIpamPoolId=<プール ID>
aws ec2 enable-ipam-policy --ipam-policy-id <policy ID>
I passed the same --locale and --resource-type to get-ipam-policy-allocation-rules and confirmed the rule I had added.
Since the pool's owner account and the connector's account are the same, sharing via RAM was not necessary.
Connector
In the connector's configuration file, I set the Type of ElasticIpConfiguration to ServiceManaged, and specified two public subnets as the subnets, one in 1a and one in 1c. I saved the configuration for Web Functions as connector-web.json.
{
"VpcEgressConfiguration": {
"SubnetIds": ["subnet-0123456789abcdef0", "subnet-0123456789abcdef1"],
"SecurityGroupIds": ["sg-0123456789abcdef0"],
"NetworkProtocol": "IPv4",
"AssociatedComputeResourceTypes": ["WebFunction"],
"ElasticIpConfiguration": { "Type": "ServiceManaged" }
}
}
In connector-microvm.json for MicroVMs, I changed only AssociatedComputeResourceTypes to MicroVm.
aws lambda-core create-network-connector \
--name <connector 名> \
--configuration file://connector-web.json \
--operator-role <operator role の ARN>
I attached to the operator role the permissions listed in the Web Functions documentation. Since these included ec2:AllocateAddress and ec2:AssociateAddress, I did not add any permissions for IPAM.
The State immediately after creation was PENDING, and it took about 4 minutes to become ACTIVE. The two connectors created in later sections took about the same time.
I created the first connector (web1) 51 seconds after enabling the policy. By the time it became ACTIVE, addresses from the pool were being used.
Results
Connector Elastic IPs
I created a connector for Web Functions (web1) and one for MicroVMs (microvm1). Then, with the pool's /30 fully used, I created a third connector (web2) with the same configuration as web1. With the following command, I listed the Elastic IPs associated with the connectors and the sources they were allocated from.
aws ec2 describe-addresses \
--filters 'Name=service-managed,Values=lambda-network-connector' \
--query 'Addresses[].{PublicIp:PublicIp,Pool:PublicIpv4Pool,Connector:Tags[?Key==`aws:lambda:networkConnectorName`]|[0].Value}' \
--output json
[
{
"PublicIp": "203.0.113.132",
"Pool": "ipam-pool-0123456789abcdef0",
"Connector": "devio-1124-web1"
},
{
"PublicIp": "203.0.113.133",
"Pool": "ipam-pool-0123456789abcdef0",
"Connector": "devio-1124-microvm1"
},
{
"PublicIp": "203.0.113.134",
"Pool": "ipam-pool-0123456789abcdef0",
"Connector": "devio-1124-web1"
},
{
"PublicIp": "203.0.113.135",
"Pool": "ipam-pool-0123456789abcdef0",
"Connector": "devio-1124-microvm1"
},
{
"PublicIp": "198.51.100.16",
"Pool": "amazon",
"Connector": "devio-1124-web2"
},
{
"PublicIp": "198.51.100.77",
"Pool": "amazon",
"Connector": "devio-1124-web2"
}
]
If Pool is an IPAM pool ID, the address was allocated from the pool by the policy's rule; if it is amazon, it is a regular Amazon address that did not go through the pool.
For both the Web Functions connector and the MicroVMs connector, addresses from the pool were allocated by the same rule.
One Elastic IP was created per connector ENI. web1 and microvm1 each have one ENI in each of the two subnets, so each used two addresses from the pool. The /30, which has 4 addresses, was exhausted by these two connectors.
When the Pool Runs Out
The state of the third connector (web2) was ACTIVE, not FAILED. No errors or warnings were returned at creation. Both of web2's Elastic IPs were regular Amazon addresses outside the pool's CIDR.
The number of allocations in the pool remained at 4 even after the third connector was created. The addresses of the two connectors created earlier also remained pool addresses.
aws ec2 get-ipam-pool-allocations \
--ipam-pool-id <プール ID> \
--query 'length(IpamPoolAllocations)' \
--output text
4
Web Function's Source IP
I used a Web Function to verify that the Elastic IP of the connector (web1) actually becomes the source IP.
The steps for creating a Web Function are introduced in the following article.
In the Web Function's revision, I specified the versioned ARN of the connector (ending in :1) for egressNetworkConnectorArn in serviceConfig. For the create-web-function command, I specified both --revision-config and --endpoint-config.
Revision and endpoint configuration, and the creation command
revision-config.json
{
"buildConfig": {
"codeConfig": {
"s3Object": {
"bucket": "<バケット名>",
"key": "app.zip",
"versionId": "<versionId>"
}
},
"runtimeConfig": {
"runtime": "nodejs24.x"
}
},
"serviceConfig": {
"executionRoleArn": "arn:aws:iam::111122223333:role/<実行ロール名>",
"timeoutSeconds": 30,
"egressNetworkConnectorArn": "arn:aws:lambda:ap-northeast-1:111122223333:network-connector:<connector ID>:1"
}
}
endpoint-config.json
{
"endpointName": "main",
"endpointType": "HomeRegion",
"authType": "ApplicationManaged"
}
aws lambda-web create-web-function \
--function-name <関数名> \
--revision-config file://revision-config.json \
--endpoint-config file://endpoint-config.json
The app calls checkip.amazonaws.com and returns the IP it receives as JSON.
App code (index.js)
// Web Function: returns the source IP seen by checkip.amazonaws.com.
// Lambda Web Functions send requests to port 3000.
const http = require('node:http');
http.createServer(async (_req, res) => {
const started = Date.now();
res.setHeader('content-type', 'application/json');
try {
const r = await fetch('https://checkip.amazonaws.com', { signal: AbortSignal.timeout(8000) });
res.end(JSON.stringify({ checkip: (await r.text()).trim(), elapsedMs: Date.now() - started }));
} catch (e) {
res.statusCode = 502;
res.end(JSON.stringify({ error: e.name, message: e.message, elapsedMs: Date.now() - started }));
}
}).listen(3000, () => console.log('listening on port 3000'));
I called the endpoint four times.
curl -s -m 30 -w '\nhttp=%{http_code}\n' https://<endpoint のドメイン>/
{"checkip":"203.0.113.134","elapsedMs":246}
http=200
{"checkip":"203.0.113.134","elapsedMs":71}
http=200
{"checkip":"203.0.113.134","elapsedMs":70}
http=200
{"checkip":"203.0.113.134","elapsedMs":72}
http=200
All four times, web1's Elastic IP (203.0.113.134), which is within the pool's CIDR, was returned.
Pricing
Even if IPAM is on the Free Tier, the provisioned Amazon-provided contiguous IPv4 /30 incurs hourly charges for 4 addresses. At $0.008 per hour per address, that is about $0.77 per day and about $23 for 30 days. For details, see the VPC pricing page.
Summary
I confirmed that Elastic IPs allocated from an IPAM pool can be used with a Lambda Network Connector.
Although I did not test it this time, I think this is a useful update if you want to associate a NAT Gateway with AWS Network Firewall, use it as an explicit proxy, and manage the proxy's IP addresses with IPAM.
If you have already adopted Amazon VPC IPAM and plan to use the newly added Lambda Web Functions / MicroVMs or the automated internet firewall, or if you want to streamline IP management for AWS Network Firewall or NAT Gateway, I recommend evaluating this update.



