Skip to content
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/2960.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_emr_cluster: support param pre_executed_file_settings
```
61 changes: 61 additions & 0 deletions tencentcloud/services/emr/resource_tc_emr_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,67 @@ func ResourceTencentCloudEmrCluster() *schema.Resource {
Computed: true,
Description: "0 means turn off automatic renewal, 1 means turn on automatic renewal. Default is 0.",
},
"pre_executed_file_settings": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: "Pre executed file settings. It can only be set at the time of creation, and cannot be modified.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"args": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "Execution script parameters.",
},
"run_order": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Description: "Run order.",
},
"when_run": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "`resourceAfter` or `clusterAfter`.",
},
"cos_file_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "Script file name.",
},
"cos_file_uri": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "The cos address of the script.",
},
"cos_secret_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "Cos secretId.",
},
"cos_secret_key": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "Cos secretKey.",
},
"remark": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "Remark.",
},
},
},
},
},
}
}
Expand Down
104 changes: 104 additions & 0 deletions tencentcloud/services/emr/resource_tc_emr_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,26 @@ func TestAccTencentCloudEmrClusterResource_Basic(t *testing.T) {
},
})
}

func TestAccTencentCloudEmrClusterResource_PreExecutedFileSettings(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { tcacctest.AccPreCheck(t) },
Providers: tcacctest.AccProviders,
Steps: []resource.TestStep{
{
Config: testEmrBasicPreExecutedFileSettings,
Check: resource.ComposeTestCheckFunc(
testAccCheckEmrExists(testEmrClusterResourceKey),
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "pre_executed_file_settings.#", "1"),
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "pre_executed_file_settings.0.cos_file_name", "test"),
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "pre_executed_file_settings.0.when_run", "resourceAfter"),
resource.TestCheckResourceAttrSet(testEmrClusterResourceKey, "pre_executed_file_settings.0.cos_file_uri"),
),
},
},
})
}
func TestAccTencentCloudEmrClusterResource_Prepay(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -347,6 +367,90 @@ resource "tencentcloud_emr_cluster" "emrrrr" {
}
`

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

resource "tencentcloud_emr_cluster" "emrrrr" {
product_id=38
vpc_settings={
vpc_id=var.vpc_id
subnet_id=var.subnet_id
}
softwares = [
"hdfs-2.8.5",
"knox-1.6.1",
"openldap-2.4.44",
"yarn-2.8.5",
"zookeeper-3.6.3",
]
support_ha=0
instance_name="emr-test-demo"
resource_spec {
master_resource_spec {
mem_size=8192
cpu=4
disk_size=100
disk_type="CLOUD_PREMIUM"
spec="CVM.${data.tencentcloud_instance_types.cvm4c8m.instance_types.0.family}"
storage_type=5
root_size=50
multi_disks {
disk_type = "CLOUD_PREMIUM"
volume = 200
count = 1
}
}
core_resource_spec {
mem_size=8192
cpu=4
disk_size=100
disk_type="CLOUD_PREMIUM"
spec="CVM.${data.tencentcloud_instance_types.cvm4c8m.instance_types.0.family}"
storage_type=5
root_size=50
multi_disks {
disk_type = "CLOUD_PREMIUM"
volume = 100
count = 2
}
}
master_count=1
core_count=2
}
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
tags = {
emr-key = "emr-value"
}
pre_executed_file_settings {
cos_file_name = "test"
cos_file_uri = "https://keep-tf-test-1308726196.cos.ap-guangzhou.myqcloud.com/test/tmp.sh"
when_run = "resourceAfter"
}
}
`

const testEmrBasic_AddCoreNode = tcacctest.DefaultEMRVariable + `
data "tencentcloud_instance_types" "cvm4c8m" {
exclude_sold_out=true
Expand Down
32 changes: 32 additions & 0 deletions tencentcloud/services/emr/service_tencentcloud_emr.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,38 @@ func (me *EMRService) CreateInstance(ctx context.Context, d *schema.ResourceData
request.Tags = emrTags
}

if v, ok := d.GetOk("pre_executed_file_settings"); ok {
preExecutedFileSettings := v.([]interface{})
for _, preExecutedFileSetting := range preExecutedFileSettings {
preExecutedFileSettingMap := preExecutedFileSetting.(map[string]interface{})
tmpPreExecutedFileSetting := &emr.PreExecuteFileSettings{}
if v, ok := preExecutedFileSettingMap["args"]; ok {
tmpPreExecutedFileSetting.Args = helper.InterfacesStringsPoint(v.([]interface{}))
}
if v, ok := preExecutedFileSettingMap["run_order"]; ok {
tmpPreExecutedFileSetting.RunOrder = helper.IntInt64(v.(int))
}
if v, ok := preExecutedFileSettingMap["when_run"]; ok {
tmpPreExecutedFileSetting.WhenRun = helper.String(v.(string))
}
if v, ok := preExecutedFileSettingMap["cos_file_name"]; ok {
tmpPreExecutedFileSetting.CosFileName = helper.String(v.(string))
}
if v, ok := preExecutedFileSettingMap["cos_file_uri"]; ok {
tmpPreExecutedFileSetting.CosFileURI = helper.String(v.(string))
}
if v, ok := preExecutedFileSettingMap["cos_secret_id"]; ok {
tmpPreExecutedFileSetting.CosSecretId = helper.String(v.(string))
}
if v, ok := preExecutedFileSettingMap["cos_secret_key"]; ok {
tmpPreExecutedFileSetting.CosSecretKey = helper.String(v.(string))
}
if v, ok := preExecutedFileSettingMap["remark"]; ok {
tmpPreExecutedFileSetting.Remark = helper.String(v.(string))
}
request.PreExecutedFileSettings = append(request.PreExecutedFileSettings, tmpPreExecutedFileSetting)
}
}
ratelimit.Check(request.GetAction())
//API: https://cloud.tencent.com/document/api/589/34261
response, err := me.client.UseEmrClient().CreateInstance(request)
Expand Down
12 changes: 12 additions & 0 deletions website/docs/r/emr_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ The following arguments are supported:
By default, the cluster Master node internet is enabled.
* `placement_info` - (Optional, List) The location of the instance.
* `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.
* `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.
Expand Down Expand Up @@ -242,6 +243,17 @@ The `placement_info` object supports the following:
* `zone` - (Required, String) Zone.
* `project_id` - (Optional, Int) Project id.

The `pre_executed_file_settings` object supports the following:

* `args` - (Optional, List, ForceNew) Execution script parameters.
* `cos_file_name` - (Optional, String, ForceNew) Script file name.
* `cos_file_uri` - (Optional, String, ForceNew) The cos address of the script.
* `cos_secret_id` - (Optional, String, ForceNew) Cos secretId.
* `cos_secret_key` - (Optional, String, ForceNew) Cos secretKey.
* `remark` - (Optional, String, ForceNew) Remark.
* `run_order` - (Optional, Int, ForceNew) Run order.
* `when_run` - (Optional, String, ForceNew) `resourceAfter` or `clusterAfter`.

The `resource_spec` object supports the following:

* `common_count` - (Optional, Int, ForceNew) The number of common node.
Expand Down
Loading