Skip to content

Commit ca755c1

Browse files
tongyimingmikatong
and
mikatong
authored
fix(emr): [121999419]support scene_name (#3189)
* support scene_name * add changelog * update --------- Co-authored-by: mikatong <[email protected]>
1 parent 131162f commit ca755c1

File tree

5 files changed

+101
-1
lines changed

5 files changed

+101
-1
lines changed

.changelog/3189.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_emr_cluster: support scene_name
3+
```

tencentcloud/services/emr/resource_tc_emr_cluster.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ func ResourceTencentCloudEmrCluster() *schema.Resource {
203203
Optional: true,
204204
Description: "Access the external file system.",
205205
},
206+
"scene_name": {
207+
Type: schema.TypeString,
208+
Optional: true,
209+
Computed: true,
210+
Description: "Scene-based value:\n" +
211+
" - Hadoop-Kudu\n" +
212+
" - Hadoop-Zookeeper\n" +
213+
" - Hadoop-Presto\n" +
214+
" - Hadoop-Hbase.",
215+
},
206216
"instance_id": {
207217
Type: schema.TypeString,
208218
Computed: true,
@@ -307,7 +317,7 @@ func resourceTencentCloudEmrClusterUpdate(d *schema.ResourceData, meta interface
307317
logId := tccommon.GetLogId(tccommon.ContextNil)
308318
ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
309319

310-
immutableFields := []string{"auto_renew", "placement", "placement_info", "display_strategy", "login_settings", "extend_fs_field"}
320+
immutableFields := []string{"auto_renew", "placement", "placement_info", "display_strategy", "login_settings", "extend_fs_field", "scene_name"}
311321
for _, f := range immutableFields {
312322
if d.HasChange(f) {
313323
return fmt.Errorf("cannot update argument `%s`", f)
@@ -632,6 +642,7 @@ func resourceTencentCloudEmrClusterRead(d *schema.ResourceData, meta interface{}
632642
return err
633643
}
634644
if instance != nil {
645+
_ = d.Set("scene_name", instance.SceneName)
635646
_ = d.Set("product_id", instance.ProductId)
636647
_ = d.Set("vpc_settings", map[string]interface{}{
637648
"vpc_id": *instance.UniqVpcId,

tencentcloud/services/emr/resource_tc_emr_cluster_test.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,29 @@ func TestAccTencentCloudEmrClusterResource_Basic(t *testing.T) {
177177
})
178178
}
179179

180+
func TestAccTencentCloudEmrClusterResource_Zookeeper(t *testing.T) {
181+
t.Parallel()
182+
resource.Test(t, resource.TestCase{
183+
PreCheck: func() { tcacctest.AccPreCheck(t) },
184+
Providers: tcacctest.AccProviders,
185+
Steps: []resource.TestStep{
186+
{
187+
Config: testEmrZookeeper,
188+
Check: resource.ComposeTestCheckFunc(
189+
testAccCheckEmrExists("tencentcloud_emr_cluster.emr_zookeeper"),
190+
resource.TestCheckResourceAttr("tencentcloud_emr_cluster.emr_zookeeper", "scene_name", "Hadoop-Zookeeper"),
191+
resource.TestCheckResourceAttr("tencentcloud_emr_cluster.emr_zookeeper", "resource_spec.0.common_count", "3"),
192+
),
193+
},
194+
{
195+
ResourceName: "tencentcloud_emr_cluster.emr_zookeeper",
196+
ImportState: true,
197+
ImportStateVerifyIgnore: []string{"display_strategy", "placement", "time_span", "time_unit", "login_settings", "terminate_node_info"},
198+
},
199+
},
200+
})
201+
}
202+
180203
func TestAccTencentCloudEmrClusterResource_PreExecutedFileSettings(t *testing.T) {
181204
t.Parallel()
182205
resource.Test(t, resource.TestCase{
@@ -668,3 +691,57 @@ resource "tencentcloud_emr_cluster" "emrrrr" {
668691
need_master_wan = "NOT_NEED_MASTER_WAN"
669692
}
670693
`
694+
695+
const testEmrZookeeper = tcacctest.DefaultEMRVariable + `
696+
data "tencentcloud_instance_types" "cvm2c4m" {
697+
exclude_sold_out=true
698+
cpu_core_count=2
699+
memory_size=4
700+
filter {
701+
name = "instance-charge-type"
702+
values = ["POSTPAID_BY_HOUR"]
703+
}
704+
filter {
705+
name = "zone"
706+
values = ["ap-guangzhou-3"]
707+
}
708+
}
709+
710+
resource "tencentcloud_emr_cluster" "emr_zookeeper" {
711+
product_id = 37
712+
vpc_settings = {
713+
vpc_id = var.vpc_id
714+
subnet_id = var.subnet_id
715+
}
716+
softwares = [
717+
"zookeeper-3.6.3",
718+
]
719+
support_ha = 1
720+
instance_name = "emr-test-demo"
721+
resource_spec {
722+
common_resource_spec {
723+
mem_size = 4096
724+
cpu = 2
725+
disk_size = 100
726+
disk_type = "CLOUD_SSD"
727+
spec = "CVM.${data.tencentcloud_instance_types.cvm2c4m.instance_types.0.family}"
728+
storage_type = 4
729+
root_size = 50
730+
}
731+
common_count = 3
732+
}
733+
login_settings = {
734+
password = "Tencent@cloud123"
735+
}
736+
time_span = 3600
737+
time_unit = "s"
738+
pay_mode = 0
739+
placement_info {
740+
zone = "ap-guangzhou-3"
741+
project_id = 0
742+
}
743+
sg_id = var.sg_id
744+
need_master_wan = "NOT_NEED_MASTER_WAN"
745+
scene_name = "Hadoop-Zookeeper"
746+
}
747+
`

tencentcloud/services/emr/service_tencentcloud_emr.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ func (me *EMRService) CreateInstance(ctx context.Context, d *schema.ResourceData
7777
logId := tccommon.GetLogId(ctx)
7878
request := emr.NewCreateInstanceRequest()
7979

80+
if v, ok := d.GetOk("scene_name"); ok {
81+
request.SceneName = helper.String(v.(string))
82+
}
83+
8084
if v, ok := d.GetOk("auto_renew"); ok {
8185
request.AutoRenew = common.Uint64Ptr((uint64)(v.(int)))
8286
}

website/docs/r/emr_cluster.html.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ The following arguments are supported:
138138
* `placement` - (Optional, Map, **Deprecated**) It will be deprecated in later versions. Use `placement_info` instead. The location of the instance.
139139
* `pre_executed_file_settings` - (Optional, List, ForceNew) Pre executed file settings. It can only be set at the time of creation, and cannot be modified.
140140
* `resource_spec` - (Optional, List) Resource specification of EMR instance.
141+
* `scene_name` - (Optional, String) Scene-based value:
142+
- Hadoop-Kudu
143+
- Hadoop-Zookeeper
144+
- Hadoop-Presto
145+
- Hadoop-Hbase.
141146
* `sg_id` - (Optional, String, ForceNew) The ID of the security group to which the instance belongs, in the form of sg-xxxxxxxx.
142147
* `tags` - (Optional, Map) Tag description list.
143148
* `terminate_node_info` - (Optional, List) Terminate nodes. Note: it only works when the number of nodes decreases.

0 commit comments

Comments
 (0)