@@ -1084,7 +1084,7 @@ describe('cluster', () => {
1084
1084
Type : 'Custom::AWSCDK-EKS-KubernetesResource' ,
1085
1085
Properties : {
1086
1086
ServiceToken : {
1087
- 'Fn::ImportValue' : 'Stack:ExportsOutputFnGetAttawscdkawseksKubectlProviderNestedStackawscdkawseksKubectlProviderNestedStackResourceA7AEBA6BOutputsStackawscdkawseksKubectlProviderframeworkonEvent8897FD9BArn49BEF20C ' ,
1087
+ 'Fn::ImportValue' : 'Stack:ExportsOutputFnGetAttawscdkawseksKubectlProviderframeworkonEvent0A650005Arn27EC41A8 ' ,
1088
1088
} ,
1089
1089
Manifest : '[{\"foo\":\"bar\"}]' ,
1090
1090
ClusterName : { 'Fn::ImportValue' : 'Stack:ExportsOutputRefcluster611F8AFFA07FC079' } ,
@@ -2069,11 +2069,9 @@ describe('cluster', () => {
2069
2069
} ,
2070
2070
} ) ;
2071
2071
2072
- // the kubectl provider is inside a nested stack.
2073
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2074
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2072
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2075
2073
VpcConfig : {
2076
- SecurityGroupIds : [ { Ref : 'referencetoStackCluster17032651AClusterSecurityGroupId' } ] ,
2074
+ SecurityGroupIds : [ { 'Fn::GetAtt' : [ 'Cluster192CD0375' , 'ClusterSecurityGroupId' ] } ] ,
2077
2075
} ,
2078
2076
} ) ;
2079
2077
} ) ;
@@ -2101,9 +2099,7 @@ describe('cluster', () => {
2101
2099
} ,
2102
2100
} ) ;
2103
2101
2104
- // the kubectl provider is inside a nested stack.
2105
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2106
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2102
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2107
2103
Environment : {
2108
2104
Variables : {
2109
2105
Foo : 'Bar' ,
@@ -2139,11 +2135,9 @@ describe('cluster', () => {
2139
2135
} ,
2140
2136
} ) ;
2141
2137
2142
- // the kubectl provider is inside a nested stack.
2143
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2144
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2138
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2145
2139
Role : {
2146
- Ref : 'referencetoStackKubectlIamRole02F8947EArn' ,
2140
+ 'Fn::GetAtt' : [ 'awscdkawseksKubectlProviderframeworkonEventServiceRoleF4FAF053' , 'Arn' ] ,
2147
2141
} ,
2148
2142
} ) ;
2149
2143
} ) ;
@@ -2165,10 +2159,9 @@ describe('cluster', () => {
2165
2159
chart,
2166
2160
} ) ;
2167
2161
2168
- const nested = stack . node . tryFindChild ( 'Imported-KubectlProvider' ) as cdk . NestedStack ;
2169
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2162
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2170
2163
Role : {
2171
- Ref : 'referencetoKubectlLambdaRole7D084D94Arn' ,
2164
+ 'Fn::GetAtt' : [ 'ImportedKubectlProviderframeworkonEventServiceRole6603B49A' , 'Arn' ] ,
2172
2165
} ,
2173
2166
} ) ;
2174
2167
Template . fromStack ( stack ) . hasResourceProperties ( HelmChart . RESOURCE_TYPE , {
@@ -2199,11 +2192,9 @@ describe('cluster', () => {
2199
2192
vpcSubnets : [ { subnetType : ec2 . SubnetType . PUBLIC } ] ,
2200
2193
} ) ;
2201
2194
2202
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2203
-
2204
2195
// we don't attach vpc config in case endpoint is public only, regardless of whether
2205
2196
// the vpc has private subnets or not.
2206
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2197
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2207
2198
VpcConfig : Match . absent ( ) ,
2208
2199
} ) ;
2209
2200
} ) ;
@@ -2217,11 +2208,9 @@ describe('cluster', () => {
2217
2208
endpointAccess : eks . EndpointAccess . PUBLIC ,
2218
2209
} ) ;
2219
2210
2220
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2221
-
2222
2211
// we don't attach vpc config in case endpoint is public only, regardless of whether
2223
2212
// the vpc has private subnets or not.
2224
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2213
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2225
2214
VpcConfig : Match . absent ( ) ,
2226
2215
} ) ;
2227
2216
} ) ;
@@ -2248,11 +2237,9 @@ describe('cluster', () => {
2248
2237
endpointAccess : eks . EndpointAccess . PRIVATE ,
2249
2238
} ) ;
2250
2239
2251
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2252
-
2253
- const functions = Template . fromStack ( nested ) . findResources ( 'AWS::Lambda::Function' ) ;
2254
- expect ( functions . Handler886CB40B . Properties . VpcConfig . SubnetIds . length ) . not . toEqual ( 0 ) ;
2255
- expect ( functions . Handler886CB40B . Properties . VpcConfig . SecurityGroupIds . length ) . not . toEqual ( 0 ) ;
2240
+ const functions = Template . fromStack ( stack ) . findResources ( 'AWS::Lambda::Function' ) ;
2241
+ expect ( functions . awscdkawseksKubectlProviderHandlerAABA4423 . Properties . VpcConfig . SubnetIds . length ) . not . toEqual ( 0 ) ;
2242
+ expect ( functions . awscdkawseksKubectlProviderHandlerAABA4423 . Properties . VpcConfig . SecurityGroupIds . length ) . not . toEqual ( 0 ) ;
2256
2243
} ) ;
2257
2244
2258
2245
test ( 'private and non restricted public without private subnets' , ( ) => {
@@ -2265,11 +2252,9 @@ describe('cluster', () => {
2265
2252
vpcSubnets : [ { subnetType : ec2 . SubnetType . PUBLIC } ] ,
2266
2253
} ) ;
2267
2254
2268
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2269
-
2270
2255
// we don't have private subnets, but we don't need them since public access
2271
2256
// is not restricted.
2272
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2257
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2273
2258
VpcConfig : Match . absent ( ) ,
2274
2259
} ) ;
2275
2260
} ) ;
@@ -2283,12 +2268,10 @@ describe('cluster', () => {
2283
2268
endpointAccess : eks . EndpointAccess . PUBLIC_AND_PRIVATE ,
2284
2269
} ) ;
2285
2270
2286
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2287
-
2288
2271
// we have private subnets so we should use them.
2289
- const functions = Template . fromStack ( nested ) . findResources ( 'AWS::Lambda::Function' ) ;
2290
- expect ( functions . Handler886CB40B . Properties . VpcConfig . SubnetIds . length ) . not . toEqual ( 0 ) ;
2291
- expect ( functions . Handler886CB40B . Properties . VpcConfig . SecurityGroupIds . length ) . not . toEqual ( 0 ) ;
2272
+ const functions = Template . fromStack ( stack ) . findResources ( 'AWS::Lambda::Function' ) ;
2273
+ expect ( functions . awscdkawseksKubectlProviderHandlerAABA4423 . Properties . VpcConfig . SubnetIds . length ) . not . toEqual ( 0 ) ;
2274
+ expect ( functions . awscdkawseksKubectlProviderHandlerAABA4423 . Properties . VpcConfig . SecurityGroupIds . length ) . not . toEqual ( 0 ) ;
2292
2275
} ) ;
2293
2276
2294
2277
test ( 'private and restricted public without private subnets' , ( ) => {
@@ -2313,12 +2296,10 @@ describe('cluster', () => {
2313
2296
endpointAccess : eks . EndpointAccess . PUBLIC_AND_PRIVATE . onlyFrom ( '1.2.3.4/32' ) ,
2314
2297
} ) ;
2315
2298
2316
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2317
-
2318
2299
// we have private subnets so we should use them.
2319
- const functions = Template . fromStack ( nested ) . findResources ( 'AWS::Lambda::Function' ) ;
2320
- expect ( functions . Handler886CB40B . Properties . VpcConfig . SubnetIds . length ) . not . toEqual ( 0 ) ;
2321
- expect ( functions . Handler886CB40B . Properties . VpcConfig . SecurityGroupIds . length ) . not . toEqual ( 0 ) ;
2300
+ const functions = Template . fromStack ( stack ) . findResources ( 'AWS::Lambda::Function' ) ;
2301
+ expect ( functions . awscdkawseksKubectlProviderHandlerAABA4423 . Properties . VpcConfig . SubnetIds . length ) . not . toEqual ( 0 ) ;
2302
+ expect ( functions . awscdkawseksKubectlProviderHandlerAABA4423 . Properties . VpcConfig . SecurityGroupIds . length ) . not . toEqual ( 0 ) ;
2322
2303
} ) ;
2323
2304
2324
2305
test ( 'private endpoint access selects only private subnets from looked up vpc' , ( ) => {
@@ -2372,8 +2353,7 @@ describe('cluster', () => {
2372
2353
endpointAccess : eks . EndpointAccess . PRIVATE ,
2373
2354
} ) ;
2374
2355
2375
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2376
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2356
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2377
2357
VpcConfig : { SubnetIds : [ 'subnet-private-in-us-east-1a' ] } ,
2378
2358
} ) ;
2379
2359
} ) ;
@@ -2437,8 +2417,7 @@ describe('cluster', () => {
2437
2417
} ] ,
2438
2418
} ) ;
2439
2419
2440
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2441
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2420
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2442
2421
VpcConfig : { SubnetIds : [ 'subnet-private-in-us-east-1a' ] } ,
2443
2422
} ) ;
2444
2423
} ) ;
@@ -2462,11 +2441,10 @@ describe('cluster', () => {
2462
2441
} ] ,
2463
2442
} ) ;
2464
2443
2465
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2466
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2444
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2467
2445
VpcConfig : {
2468
2446
SubnetIds : [
2469
- { Ref : 'referencetoStackVpcPrivateSubnet1Subnet8E6A14CBRef ' } ,
2447
+ { Ref : 'VpcPrivateSubnet1Subnet536B997A ' } ,
2470
2448
'subnet-unknown' ,
2471
2449
] ,
2472
2450
} ,
@@ -2488,8 +2466,7 @@ describe('cluster', () => {
2488
2466
} ] ,
2489
2467
} ) ;
2490
2468
2491
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2492
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2469
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2493
2470
VpcConfig : { SubnetIds : [ 'subnet1' ] } ,
2494
2471
} ) ;
2495
2472
} ) ;
@@ -2541,21 +2518,19 @@ describe('cluster', () => {
2541
2518
} ,
2542
2519
} ) ;
2543
2520
2544
- // the kubectl provider is inside a nested stack.
2545
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2546
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2521
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2547
2522
VpcConfig : {
2548
2523
SecurityGroupIds : [
2549
2524
{
2550
- Ref : 'referencetoStackCluster17032651AClusterSecurityGroupId' ,
2525
+ 'Fn::GetAtt' : [ 'Cluster192CD0375' , 'ClusterSecurityGroupId' ] ,
2551
2526
} ,
2552
2527
] ,
2553
2528
SubnetIds : [
2554
2529
{
2555
- Ref : 'referencetoStackVpcPrivate1Subnet1Subnet6764A0F6Ref ' ,
2530
+ Ref : 'VpcPrivate1Subnet1SubnetC688B2B1 ' ,
2556
2531
} ,
2557
2532
{
2558
- Ref : 'referencetoStackVpcPrivate1Subnet2SubnetDFD49645Ref ' ,
2533
+ Ref : 'VpcPrivate1Subnet2SubnetA2AF15C7 ' ,
2559
2534
} ,
2560
2535
] ,
2561
2536
} ,
@@ -2604,10 +2579,8 @@ describe('cluster', () => {
2604
2579
} ,
2605
2580
} ) ;
2606
2581
2607
- // the kubectl provider is inside a nested stack.
2608
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2609
- const functions = Template . fromStack ( nested ) . findResources ( 'AWS::Lambda::Function' ) ;
2610
- expect ( functions . Handler886CB40B . Properties . VpcConfig . SubnetIds . length ) . toEqual ( 16 ) ;
2582
+ const functions = Template . fromStack ( stack ) . findResources ( 'AWS::Lambda::Function' ) ;
2583
+ expect ( functions . awscdkawseksKubectlProviderHandlerAABA4423 . Properties . VpcConfig . SubnetIds . length ) . toEqual ( 16 ) ;
2611
2584
} ) ;
2612
2585
2613
2586
test ( 'kubectl provider considers vpc subnet selection' , ( ) => {
@@ -2653,27 +2626,25 @@ describe('cluster', () => {
2653
2626
} ,
2654
2627
} ) ;
2655
2628
2656
- // the kubectl provider is inside a nested stack.
2657
- const nested = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2658
- Template . fromStack ( nested ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2629
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2659
2630
VpcConfig : {
2660
2631
SecurityGroupIds : [
2661
2632
{
2662
- Ref : 'referencetoStackCluster17032651AClusterSecurityGroupId' ,
2633
+ 'Fn::GetAtt' : [ 'Cluster192CD0375' , 'ClusterSecurityGroupId' ] ,
2663
2634
} ,
2664
2635
] ,
2665
2636
SubnetIds : [
2666
2637
{
2667
- Ref : 'referencetoStackVpcPrivate1Subnet1Subnet6764A0F6Ref ' ,
2638
+ Ref : 'VpcPrivate1Subnet1SubnetC688B2B1 ' ,
2668
2639
} ,
2669
2640
{
2670
- Ref : 'referencetoStackVpcPrivate1Subnet2SubnetDFD49645Ref ' ,
2641
+ Ref : 'VpcPrivate1Subnet2SubnetA2AF15C7 ' ,
2671
2642
} ,
2672
2643
{
2673
- Ref : 'referencetoStackVpcPrivate2Subnet1Subnet586AD392Ref ' ,
2644
+ Ref : 'VpcPrivate2Subnet1SubnetE13E2E30 ' ,
2674
2645
} ,
2675
2646
{
2676
- Ref : 'referencetoStackVpcPrivate2Subnet2SubnetE42148C0Ref ' ,
2647
+ Ref : 'VpcPrivate2Subnet2Subnet158A38AB ' ,
2677
2648
} ,
2678
2649
] ,
2679
2650
} ,
@@ -2734,8 +2705,8 @@ describe('cluster', () => {
2734
2705
expect ( resources [ expectedKubernetesGetId ] . Properties ) . toEqual ( {
2735
2706
ServiceToken : {
2736
2707
'Fn::GetAtt' : [
2737
- 'awscdkawseksKubectlProviderNestedStackawscdkawseksKubectlProviderNestedStackResourceA7AEBA6B ' ,
2738
- 'Outputs.StackawscdkawseksKubectlProviderframeworkonEvent8897FD9BArn ' ,
2708
+ 'awscdkawseksKubectlProviderframeworkonEvent0A650005 ' ,
2709
+ 'Arn ' ,
2739
2710
] ,
2740
2711
} ,
2741
2712
ClusterName : {
@@ -2773,10 +2744,9 @@ describe('cluster', () => {
2773
2744
} ) ;
2774
2745
2775
2746
// THEN
2776
- const providerStack = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2777
- Template . fromStack ( providerStack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2747
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2778
2748
Layers : [
2779
- { Ref : 'AwsCliLayerF44AAF94 ' } ,
2749
+ { Ref : 'awscdkawseksKubectlProviderAwsCliLayerF72FE066 ' } ,
2780
2750
'arn:of:layer' ,
2781
2751
] ,
2782
2752
} ) ;
@@ -2833,11 +2803,10 @@ describe('cluster', () => {
2833
2803
} ) ;
2834
2804
2835
2805
// THEN
2836
- const providerStack = stack . node . tryFindChild ( '@aws-cdk/aws-eks.KubectlProvider' ) as cdk . NestedStack ;
2837
- Template . fromStack ( providerStack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2806
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
2838
2807
Layers : [
2839
2808
'arn:of:layer' ,
2840
- { Ref : 'KubectlLayer600207B5 ' } ,
2809
+ { Ref : 'awscdkawseksKubectlProviderKubectlLayerA7F2FE55 ' } ,
2841
2810
] ,
2842
2811
} ) ;
2843
2812
} ) ;
@@ -2870,42 +2839,6 @@ describe('cluster', () => {
2870
2839
} ) ;
2871
2840
} ) ;
2872
2841
2873
- test ( 'custom memory size for kubectl provider' , ( ) => {
2874
- // GIVEN
2875
- const { stack, vpc, app } = testFixture ( ) ;
2876
-
2877
- // WHEN
2878
- new eks . Cluster ( stack , 'Cluster' , {
2879
- vpc,
2880
- version : CLUSTER_VERSION ,
2881
- kubectlMemory : cdk . Size . gibibytes ( 2 ) ,
2882
- } ) ;
2883
-
2884
- // THEN
2885
- const casm = app . synth ( ) ;
2886
- const providerNestedStackTemplate = JSON . parse ( fs . readFileSync ( path . join ( casm . directory , 'StackawscdkawseksKubectlProvider7346F799.nested.template.json' ) , 'utf-8' ) ) ;
2887
- expect ( providerNestedStackTemplate ?. Resources ?. Handler886CB40B ?. Properties ?. MemorySize ) . toEqual ( 2048 ) ;
2888
- } ) ;
2889
-
2890
- test ( 'custom memory size for imported clusters' , ( ) => {
2891
- // GIVEN
2892
- const { stack, app } = testFixture ( ) ;
2893
-
2894
- // WHEN
2895
- const cluster = eks . Cluster . fromClusterAttributes ( stack , 'Imported' , {
2896
- clusterName : 'my-cluster' ,
2897
- kubectlRoleArn : 'arn:aws:iam::123456789012:role/MyRole' ,
2898
- kubectlMemory : cdk . Size . gibibytes ( 4 ) ,
2899
- } ) ;
2900
-
2901
- cluster . addManifest ( 'foo' , { bar : 123 } ) ;
2902
-
2903
- // THEN
2904
- const casm = app . synth ( ) ;
2905
- const providerNestedStackTemplate = JSON . parse ( fs . readFileSync ( path . join ( casm . directory , 'StackStackImported1CBA9C50KubectlProviderAA00BA49.nested.template.json' ) , 'utf-8' ) ) ;
2906
- expect ( providerNestedStackTemplate ?. Resources ?. Handler886CB40B ?. Properties ?. MemorySize ) . toEqual ( 4096 ) ;
2907
- } ) ;
2908
-
2909
2842
test ( 'create a cluster using custom kubernetes network config' , ( ) => {
2910
2843
// GIVEN
2911
2844
const { stack } = testFixture ( ) ;
0 commit comments