@aws-cdk/aws-ec2.InterfaceVpcEndpoint Fails Test
See original GitHub issueReproduction Steps
Run the jest test below:
import { InterfaceVpcEndpoint, InterfaceVpcEndpointAwsService, Vpc }
from "@aws-cdk/aws-ec2";
import { Stack } from "@aws-cdk/core";
test("InterfaceVpcEndpoint", () => {
// given
const stack = new Stack();
const vpc = new Vpc(stack, "TestVpc");
// when
new InterfaceVpcEndpoint(stack, "TestEndpoint", {
lookupSupportedAzs: true,
service: InterfaceVpcEndpointAwsService.SECRETS_MANAGER,
vpc: vpc,
});
});
What did you expect to happen?
The test to succeed.
What actually happened?
The test failed with the error Cannot look up VPC endpoint availability zones if account/region are not specified
and stack trace:
at InterfaceVpcEndpoint.validateCanLookupSupportedAzs (node_modules/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts:556:13)
at InterfaceVpcEndpoint.endpointSubnets (node_modules/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts:526:10)
at new InterfaceVpcEndpoint (node_modules/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts:480:28)
at Object.<anonymous> (test/cdk-constructs/interface-vpc-endpoint.test.ts:10:3)
Environment
- CDK CLI Version : 1.103.0 (build bc13a66)
- Framework Version: 1.103.0
- Node.js Version: v14.15.1
- OS : Ubuntu 20.04.2 LTS
- Language (Version): TypeScript 4.2.4
- Jest (Version) : 26.6.3
- ts-jest (version): 26.5.6
Other
I understand this can work without the lookupSupportedAzs: true,
param property, but my default profile is configured. I’m unable to determine why this is failing.
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Troubleshoot issues with Amazon VPC interface endpoints
I'm using Amazon Virtual Private Cloud (Amazon VPC) to create an interface VPC endpoint. However, I can't select my preferred subnet for the ......
Read more >What is an Interface VPC Endpoint and how can I ... - YouTube
We appreciate your feedback: https://amazonintna.qualtrics.com/jfe/form/SV_a5xC6bFzTcMv35sFind more details in the AWS Knowledge Center: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This test will work, even with the dummy account number
The code will throw the error you received on creating an
InterfaceVpcEndpoint
only if both account and region of the stack are undefined andlookupSupportedAzs
is true. So it doesn’t actually matter what the values are for this test to pass https://github.com/aws/aws-cdk/blob/7966f8d48c4bff26beb22856d289f9d0c7e7081d/packages/%40aws-cdk/aws-ec2/lib/vpc-endpoint.ts#L546-L557Thanks @peterwoodworth, that solved my issue. Is this quirk of CDK_DEFAULT_ACCOUNT (and I’m assuming CDK_DEFAULT_REGION) returning undefined documented anywhere for future reference? I’m aware now but others may have similar questions.