@@ -1058,6 +1058,11 @@ func resourceTencentCloudTkeCluster() *schema.Resource {
1058
1058
" If this field is set 'true', the field below `worker_config` must be set." +
1059
1059
" Because only cluster with node is allowed enable access endpoint." ,
1060
1060
},
1061
+ "cluster_internet_security_group" : {
1062
+ Type : schema .TypeString ,
1063
+ Optional : true ,
1064
+ Description : "Specify security group, NOTE: This argument must not be empty if cluster internet enabled." ,
1065
+ },
1061
1066
"managed_cluster_internet_security_policies" : {
1062
1067
Type : schema .TypeList ,
1063
1068
Optional : true ,
@@ -1845,17 +1850,18 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
1845
1850
ctx := context .WithValue (context .TODO (), logIdKey , logId )
1846
1851
1847
1852
var (
1848
- basic ClusterBasicSetting
1849
- advanced ClusterAdvancedSettings
1850
- cvms RunInstancesForNode
1851
- iAdvanced InstanceAdvancedSettings
1852
- iDiskMountSettings []* tke.InstanceDataDiskMountSetting
1853
- cidrSet ClusterCidrSettings
1854
- securityPolicies []string
1855
- extensionAddons []* tke.ExtensionAddon
1856
- clusterInternet = d .Get ("cluster_internet" ).(bool )
1857
- clusterIntranet = d .Get ("cluster_intranet" ).(bool )
1858
- intranetSubnetId = d .Get ("cluster_intranet_subnet_id" ).(string )
1853
+ basic ClusterBasicSetting
1854
+ advanced ClusterAdvancedSettings
1855
+ cvms RunInstancesForNode
1856
+ iAdvanced InstanceAdvancedSettings
1857
+ iDiskMountSettings []* tke.InstanceDataDiskMountSetting
1858
+ cidrSet ClusterCidrSettings
1859
+ securityPolicies []string
1860
+ extensionAddons []* tke.ExtensionAddon
1861
+ clusterInternet = d .Get ("cluster_internet" ).(bool )
1862
+ clusterIntranet = d .Get ("cluster_intranet" ).(bool )
1863
+ intranetSubnetId = d .Get ("cluster_intranet_subnet_id" ).(string )
1864
+ clusterInternetSecurityGroup = d .Get ("cluster_internet_security_group" ).(string )
1859
1865
)
1860
1866
1861
1867
if temp , ok := d .GetOkExists ("managed_cluster_internet_security_policies" ); ok {
@@ -2189,7 +2195,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
2189
2195
//intranet
2190
2196
if clusterIntranet {
2191
2197
err = resource .Retry (writeRetryTimeout , func () * resource.RetryError {
2192
- inErr := service .CreateClusterEndpoint (ctx , id , intranetSubnetId , false )
2198
+ inErr := service .CreateClusterEndpoint (ctx , id , intranetSubnetId , clusterInternetSecurityGroup , false )
2193
2199
if inErr != nil {
2194
2200
return retryError (inErr )
2195
2201
}
@@ -2199,7 +2205,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
2199
2205
return err
2200
2206
}
2201
2207
err = resource .Retry (2 * readRetryTimeout , func () * resource.RetryError {
2202
- status , message , inErr := service .DescribeClusterEndpointStatus (ctx , id )
2208
+ status , message , inErr := service .DescribeClusterEndpointStatus (ctx , id , false )
2203
2209
if inErr != nil {
2204
2210
return retryError (inErr )
2205
2211
}
@@ -2221,7 +2227,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
2221
2227
//TKE_DEPLOY_TYPE_MANAGED Open the internet
2222
2228
if clusterDeployType == TKE_DEPLOY_TYPE_MANAGED && clusterInternet {
2223
2229
err = resource .Retry (writeRetryTimeout , func () * resource.RetryError {
2224
- inErr := service .CreateClusterEndpointVip (ctx , id , securityPolicies )
2230
+ inErr := service .CreateClusterEndpointVip (ctx , id , clusterInternetSecurityGroup )
2225
2231
if inErr != nil {
2226
2232
return retryError (inErr )
2227
2233
}
@@ -2231,7 +2237,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
2231
2237
return err
2232
2238
}
2233
2239
err = resource .Retry (2 * readRetryTimeout , func () * resource.RetryError {
2234
- status , message , inErr := service .DescribeClusterEndpointVipStatus (ctx , id )
2240
+ status , message , inErr := service .DescribeClusterEndpointVipStatus (ctx , id , true )
2235
2241
if inErr != nil {
2236
2242
return retryError (inErr )
2237
2243
}
@@ -2253,7 +2259,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
2253
2259
//TKE_DEPLOY_TYPE_INDEPENDENT Open the internet
2254
2260
if clusterDeployType == TKE_DEPLOY_TYPE_INDEPENDENT && clusterInternet {
2255
2261
err = resource .Retry (writeRetryTimeout , func () * resource.RetryError {
2256
- inErr := service .CreateClusterEndpoint (ctx , id , "" , true )
2262
+ inErr := service .CreateClusterEndpoint (ctx , id , "" , clusterInternetSecurityGroup , true )
2257
2263
if inErr != nil {
2258
2264
return retryError (inErr )
2259
2265
}
@@ -2263,7 +2269,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
2263
2269
return err
2264
2270
}
2265
2271
err = resource .Retry (2 * readRetryTimeout , func () * resource.RetryError {
2266
- status , message , inErr := service .DescribeClusterEndpointStatus (ctx , id )
2272
+ status , message , inErr := service .DescribeClusterEndpointStatus (ctx , id , true )
2267
2273
if inErr != nil {
2268
2274
return retryError (inErr )
2269
2275
}
@@ -2504,19 +2510,19 @@ func resourceTencentCloudTkeClusterRead(d *schema.ResourceData, meta interface{}
2504
2510
_ = d .Set ("pgw_endpoint" , emptyStrFunc (securityRet .Response .PgwEndpoint ))
2505
2511
_ = d .Set ("security_policy" , policies )
2506
2512
2507
- if v , ok := d .GetOk ("worker_config" ); ok && len (v .([]interface {})) > 0 {
2508
- if emptyStrFunc (securityRet .Response .ClusterExternalEndpoint ) == "" {
2509
- _ = d .Set ("cluster_internet" , false )
2510
- } else {
2511
- _ = d .Set ("cluster_internet" , true )
2512
- }
2513
-
2514
- if emptyStrFunc (securityRet .Response .PgwEndpoint ) == "" {
2515
- _ = d .Set ("cluster_intranet" , false )
2516
- } else {
2517
- _ = d .Set ("cluster_intranet" , true )
2518
- }
2519
- }
2513
+ // if v, ok := d.GetOk("worker_config"); ok && len(v.([]interface{})) > 0 {
2514
+ // if emptyStrFunc(securityRet.Response.ClusterExternalEndpoint) == "" {
2515
+ // _ = d.Set("cluster_internet", false)
2516
+ // } else {
2517
+ // _ = d.Set("cluster_internet", true)
2518
+ // }
2519
+ //
2520
+ // if emptyStrFunc(securityRet.Response.PgwEndpoint) == "" {
2521
+ // _ = d.Set("cluster_intranet", false)
2522
+ // } else {
2523
+ // _ = d.Set("cluster_intranet", true)
2524
+ // }
2525
+ // }
2520
2526
2521
2527
var globalConfig * tke.ClusterAsGroupOption
2522
2528
err = resource .Retry (readRetryTimeout , func () * resource.RetryError {
@@ -2577,10 +2583,11 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2577
2583
}
2578
2584
2579
2585
var (
2580
- securityPolicies []string
2581
- clusterInternet = d .Get ("cluster_internet" ).(bool )
2582
- clusterIntranet = d .Get ("cluster_intranet" ).(bool )
2583
- intranetSubnetId = d .Get ("cluster_intranet_subnet_id" ).(string )
2586
+ securityPolicies []string
2587
+ clusterInternet = d .Get ("cluster_internet" ).(bool )
2588
+ clusterIntranet = d .Get ("cluster_intranet" ).(bool )
2589
+ intranetSubnetId = d .Get ("cluster_intranet_subnet_id" ).(string )
2590
+ clusterInternetSecurityGroup = d .Get ("cluster_internet_security_group" ).(string )
2584
2591
)
2585
2592
2586
2593
if temp , ok := d .GetOkExists ("managed_cluster_internet_security_policies" ); ok {
@@ -2608,7 +2615,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2608
2615
//open intranet
2609
2616
if clusterIntranet {
2610
2617
err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
2611
- inErr := tkeService .CreateClusterEndpoint (ctx , id , intranetSubnetId , false )
2618
+ inErr := tkeService .CreateClusterEndpoint (ctx , id , intranetSubnetId , clusterInternetSecurityGroup , false )
2612
2619
if inErr != nil {
2613
2620
return retryError (inErr )
2614
2621
}
@@ -2618,7 +2625,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2618
2625
return err
2619
2626
}
2620
2627
err = resource .Retry (2 * readRetryTimeout , func () * resource.RetryError {
2621
- status , message , inErr := tkeService .DescribeClusterEndpointStatus (ctx , id )
2628
+ status , message , inErr := tkeService .DescribeClusterEndpointStatus (ctx , id , false )
2622
2629
if inErr != nil {
2623
2630
return retryError (inErr )
2624
2631
}
@@ -2648,7 +2655,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2648
2655
return err
2649
2656
}
2650
2657
err = resource .Retry (2 * readRetryTimeout , func () * resource.RetryError {
2651
- status , message , inErr := tkeService .DescribeClusterEndpointStatus (ctx , id )
2658
+ status , message , inErr := tkeService .DescribeClusterEndpointStatus (ctx , id , false )
2652
2659
if inErr != nil {
2653
2660
return retryError (inErr )
2654
2661
}
@@ -2675,7 +2682,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2675
2682
//TKE_DEPLOY_TYPE_INDEPENDENT open internet
2676
2683
if clusterDeployType == TKE_DEPLOY_TYPE_INDEPENDENT && clusterInternet {
2677
2684
err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
2678
- inErr := tkeService .CreateClusterEndpoint (ctx , id , "" , true )
2685
+ inErr := tkeService .CreateClusterEndpoint (ctx , id , "" , clusterInternetSecurityGroup , true )
2679
2686
if inErr != nil {
2680
2687
return retryError (inErr )
2681
2688
}
@@ -2685,7 +2692,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2685
2692
return err
2686
2693
}
2687
2694
err = resource .Retry (2 * readRetryTimeout , func () * resource.RetryError {
2688
- status , message , inErr := tkeService .DescribeClusterEndpointStatus (ctx , id )
2695
+ status , message , inErr := tkeService .DescribeClusterEndpointStatus (ctx , id , true )
2689
2696
if inErr != nil {
2690
2697
return retryError (inErr )
2691
2698
}
@@ -2717,7 +2724,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2717
2724
return err
2718
2725
}
2719
2726
err = resource .Retry (2 * readRetryTimeout , func () * resource.RetryError {
2720
- status , message , inErr := tkeService .DescribeClusterEndpointStatus (ctx , id )
2727
+ status , message , inErr := tkeService .DescribeClusterEndpointStatus (ctx , id , true )
2721
2728
if inErr != nil {
2722
2729
return retryError (inErr )
2723
2730
}
@@ -2739,7 +2746,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2739
2746
//TKE_DEPLOY_TYPE_MANAGED open internet
2740
2747
if clusterDeployType == TKE_DEPLOY_TYPE_MANAGED && clusterInternet {
2741
2748
err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
2742
- inErr := tkeService .CreateClusterEndpointVip (ctx , id , securityPolicies )
2749
+ inErr := tkeService .CreateClusterEndpointVip (ctx , id , clusterInternetSecurityGroup )
2743
2750
if inErr != nil {
2744
2751
return retryError (inErr )
2745
2752
}
@@ -2749,7 +2756,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2749
2756
return err
2750
2757
}
2751
2758
err = resource .Retry (2 * readRetryTimeout , func () * resource.RetryError {
2752
- status , message , inErr := tkeService .DescribeClusterEndpointVipStatus (ctx , id )
2759
+ status , message , inErr := tkeService .DescribeClusterEndpointVipStatus (ctx , id , true )
2753
2760
if inErr != nil {
2754
2761
return retryError (inErr )
2755
2762
}
@@ -2781,7 +2788,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
2781
2788
return err
2782
2789
}
2783
2790
err = resource .Retry (2 * readRetryTimeout , func () * resource.RetryError {
2784
- status , message , inErr := tkeService .DescribeClusterEndpointVipStatus (ctx , id )
2791
+ status , message , inErr := tkeService .DescribeClusterEndpointVipStatus (ctx , id , true )
2785
2792
if inErr != nil {
2786
2793
return retryError (inErr )
2787
2794
}
0 commit comments