# NetworkConnector

A Lambda Network Connector: network configuration that Lambda compute attaches to.

The connector owns the network interfaces in the VPC. Compute references a connector rather
than carrying subnets and security groups itself, so the interfaces are provisioned when the
connector is created, not when each function is.

Every update to the connector produces a new immutable version. A WebFunction pins its
revision to one version (`latestVersionArn`), so when the connector in the same stack is
updated, the revision is replaced and moves to the new version as part of that deployment.
To hold a WebFunction on a fixed version instead — or to reference a connector from another
stack — import the version with `fromNetworkConnectorVersionArn`.

Extends: Construct › Resource › NetworkConnector
Implements: IResource, INetworkConnector, IEnvironmentAware, INetworkConnectorRef, IConstruct, IDependable

- CloudFormation: [`AWS::Lambda::NetworkConnector`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-lambda-networkconnector.html)
- L1 type: [`CfnNetworkConnector`](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.CfnNetworkConnector.html)
- Source: [`aws-lambda/lib/network-connector.ts`](https://github.com/aws/aws-cdk/blob/v2.276.0/packages/aws-cdk-lib/aws-lambda/lib/network-connector.ts#L267)
- Type last changed: v2.276.0 · 10 Nov 2026

## Example

```ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';

declare const vpc: ec2.Vpc;
declare const code: lambda.WebFunctionCode;

const securityGroup = new ec2.SecurityGroup(this, 'EgressSecurityGroup', { vpc });

const connector = new lambda.NetworkConnector(this, 'Egress', {
  configuration: lambda.NetworkConnectorConfiguration.vpcEgress({
    computeType: lambda.NetworkConnectorComputeType.WEB_FUNCTION,
    vpc,
    vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
    securityGroups: [securityGroup],
  }),
});

new lambda.WebFunction(this, 'MyWebFunction', {
  code,
  runtime: lambda.WebFunctionRuntime.NODEJS_24_X,
  defaultEndpointAuth: lambda.WebFunctionAuthType.IAM_AUTH,
  egressNetworkConnector: connector,
});
```

## Initializer

```ts
new NetworkConnector(scope: Construct, id: string, props: NetworkConnectorProps)
```

## Construct Props

- `configuration`: [NetworkConnectorConfiguration](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.NetworkConnectorConfiguration.html) (required) — The network configuration.

- `networkConnectorName`: string — A name for the connector, unique within the account and region.

  **Default:** a name is generated by CloudFormation

  Changing it replaces the connector.

- `operatorRole`: [IRoleRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_iam.IRoleRef.html) — The role the Lambda service assumes to manage the connector's network interfaces in the VPC.

  **Default:** a role is created with the `AWSLambdaNetworkConnectorOperatorPolicy` managed policy

  The `AWSLambdaNetworkConnectorOperatorPolicy` managed policy is attached to a provided role
  defined in this app, as it is to the default one. A role imported by ARN or name cannot be
  modified from this app, so a warning is emitted instead: make sure it already carries that
  policy, or equivalent permissions to manage the connector's network interfaces.

  Use a role dedicated to this connector. The service assumes it without presenting a source
  account or ARN, so its trust policy cannot be conditioned, and whatever else uses the role
  gains the permissions to manage network interfaces in the VPC. A function's execution role,
  for example, already trusts `lambda.amazonaws.com`, so passing it here would give that
  function's code those permissions.

- `tags`: { [key: string]: string } — Tags to apply to the connector.

  **Default:** No tags.

## Properties

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `latestVersionArn`: string — The qualified ARN of the connector's latest version.

  WebFunction pins a revision to this. For a connector defined in this app the value changes
  on every update to the connector, which replaces the revision that references it.

- `networkConnectorArn`: string — The unqualified ARN of the network connector.

  Identifies the connector as a whole, across its versions: use it in IAM policies and for
  consumers that resolve the current version at run time. It does not name a version, so
  WebFunction — which pins a revision to one version — does not accept it.

- `networkConnectorRef`: [NetworkConnectorReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_lambda.NetworkConnectorReference.html) — A reference to a NetworkConnector resource.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `operatorRole`: [IRoleRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_iam.IRoleRef.html) — The role the Lambda service assumes to manage the connector's network interfaces.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `resource`: [CfnNetworkConnector](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.CfnNetworkConnector.html) — The underlying L1 CfnNetworkConnector resource.

  Use for escape hatches.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

## Methods

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromNetworkConnectorArn(scope: Construct, id: string, networkConnectorArn: string): INetworkConnector` (static) — Import a connector by its unqualified ARN.

  The result names the connector as a whole, not a version, so it can be used in IAM
  policies but not as a WebFunction's `egressNetworkConnector`; reading `latestVersionArn`
  on it throws. Use `fromNetworkConnectorVersionArn` for that.

  **Parameters**

  - `networkConnectorArn` — An unqualified ARN, `arn:...:network-connector:nc-<id>`.

- `fromNetworkConnectorAttributes(scope: Construct, id: string, attrs: NetworkConnectorAttributes): INetworkConnector` (static) — Import a connector from its attributes.

- `fromNetworkConnectorVersionArn(scope: Construct, id: string, networkConnectorVersionArn: string): INetworkConnector` (static) — Import a specific version of a connector by its qualified ARN.

  This is the form a WebFunction can reference. The revision stays on this version until the
  ARN in your code changes, regardless of updates to the connector.

  A literal ARN is checked for a version suffix at synthesis. A deploy-time value — an SSM
  parameter, an imported value — cannot be inspected until deployment, where an unqualified
  ARN is rejected by the service when the revision is created.

  Do not pass the `latestVersionArn` of a connector in another stack. It changes on every
  update to the connector, and CloudFormation does not allow an exported value that another
  stack imports to change; a WebFunction rejects such an import at synthesis.

  **Parameters**

  - `networkConnectorVersionArn` — A qualified ARN, `arn:...:network-connector:nc-<id>:<version>`.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isNetworkConnector(x: any): boolean` (static) — Return whether the given object is a NetworkConnector.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
