Skip to content

fix(emr): [121999419]support scene_name #3189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3189.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_emr_cluster: support scene_name
```
13 changes: 12 additions & 1 deletion tencentcloud/services/emr/resource_tc_emr_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ func ResourceTencentCloudEmrCluster() *schema.Resource {
Optional: true,
Description: "Access the external file system.",
},
"scene_name": {
Type: schema.TypeString,
Optional: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

支持Update么?

Computed: true,
Description: "Scene-based value:\n" +
" - Hadoop-Kudu\n" +
" - Hadoop-Zookeeper\n" +
" - Hadoop-Presto\n" +
" - Hadoop-Hbase.",
},
"instance_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -307,7 +317,7 @@ func resourceTencentCloudEmrClusterUpdate(d *schema.ResourceData, meta interface
logId := tccommon.GetLogId(tccommon.ContextNil)
ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId)

immutableFields := []string{"auto_renew", "placement", "placement_info", "display_strategy", "login_settings", "extend_fs_field"}
immutableFields := []string{"auto_renew", "placement", "placement_info", "display_strategy", "login_settings", "extend_fs_field", "scene_name"}
for _, f := range immutableFields {
if d.HasChange(f) {
return fmt.Errorf("cannot update argument `%s`", f)
Expand Down Expand Up @@ -632,6 +642,7 @@ func resourceTencentCloudEmrClusterRead(d *schema.ResourceData, meta interface{}
return err
}
if instance != nil {
_ = d.Set("scene_name", instance.SceneName)
_ = d.Set("product_id", instance.ProductId)
_ = d.Set("vpc_settings", map[string]interface{}{
"vpc_id": *instance.UniqVpcId,
Expand Down
77 changes: 77 additions & 0 deletions tencentcloud/services/emr/resource_tc_emr_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,29 @@ func TestAccTencentCloudEmrClusterResource_Basic(t *testing.T) {
})
}

func TestAccTencentCloudEmrClusterResource_Zookeeper(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { tcacctest.AccPreCheck(t) },
Providers: tcacctest.AccProviders,
Steps: []resource.TestStep{
{
Config: testEmrZookeeper,
Check: resource.ComposeTestCheckFunc(
testAccCheckEmrExists("tencentcloud_emr_cluster.emr_zookeeper"),
resource.TestCheckResourceAttr("tencentcloud_emr_cluster.emr_zookeeper", "scene_name", "Hadoop-Zookeeper"),
resource.TestCheckResourceAttr("tencentcloud_emr_cluster.emr_zookeeper", "resource_spec.0.common_count", "3"),
),
},
{
ResourceName: "tencentcloud_emr_cluster.emr_zookeeper",
ImportState: true,
ImportStateVerifyIgnore: []string{"display_strategy", "placement", "time_span", "time_unit", "login_settings", "terminate_node_info"},
},
},
})
}

func TestAccTencentCloudEmrClusterResource_PreExecutedFileSettings(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -668,3 +691,57 @@ resource "tencentcloud_emr_cluster" "emrrrr" {
need_master_wan = "NOT_NEED_MASTER_WAN"
}
`

const testEmrZookeeper = tcacctest.DefaultEMRVariable + `
data "tencentcloud_instance_types" "cvm2c4m" {
exclude_sold_out=true
cpu_core_count=2
memory_size=4
filter {
name = "instance-charge-type"
values = ["POSTPAID_BY_HOUR"]
}
filter {
name = "zone"
values = ["ap-guangzhou-3"]
}
}

resource "tencentcloud_emr_cluster" "emr_zookeeper" {
product_id = 37
vpc_settings = {
vpc_id = var.vpc_id
subnet_id = var.subnet_id
}
softwares = [
"zookeeper-3.6.3",
]
support_ha = 1
instance_name = "emr-test-demo"
resource_spec {
common_resource_spec {
mem_size = 4096
cpu = 2
disk_size = 100
disk_type = "CLOUD_SSD"
spec = "CVM.${data.tencentcloud_instance_types.cvm2c4m.instance_types.0.family}"
storage_type = 4
root_size = 50
}
common_count = 3
}
login_settings = {
password = "Tencent@cloud123"
}
time_span = 3600
time_unit = "s"
pay_mode = 0
placement_info {
zone = "ap-guangzhou-3"
project_id = 0
}
sg_id = var.sg_id
need_master_wan = "NOT_NEED_MASTER_WAN"
scene_name = "Hadoop-Zookeeper"
}
`
4 changes: 4 additions & 0 deletions tencentcloud/services/emr/service_tencentcloud_emr.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ func (me *EMRService) CreateInstance(ctx context.Context, d *schema.ResourceData
logId := tccommon.GetLogId(ctx)
request := emr.NewCreateInstanceRequest()

if v, ok := d.GetOk("scene_name"); ok {
request.SceneName = helper.String(v.(string))
}

if v, ok := d.GetOk("auto_renew"); ok {
request.AutoRenew = common.Uint64Ptr((uint64)(v.(int)))
}
Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/emr_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ The following arguments are supported:
* `placement` - (Optional, Map, **Deprecated**) It will be deprecated in later versions. Use `placement_info` instead. The location of the instance.
* `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.
* `resource_spec` - (Optional, List) Resource specification of EMR instance.
* `scene_name` - (Optional, String) Scene-based value:
- Hadoop-Kudu
- Hadoop-Zookeeper
- Hadoop-Presto
- Hadoop-Hbase.
* `sg_id` - (Optional, String, ForceNew) The ID of the security group to which the instance belongs, in the form of sg-xxxxxxxx.
* `tags` - (Optional, Map) Tag description list.
* `terminate_node_info` - (Optional, List) Terminate nodes. Note: it only works when the number of nodes decreases.
Expand Down
Loading