From 46742215df07ceeba4536e653f54daf92f750d7d Mon Sep 17 00:00:00 2001 From: mikatong Date: Wed, 16 Mar 2022 16:05:50 +0800 Subject: [PATCH] fix: emr destroy && support need_master_wan param --- tencentcloud/extension_emr.go | 7 +++++++ tencentcloud/resource_tc_emr_cluster.go | 14 ++++++++++++++ tencentcloud/service_tencentcloud_emr.go | 3 ++- website/docs/r/emr_cluster.html.markdown | 4 ++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tencentcloud/extension_emr.go b/tencentcloud/extension_emr.go index 8745c53c20..e585ced66c 100644 --- a/tencentcloud/extension_emr.go +++ b/tencentcloud/extension_emr.go @@ -15,6 +15,13 @@ const ( DisplayStrategyIsclusterList = "clusterList" ) +const ( + EMR_MASTER_WAN_TYPE_NEED_MASTER_WAN = "NEED_MASTER_WAN" + EMR_MASTER_WAN_TYPE_NOT_NEED_MASTER_WAN = "NOT_NEED_MASTER_WAN" +) + +var EMR_MASTER_WAN_TYPES = []string{EMR_MASTER_WAN_TYPE_NEED_MASTER_WAN, EMR_MASTER_WAN_TYPE_NOT_NEED_MASTER_WAN} + func buildResourceSpecSchema() *schema.Schema { return &schema.Schema{ Type: schema.TypeList, diff --git a/tencentcloud/resource_tc_emr_cluster.go b/tencentcloud/resource_tc_emr_cluster.go index b22ef40c14..1387030bc7 100644 --- a/tencentcloud/resource_tc_emr_cluster.go +++ b/tencentcloud/resource_tc_emr_cluster.go @@ -176,6 +176,17 @@ func resourceTencentCloudEmrCluster() *schema.Resource { Computed: true, Description: "Created EMR instance id.", }, + "need_master_wan": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: EMR_MASTER_WAN_TYPE_NEED_MASTER_WAN, + ValidateFunc: validateAllowedStringValue(EMR_MASTER_WAN_TYPES), + Description: `Whether to enable the cluster Master node public network. Value range: + - NEED_MASTER_WAN: Indicates that the cluster Master node public network is enabled. + - NOT_NEED_MASTER_WAN: Indicates that it is not turned on. + By default, the cluster Master node internet is enabled.`, + }, }, } } @@ -307,6 +318,9 @@ func resourceTencentCloudEmrClusterDelete(d *schema.ResourceData, meta interface if e.GetCode() == "InternalError.ClusterNotFound" { return nil } + if e.GetCode() == "UnauthorizedOperation" { + return nil + } } if len(clusters) > 0 { diff --git a/tencentcloud/service_tencentcloud_emr.go b/tencentcloud/service_tencentcloud_emr.go index d83a031d74..3dc55a0d23 100644 --- a/tencentcloud/service_tencentcloud_emr.go +++ b/tencentcloud/service_tencentcloud_emr.go @@ -121,6 +121,8 @@ func (me *EMRService) CreateInstance(ctx context.Context, d *schema.ResourceData request.InstanceName = common.StringPtr(v.(string)) } + needMasterWan := d.Get("need_master_wan").(string) + request.NeedMasterWan = common.StringPtr(needMasterWan) payMode := d.Get("pay_mode") request.PayMode = common.Uint64Ptr((uint64)(payMode.(int))) if v, ok := d.GetOk("placement"); ok { @@ -186,7 +188,6 @@ func (me *EMRService) DescribeInstances(ctx context.Context, filters map[string] if v, ok := filters["project_id"]; ok { request.ProjectId = common.Int64Ptr(v.(int64)) } - request.ProjectId = helper.IntInt64(-1) response, err := me.client.UseEmrClient().DescribeInstances(request) if err != nil { diff --git a/website/docs/r/emr_cluster.html.markdown b/website/docs/r/emr_cluster.html.markdown index 40616cb6c8..629a27103c 100644 --- a/website/docs/r/emr_cluster.html.markdown +++ b/website/docs/r/emr_cluster.html.markdown @@ -73,6 +73,10 @@ The following arguments are supported: 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. * `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). * `vpc_settings` - (Required, ForceNew) The private net config of EMR instance. +* `need_master_wan` - (Optional, ForceNew) Whether to enable the cluster Master node public network. Value range: + - NEED_MASTER_WAN: Indicates that the cluster Master node public network is enabled. + - NOT_NEED_MASTER_WAN: Indicates that it is not turned on. + By default, the cluster Master node internet is enabled. * `resource_spec` - (Optional) Resource specification of EMR instance. The `resource_spec` object supports the following: