Skip to content

aws-cdk-lib/aws-ec2: InterfaceVpcEndpoint. fromInterfaceVpcEndpointAttributes returns an object that does nothing #21636

@Juholei

Description

@Juholei

Describe the bug

Calling InterfaceVpcEndpoint.fromInterfaceVpcEndpointAttributes with the minimum required parameters like below can return an endpoint object that seemingly works but if you try to use it to allow connections, nothing happens.

const endpoint = InterfaceVpcEndpoint.fromInterfaceVpcEndpointAttributes(
  this,
  "Endpoint",
  {
      vpcEndpointId: "correct-id",
      port: 443,
  }
 );

 fargateService.connections.allowTo(endpoint, Port.tcp(443));

cdk diff shows no changes and after the deploy the connection is not allowed. If you add the optional securityGroups parameter to InterfaceVpcEndpointAttributes parameter of the call, then the endpoint works.

Also if the vpcEndpointId is wrong, it works exactly the same as with the correct id with a call such as above.

Expected Behavior

If an endpoint cannot be found with the given parameters, CDK should give an error like when importing other existing resources.

Current Behavior

There is no error, endpoint object's connections object can be used but nothing happens.

Reproduction Steps

  1. There is an existing interface endpoint defined outside of CDK.
  2. Import it using const endpoint = InterfaceVpcEndpoint.fromInterfaceVpcEndpointAttributes( this, "Endpoint", { vpcEndpointId: "correct-id", port: 443, } );
  3. Grant access to some other resource to the endpoint, for example like fargateService.connections.allowTo(endpoint, Port.tcp(443));
  4. Check cdk diff output for the stack, there's no changes.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.31.1

Framework Version

2.37.1

Node.js Version

v16.10.0

OS

Mac OS Monterey

Language

Typescript

Language Version

4.7.4

Other information

No response

Metadata

Metadata

Assignees

Labels

documentationThis is a problem with documentation.effort/smallSmall work item – less than a day of effortp2package/toolsRelated to AWS CDK Tools or CLI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions