Skip to content

Commit 55b26ac

Browse files
tongyimingmikatong
andauthored
fix: emr destroy && support need_master_wan param (#908)
Co-authored-by: mikatong <mikatong@tencent.com>
1 parent f39ea1b commit 55b26ac

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

tencentcloud/extension_emr.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ const (
1515
DisplayStrategyIsclusterList = "clusterList"
1616
)
1717

18+
const (
19+
EMR_MASTER_WAN_TYPE_NEED_MASTER_WAN = "NEED_MASTER_WAN"
20+
EMR_MASTER_WAN_TYPE_NOT_NEED_MASTER_WAN = "NOT_NEED_MASTER_WAN"
21+
)
22+
23+
var EMR_MASTER_WAN_TYPES = []string{EMR_MASTER_WAN_TYPE_NEED_MASTER_WAN, EMR_MASTER_WAN_TYPE_NOT_NEED_MASTER_WAN}
24+
1825
func buildResourceSpecSchema() *schema.Schema {
1926
return &schema.Schema{
2027
Type: schema.TypeList,

tencentcloud/resource_tc_emr_cluster.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ func resourceTencentCloudEmrCluster() *schema.Resource {
176176
Computed: true,
177177
Description: "Created EMR instance id.",
178178
},
179+
"need_master_wan": {
180+
Type: schema.TypeString,
181+
Optional: true,
182+
ForceNew: true,
183+
Default: EMR_MASTER_WAN_TYPE_NEED_MASTER_WAN,
184+
ValidateFunc: validateAllowedStringValue(EMR_MASTER_WAN_TYPES),
185+
Description: `Whether to enable the cluster Master node public network. Value range:
186+
- NEED_MASTER_WAN: Indicates that the cluster Master node public network is enabled.
187+
- NOT_NEED_MASTER_WAN: Indicates that it is not turned on.
188+
By default, the cluster Master node internet is enabled.`,
189+
},
179190
},
180191
}
181192
}
@@ -307,6 +318,9 @@ func resourceTencentCloudEmrClusterDelete(d *schema.ResourceData, meta interface
307318
if e.GetCode() == "InternalError.ClusterNotFound" {
308319
return nil
309320
}
321+
if e.GetCode() == "UnauthorizedOperation" {
322+
return nil
323+
}
310324
}
311325

312326
if len(clusters) > 0 {

tencentcloud/service_tencentcloud_emr.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ func (me *EMRService) CreateInstance(ctx context.Context, d *schema.ResourceData
121121
request.InstanceName = common.StringPtr(v.(string))
122122
}
123123

124+
needMasterWan := d.Get("need_master_wan").(string)
125+
request.NeedMasterWan = common.StringPtr(needMasterWan)
124126
payMode := d.Get("pay_mode")
125127
request.PayMode = common.Uint64Ptr((uint64)(payMode.(int)))
126128
if v, ok := d.GetOk("placement"); ok {
@@ -186,7 +188,6 @@ func (me *EMRService) DescribeInstances(ctx context.Context, filters map[string]
186188
if v, ok := filters["project_id"]; ok {
187189
request.ProjectId = common.Int64Ptr(v.(int64))
188190
}
189-
request.ProjectId = helper.IntInt64(-1)
190191
response, err := me.client.UseEmrClient().DescribeInstances(request)
191192

192193
if err != nil {

website/docs/r/emr_cluster.html.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ The following arguments are supported:
7373
When TimeUnit is m, the number filled in by this parameter indicates the length of purchase of the monthly instance of the package year, such as 1 for one month of purchase.
7474
* `time_unit` - (Required) The unit of time in which the instance was purchased. When PayMode is 0, TimeUnit can only take values of s(second). When PayMode is 1, TimeUnit can only take the value m(month).
7575
* `vpc_settings` - (Required, ForceNew) The private net config of EMR instance.
76+
* `need_master_wan` - (Optional, ForceNew) Whether to enable the cluster Master node public network. Value range:
77+
- NEED_MASTER_WAN: Indicates that the cluster Master node public network is enabled.
78+
- NOT_NEED_MASTER_WAN: Indicates that it is not turned on.
79+
By default, the cluster Master node internet is enabled.
7680
* `resource_spec` - (Optional) Resource specification of EMR instance.
7781

7882
The `resource_spec` object supports the following:

0 commit comments

Comments
 (0)