Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DDynamic committed May 25, 2022
1 parent 736ea42 commit 63a1ad5
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const vpc = new ec2.Vpc(stack, 'Vpc', {
const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup', { vpc });

const vpcConnector = new VpcConnector(stack, 'VpcConnector', {
subnets: vpc.publicSubnets,
vpc,
vpcSubnets: vpc.selectSubnets({ subnetType: ec2.SubnetType.PUBLIC }),
securityGroups: [securityGroup],
vpcConnectorName: 'MyVpcConnector',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
}
}
},
"VpcConnectorCF6E3C30": {
"VpcConnectorE3A78531": {
"Type": "AWS::AppRunner::VpcConnector",
"Properties": {
"Subnets": [
Expand Down Expand Up @@ -440,7 +440,7 @@
"EgressType": "VPC",
"VpcConnectorArn": {
"Fn::GetAtt": [
"VpcConnectorCF6E3C30",
"VpcConnectorE3A78531",
"VpcConnectorArn"
]
}
Expand All @@ -467,7 +467,7 @@
"EgressType": "VPC",
"VpcConnectorArn": {
"Fn::GetAtt": [
"VpcConnectorCF6E3C30",
"VpcConnectorE3A78531",
"VpcConnectorArn"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@
"data": "SecurityGroupDD263621"
}
],
"/integ-apprunner/VpcConnector/VpcConnector": [
"/integ-apprunner/VpcConnector/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "VpcConnectorCF6E3C30"
"data": "VpcConnectorE3A78531"
}
],
"/integ-apprunner/Service6/Resource": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,9 @@
"id": "VpcConnector",
"path": "integ-apprunner/VpcConnector",
"children": {
"VpcConnector": {
"id": "VpcConnector",
"path": "integ-apprunner/VpcConnector/VpcConnector",
"Resource": {
"id": "Resource",
"path": "integ-apprunner/VpcConnector/Resource",
"attributes": {
"aws:cdk:cloudformation:type": "AWS::AppRunner::VpcConnector",
"aws:cdk:cloudformation:props": {
Expand Down Expand Up @@ -759,7 +759,7 @@
"egressType": "VPC",
"vpcConnectorArn": {
"Fn::GetAtt": [
"VpcConnectorCF6E3C30",
"VpcConnectorE3A78531",
"VpcConnectorArn"
]
}
Expand Down Expand Up @@ -820,7 +820,7 @@
"egressType": "VPC",
"vpcConnectorArn": {
"Fn::GetAtt": [
"VpcConnectorCF6E3C30",
"VpcConnectorE3A78531",
"VpcConnectorArn"
]
}
Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-apprunner/test/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ test('specifying a vpcConnector should assign the service to it and set the egre

const vpcConnector = new VpcConnector(stack, 'VpcConnector', {
securityGroups: [securityGroup],
subnets: vpc.publicSubnets,
vpc,
vpcSubnets: vpc.selectSubnets({ subnetType: ec2.SubnetType.PUBLIC }),
vpcConnectorName: 'MyVpcConnector',
});
// WHEN
Expand All @@ -675,7 +676,7 @@ test('specifying a vpcConnector should assign the service to it and set the egre
EgressType: 'VPC',
VpcConnectorArn: {
'Fn::GetAtt': [
'VpcConnectorCF6E3C30',
'VpcConnectorE3A78531',
'VpcConnectorArn',
],
},
Expand Down
41 changes: 39 additions & 2 deletions packages/@aws-cdk/aws-apprunner/test/vpc-connector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ test('create a vpcConnector with all properties', () => {
// WHEN
new VpcConnector(stack, 'VpcConnector', {
securityGroups: [securityGroup],
subnets: vpc.publicSubnets,
vpc,
vpcSubnets: vpc.selectSubnets({ subnetType: ec2.SubnetType.PUBLIC }),
vpcConnectorName: 'MyVpcConnector',
});
// THEN
Expand Down Expand Up @@ -54,7 +55,8 @@ test('create a vpcConnector without a name', () => {
// WHEN
new VpcConnector(stack, 'VpcConnector', {
securityGroups: [securityGroup],
subnets: vpc.publicSubnets,
vpc,
vpcSubnets: vpc.selectSubnets({ subnetType: ec2.SubnetType.PUBLIC }),
});
// THEN
Template.fromStack(stack).hasResourceProperties('AWS::AppRunner::VpcConnector', {
Expand All @@ -75,4 +77,39 @@ test('create a vpcConnector without a name', () => {
},
],
});
});

test('create a vpcConnector without a security group should create one', () => {
// GIVEN
const app = new cdk.App();
const stack = new cdk.Stack(app, 'demo-stack');

const vpc = new ec2.Vpc(stack, 'Vpc', {
cidr: '10.0.0.0/16',
});

// WHEN
new VpcConnector(stack, 'VpcConnector', {
vpc,
vpcSubnets: vpc.selectSubnets({ subnetType: ec2.SubnetType.PUBLIC }),
});
// THEN
Template.fromStack(stack).hasResourceProperties('AWS::AppRunner::VpcConnector', {
Subnets: [
{
Ref: 'VpcPublicSubnet1Subnet5C2D37C4',
},
{
Ref: 'VpcPublicSubnet2Subnet691E08A3',
},
],
SecurityGroups: [
{
'Fn::GetAtt': [
'VpcConnectorSecurityGroup33FAF25D',
'GroupId',
],
},
],
});
});

0 comments on commit 63a1ad5

Please sign in to comment.