createNetworkConnector method
Creates a network connector that enables Lambda compute resources to route outbound traffic through your Amazon VPC. The network connector provisions elastic network interfaces (ENIs) in the subnets you specify, providing a managed network path to private resources such as databases, caches, and internal APIs.
This operation is asynchronous. The network connector starts in
PENDING state while ENIs are provisioned in your VPC
(provisioning typically takes up to 10 minutes). Use
GetNetworkConnector to poll the connector state until it
reaches ACTIVE. Once active, you can attach the connector to
Lambda MicroVMs at run time using the egressNetworkConnectors
parameter on RunMicroVm.
This operation is idempotent when you provide a ClientToken —
if you retry a request that completed successfully using the same client
token, the operation returns the existing connector without creating a
duplicate.
May throw InvalidParameterValueException.
May throw NetworkConnectorLimitExceededException.
May throw ResourceConflictException.
May throw ServiceException.
May throw TooManyRequestsException.
Parameter configuration :
The network configuration for the connector. Specify a
VpcEgressConfiguration to enable outbound traffic routing
through your VPC.
Parameter name :
A unique name for the network connector within your account and Region.
You can use the name to identify the connector in subsequent API calls.
Parameter clientToken :
A unique, case-sensitive identifier that you provide to ensure the
idempotency of the request. If you retry a request with the same client
token, the API returns the existing connector without creating a
duplicate.
Parameter operatorRole :
The ARN of the IAM role that Lambda assumes to manage elastic network
interfaces in your VPC. This role must have permissions for
ec2:CreateNetworkInterface,
ec2:DeleteNetworkInterface, and related describe operations.
Parameter tags :
A map of key-value pairs to associate with the network connector for
organization, cost allocation, or access control.
Implementation
Future<CreateNetworkConnectorResponse> createNetworkConnector({
required NetworkConnectorConfiguration configuration,
required String name,
String? clientToken,
String? operatorRole,
Map<String, String>? tags,
}) async {
final $payload = <String, dynamic>{
'Configuration': configuration,
'Name': name,
'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
if (operatorRole != null) 'OperatorRole': operatorRole,
if (tags != null) 'Tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/2026-04-04/network-connectors',
exceptionFnMap: _exceptionFns,
);
return CreateNetworkConnectorResponse.fromJson(response);
}