Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: version updates, including breaking changes in jsii (backport #22382) #22464

Merged
merged 7 commits into from
Oct 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2/lib/vpc.ts
Original file line number Diff line number Diff line change
@@ -2190,7 +2190,7 @@ function determineNatGatewayCount(requestedCount: number | undefined, subnetConf

if (count === 0 && hasPrivateSubnets) {
// eslint-disable-next-line max-len
throw new Error('If you do not want NAT gateways (natGateways=0), make sure you don\'t configure any PRIVATE subnets in \'subnetConfiguration\' (make them PUBLIC or ISOLATED instead)');
throw new Error('If you do not want NAT gateways (natGateways=0), make sure you don\'t configure any PRIVATE(_WITH_NAT) subnets in \'subnetConfiguration\' (make them PUBLIC or ISOLATED instead)');
}

if (count > 0 && !hasPublicSubnets) {
9 changes: 4 additions & 5 deletions packages/@aws-cdk/aws-ec2/test/vpc.test.ts
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ import {
describe('vpc', () => {
describe('When creating a VPC', () => {

test('SubnetType.PRIVATE is equivalent to SubnetType.PRIVATE_WITH_NAT', () => {
testDeprecated('SubnetType.PRIVATE is equivalent to SubnetType.PRIVATE_WITH_NAT', () => {

const stack1 = getTestStack();
const stack2 = getTestStack();
@@ -68,7 +68,7 @@ describe('vpc', () => {

});

test('SubnetType.ISOLATED is equivalent to SubnetType.PRIVATE_ISOLATED', () => {
testDeprecated('SubnetType.ISOLATED is equivalent to SubnetType.PRIVATE_ISOLATED', () => {

const stack1 = getTestStack();
const stack2 = getTestStack();
@@ -89,7 +89,6 @@ describe('vpc', () => {
},
],
});

const t1 = Template.fromStack(stack1);
const t2 = Template.fromStack(stack2);

@@ -706,7 +705,7 @@ describe('vpc', () => {

});

test('natGateways = 0 throws if no PRIVATE subnets configured', () => {
testDeprecated('natGateways = 0 throws if PRIVATE_WITH_NAT subnets configured', () => {
const stack = getTestStack();
expect(() => {
new Vpc(stack, 'VPC', {
@@ -722,7 +721,7 @@ describe('vpc', () => {
},
],
});
}).toThrow(/make sure you don't configure any PRIVATE subnets/);
}).toThrow(/make sure you don't configure any PRIVATE/);


});
60 changes: 44 additions & 16 deletions packages/@aws-cdk/aws-ec2/test/vpn.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Template } from '@aws-cdk/assertions';
import { testDeprecated } from '@aws-cdk/cdk-build-tools';
import { Duration, SecretValue, Stack, Token } from '@aws-cdk/core';
import { PublicSubnet, Vpc, VpnConnection } from '../lib';

@@ -84,25 +85,52 @@ describe('vpn', () => {

});

test.each([false, true])('with tunnel options, using secret: %p', (secret) => {
test('with tunnel options, using secret value', () => {
// GIVEN
const stack = new Stack();

new Vpc(stack, 'VpcNetwork', {
vpnConnections: {
VpnConnection: {
ip: '192.0.2.1',
tunnelOptions: [
secret
? {
preSharedKeySecret: SecretValue.unsafePlainText('secretkey1234'),
tunnelInsideCidr: '169.254.10.0/30',
}
: {
preSharedKey: 'secretkey1234',
tunnelInsideCidr: '169.254.10.0/30',
},
],
tunnelOptions: [{
preSharedKeySecret: SecretValue.unsafePlainText('secretkey1234'),
tunnelInsideCidr: '169.254.10.0/30',
}],
},
},
});

Template.fromStack(stack).hasResourceProperties('AWS::EC2::VPNConnection', {
CustomerGatewayId: {
Ref: 'VpcNetworkVpnConnectionCustomerGateway8B56D9AF',
},
Type: 'ipsec.1',
VpnGatewayId: {
Ref: 'VpcNetworkVpnGateway501295FA',
},
StaticRoutesOnly: false,
VpnTunnelOptionsSpecifications: [
{
PreSharedKey: 'secretkey1234',
TunnelInsideCidr: '169.254.10.0/30',
},
],
});
});

testDeprecated('with tunnel options, using secret', () => {
// GIVEN
const stack = new Stack();

new Vpc(stack, 'VpcNetwork', {
vpnConnections: {
VpnConnection: {
ip: '192.0.2.1',
tunnelOptions: [{
preSharedKey: 'secretkey1234',
tunnelInsideCidr: '169.254.10.0/30',
}],
},
},
});
@@ -150,13 +178,13 @@ describe('vpn', () => {
ip: '192.0.2.1',
tunnelOptions: [
{
preSharedKey: 'secretkey1234',
preSharedKeySecret: SecretValue.unsafePlainText('secretkey1234'),
},
{
preSharedKey: 'secretkey1234',
preSharedKeySecret: SecretValue.unsafePlainText('secretkey1234'),
},
{
preSharedKey: 'secretkey1234',
preSharedKeySecret: SecretValue.unsafePlainText('secretkey1234'),
},
],
},
@@ -189,7 +217,7 @@ describe('vpn', () => {

});

test('fails when specifying an invalid pre-shared key', () => {
testDeprecated('fails when specifying an invalid pre-shared key', () => {
// GIVEN
const stack = new Stack();

Original file line number Diff line number Diff line change
@@ -742,4 +742,4 @@ test('assumedRoleArn adds statement for sts:assumeRole', () => {
Version: '2012-10-17',
},
});
});
});
15 changes: 15 additions & 0 deletions tools/@aws-cdk/cdk-build-tools/lib/deprecated-symbols.ts
Original file line number Diff line number Diff line change
@@ -37,6 +37,21 @@ export function testDeprecated(name: string, fn: () => any, timeout?: number) {
}, timeout);
}

export declare namespace testDeprecated {
const each: typeof test.each;
}

(testDeprecated as any).each = function(cases: ReadonlyArray<ReadonlyArray<any>>) {
const testRunner = (test.each as any).call(test, cases);
return (name: string, fn: (...testArgs: any[]) => any) => {
testRunner(name, (...testArgs: any[]) => {
const deprecated = DeprecatedSymbols.quiet();
fn(...testArgs);
DeprecatedSymbols.reset(deprecated);
});
};
};

namespace DeprecatedSymbols {
export function quiet(): string | undefined {
const deprecated = process.env.JSII_DEPRECATED;