1- import { Match , Template } from '../../assertions' ;
2- import { AnyPrincipal , PolicyStatement } from '../../aws-iam' ;
1+ import { Match , Template } from '../../assertions' ;
2+ import { AnyPrincipal , PolicyStatement } from '../../aws-iam' ;
33import * as cxschema from '../../cloud-assembly-schema' ;
4- import { ContextProvider , Fn , Stack } from '../../core' ;
4+ import { ContextProvider , Fn , Stack } from '../../core' ;
55// eslint-disable-next-line max-len
66import {
77 GatewayVpcEndpoint ,
@@ -13,7 +13,8 @@ import {
1313 SubnetFilter ,
1414 SubnetType ,
1515 Vpc ,
16- VpcEndpointDnsRecordIpType , VpcEndpointIpAddressType ,
16+ VpcEndpointDnsRecordIpType ,
17+ VpcEndpointIpAddressType ,
1718} from '../lib' ;
1819
1920describe ( 'vpc endpoint' , ( ) => {
@@ -180,91 +181,25 @@ describe('vpc endpoint', () => {
180181 } ) ;
181182 } ) ;
182183
183- test ( 'throws when adding dnsRecordIpType without private dns enabled' , ( ) => {
184- // GIVEN
185- const stack = new Stack ( ) ;
186- const vpc = new Vpc ( stack , 'VpcNetwork' ) ;
187-
188- // WHEN
189- expect ( ( ) => {
190- vpc . addInterfaceEndpoint ( 'EcrDocker' , {
191- privateDnsEnabled : false ,
192- service : InterfaceVpcEndpointAwsService . ECR_DOCKER ,
193- dnsRecordIpType : VpcEndpointDnsRecordIpType . DUALSTACK ,
194- } ) ;
195- // THEN
196- } ) . toThrow ( ) ;
197- } ) ;
198-
199- test ( 'throws when adding dnsRecordIpType without ipAddressType' , ( ) => {
200- // GIVEN
201- const stack = new Stack ( ) ;
202- const vpc = new Vpc ( stack , 'VpcNetwork' ) ;
203-
204- // WHEN
205- expect ( ( ) => {
206- vpc . addInterfaceEndpoint ( 'EcrDocker' , {
207- service : InterfaceVpcEndpointAwsService . ECR_DOCKER ,
208- dnsRecordIpType : VpcEndpointDnsRecordIpType . DUALSTACK ,
209- } ) ;
210- // THEN
211- } ) . toThrow ( ) ;
212- } ) ;
213-
214- test . each ( [
215- [ VpcEndpointIpAddressType . IPV4 , VpcEndpointDnsRecordIpType . IPV4 ] ,
216- [ VpcEndpointIpAddressType . DUALSTACK , VpcEndpointDnsRecordIpType . IPV4 ] ,
217- [ VpcEndpointIpAddressType . IPV6 , VpcEndpointDnsRecordIpType . IPV6 ] ,
218- [ VpcEndpointIpAddressType . DUALSTACK , VpcEndpointDnsRecordIpType . IPV6 ] ,
219- [ VpcEndpointIpAddressType . DUALSTACK , VpcEndpointDnsRecordIpType . DUALSTACK ] ,
220- [ VpcEndpointIpAddressType . DUALSTACK , VpcEndpointDnsRecordIpType . SERVICE_DEFINED ] ,
221- ] ) ( 'add an endpoint to a vpc with various matching IP address types' , (
222- ipAddressType : VpcEndpointIpAddressType ,
223- dnsRecordIpType : VpcEndpointDnsRecordIpType ) => {
184+ test ( 'check ipAddressType and dnsOptions are present when specified' , ( ) => {
224185 // GIVEN
225186 const stack = new Stack ( ) ;
226187 const vpc = new Vpc ( stack , 'VpcNetwork' ) ;
227188
228189 // WHEN
229190 vpc . addInterfaceEndpoint ( 'EcrDocker' , {
230191 service : InterfaceVpcEndpointAwsService . ECR_DOCKER ,
231- ipAddressType : ipAddressType ,
232- dnsRecordIpType : dnsRecordIpType ,
192+ ipAddressType : VpcEndpointIpAddressType . DUALSTACK ,
193+ dnsRecordIpType : VpcEndpointDnsRecordIpType . DUALSTACK ,
233194 } ) ;
234195
235196 // THEN
236197 Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::EC2::VPCEndpoint' , {
237- IpAddressType : ipAddressType ,
238- DnsOptions : { DnsRecordIpType : dnsRecordIpType } ,
198+ IpAddressType : VpcEndpointIpAddressType . DUALSTACK ,
199+ DnsOptions : { DnsRecordIpType : VpcEndpointDnsRecordIpType . DUALSTACK } ,
239200 } ) ;
240201 } ) ;
241202
242- test . each ( [
243- [ VpcEndpointIpAddressType . IPV6 , VpcEndpointDnsRecordIpType . IPV4 ] ,
244- [ VpcEndpointIpAddressType . IPV4 , VpcEndpointDnsRecordIpType . IPV6 ] ,
245- [ VpcEndpointIpAddressType . IPV4 , VpcEndpointDnsRecordIpType . DUALSTACK ] ,
246- [ VpcEndpointIpAddressType . IPV6 , VpcEndpointDnsRecordIpType . DUALSTACK ] ,
247- [ VpcEndpointIpAddressType . IPV4 , VpcEndpointDnsRecordIpType . SERVICE_DEFINED ] ,
248- [ VpcEndpointIpAddressType . IPV6 , VpcEndpointDnsRecordIpType . SERVICE_DEFINED ] ,
249- ] ) ( 'add an endpoint to a vpc with mismatched ipAddressType and dnsRecordIpType, which throws error' , (
250- ipAddressType : VpcEndpointIpAddressType ,
251- dnsRecordIpType : VpcEndpointDnsRecordIpType ,
252- ) => {
253- // GIVEN
254- const stack = new Stack ( ) ;
255- const vpc = new Vpc ( stack , 'VpcNetwork' ) ;
256-
257- // WHEN
258- expect ( ( ) => {
259- vpc . addInterfaceEndpoint ( 'EcrDocker' , {
260- service : InterfaceVpcEndpointAwsService . ECR_DOCKER ,
261- ipAddressType : ipAddressType ,
262- dnsRecordIpType : dnsRecordIpType ,
263- } ) ;
264- // THEN
265- } ) . toThrow ( ) ;
266- } ) ;
267-
268203 test ( 'import/export' , ( ) => {
269204 // GIVEN
270205 const stack2 = new Stack ( ) ;
0 commit comments