Skip to content

create_network_connector

create_network_connector(
    name: NetworkConnectorName,
    configuration: NetworkConnectorConfiguration,
    *,
    config_overrides: Optional[LambdaCoreClientConfig] = None,
    operator_role: Optional[NetworkConnectorRoleArn] = None,
    client_token: Optional[ClientTokenString] = None,
    tags: Optional[NetworkConnectorTags] = None,
) -> CreateNetworkConnectorResponse

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 supported Lambda compute resources — such as MicroVMs and WebFunctions — at run time. For how to attach a connector, see the documentation for the specific compute type.

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.

Parameters:

  • name (NetworkConnectorName) –

    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.

  • configuration (NetworkConnectorConfiguration) –

    The network configuration for the connector. Specify a VpcEgressConfiguration to enable outbound traffic routing through your VPC.

  • operator_role (Optional[NetworkConnectorRoleArn], default: None ) –

    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.

  • client_token (Optional[ClientTokenString], default: None ) –

    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.

  • tags (Optional[NetworkConnectorTags], default: None ) –

    A map of key-value pairs to associate with the network connector for organization, cost allocation, or access control.

Raises:

  • InvalidParameterValueException –

    One of the parameters in the request is not valid. Check the error message for details about which parameter failed validation.

  • NetworkConnectorLimitExceededException –

    The request would exceed a network connector limit. For CreateNetworkConnector, the account has reached the maximum number of network connectors allowed. For UpdateNetworkConnector, the connector has reached the maximum number of versions allowed.

  • ResourceConflictException –

    The request could not be completed due to a conflict with the current state of the resource. For example, attempting to update a connector that is not in ACTIVE state.

  • ServiceException –

    An internal service error occurred. Retry the request with exponential backoff.

  • TooManyRequestsException –

    The request was throttled due to exceeding the allowed request rate. Retry the request after a brief wait using exponential backoff.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_lambda_core/_services/lambda_core.py
def create_network_connector(
    self,
    name: "capo_lambda_core.types.network_connector_name.NetworkConnectorName",
    configuration: "capo_lambda_core.types.network_connector_configuration.NetworkConnectorConfiguration",
    *,
    config_overrides: Optional[LambdaCoreClientConfig] = None,
    operator_role: Optional[
        "capo_lambda_core.types.network_connector_role_arn.NetworkConnectorRoleArn"
    ] = None,
    client_token: Optional[
        "capo_lambda_core.types.client_token_string.ClientTokenString"
    ] = None,
    tags: Optional[
        "capo_lambda_core.types.network_connector_tags.NetworkConnectorTags"
    ] = None,
) -> "capo_lambda_core.types.create_network_connector_response.CreateNetworkConnectorResponse":
    """<p>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.</p> <p>This operation is asynchronous. The network connector starts in <code>PENDING</code> state while ENIs are provisioned in your VPC (provisioning typically takes up to 10 minutes). Use <code>GetNetworkConnector</code> to poll the connector state until it reaches <code>ACTIVE</code>. Once active, you can attach the connector to supported Lambda compute resources — such as MicroVMs and WebFunctions — at run time. For how to attach a connector, see the documentation for the specific compute type.</p> <p>This operation is idempotent when you provide a <code>ClientToken</code> — if you retry a request that completed successfully using the same client token, the operation returns the existing connector without creating a duplicate.</p>

    Args:
        name: <p>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.</p>
        configuration: <p>The network configuration for the connector. Specify a <code>VpcEgressConfiguration</code> to enable outbound traffic routing through your VPC.</p>
        operator_role: <p>The ARN of the IAM role that Lambda assumes to manage elastic network interfaces in your VPC. This role must have permissions for <code>ec2:CreateNetworkInterface</code>, <code>ec2:DeleteNetworkInterface</code>, and related describe operations.</p>
        client_token: <p>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.</p>
        tags: <p>A map of key-value pairs to associate with the network connector for organization, cost allocation, or access control.</p>

    Raises:
        capo_lambda_core.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One of the parameters in the request is not valid. Check the error message for details about which parameter failed validation.</p>
        capo_lambda_core.errors.network_connector_limit_exceeded_exception.NetworkConnectorLimitExceededException: <p>The request would exceed a network connector limit. For <code>CreateNetworkConnector</code>, the account has reached the maximum number of network connectors allowed. For <code>UpdateNetworkConnector</code>, the connector has reached the maximum number of versions allowed.</p>
        capo_lambda_core.errors.resource_conflict_exception.ResourceConflictException: <p>The request could not be completed due to a conflict with the current state of the resource. For example, attempting to update a connector that is not in <code>ACTIVE</code> state.</p>
        capo_lambda_core.errors.service_exception.ServiceException: <p>An internal service error occurred. Retry the request with exponential backoff.</p>
        capo_lambda_core.errors.too_many_requests_exception.TooManyRequestsException: <p>The request was throttled due to exceeding the allowed request rate. Retry the request after a brief wait using exponential backoff.</p>
        capo_lambda_core.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lambda_core.types.create_network_connector_request.CreateNetworkConnectorRequest]",
    ) -> OperationResponse[
        "capo_lambda_core.types.create_network_connector_response.CreateNetworkConnectorResponse"
    ]:
        import capo_lambda_core._operations.lambda_core_api_service.create_network_connector

        output, http_response = (
            capo_lambda_core._operations.lambda_core_api_service.create_network_connector.create_network_connector(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateNetworkConnector")
    )
    input_: capo_lambda_core.types.create_network_connector_request.CreateNetworkConnectorRequest = {
        "name": name,
        "configuration": configuration,
    }
    if operator_role is not None:
        input_["operator_role"] = operator_role
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output