Skip to content

Commit d0912ca

Browse files
authored
fix(ec2): tokenised subnet.subnetId filtered by the SubnetIdSubnetFilter returns an empty array (#24625)
> Fix for SubnetFilter.byId() > > fix for returning an empty array after this SubnetFilter.byId() applied Closes #24427. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e69e0de commit d0912ca

11 files changed

+1575
-2
lines changed

packages/@aws-cdk/aws-ec2/lib/subnet.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { Token } from '@aws-cdk/core';
12
import { CidrBlock, NetworkUtils } from './network-util';
23
import { ISubnet } from './vpc';
3-
44
/**
55
* Contains logic which chooses a set of subnets from a larger list, in conjunction
66
* with SubnetSelection, to determine where to place AWS resources such as VPC
@@ -144,7 +144,7 @@ class SubnetIdSubnetFilter extends SubnetFilter {
144144
* Executes the subnet filtering logic.
145145
*/
146146
public selectSubnets(subnets: ISubnet[]): ISubnet[] {
147-
return subnets.filter(subnet => this.subnetIds.includes(subnet.subnetId));
147+
return subnets.filter(subnet => this.subnetIds.includes(Token.asString(subnet.subnetId)));
148148
}
149149
}
150150

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "31.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "VPCFilterSubnetsDefaultTestDeployAssertC02936E8.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "31.0.0",
3+
"files": {
4+
"a9beea32c9b28bae98911a4a8b67622ad7d611f5d0604066ceaf6e283e02c0c3": {
5+
"source": {
6+
"path": "VPCFilterSubnetsTestStack.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "a9beea32c9b28bae98911a4a8b67622ad7d611f5d0604066ceaf6e283e02c0c3.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}

0 commit comments

Comments
 (0)