diff --git a/.changelog/2131.txt b/.changelog/2131.txt new file mode 100644 index 0000000000..1e8e0a1e84 --- /dev/null +++ b/.changelog/2131.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +tencentcloud_ses_black_list_delete +``` \ No newline at end of file diff --git a/tencentcloud/provider.go b/tencentcloud/provider.go index a19957e523..295c9d3f3e 100644 --- a/tencentcloud/provider.go +++ b/tencentcloud/provider.go @@ -1211,6 +1211,7 @@ Simple Email Service(SES) tencentcloud_ses_send_email tencentcloud_ses_batch_send_email tencentcloud_ses_verify_domain + tencentcloud_ses_black_list_delete Security Token Service(STS) Data Source @@ -2816,6 +2817,7 @@ func Provider() *schema.Provider { "tencentcloud_ses_send_email": resourceTencentCloudSesSendEmail(), "tencentcloud_ses_batch_send_email": resourceTencentCloudSesBatchSendEmail(), "tencentcloud_ses_verify_domain": resourceTencentCloudSesVerifyDomain(), + "tencentcloud_ses_black_list_delete": resourceTencentCloudSesBlackListDelete(), "tencentcloud_sms_sign": resourceTencentCloudSmsSign(), "tencentcloud_sms_template": resourceTencentCloudSmsTemplate(), "tencentcloud_dcdb_account": resourceTencentCloudDcdbAccount(), diff --git a/tencentcloud/resource_tc_ses_black_list_delete.go b/tencentcloud/resource_tc_ses_black_list_delete.go new file mode 100644 index 0000000000..e50fdb9a05 --- /dev/null +++ b/tencentcloud/resource_tc_ses_black_list_delete.go @@ -0,0 +1,90 @@ +/* +Provides a resource to create a ses black_list + +~> **NOTE:** Used to remove email addresses from blacklists. + +Example Usage + +```hcl +resource "tencentcloud_ses_black_list_delete" "black_list" { + email_address = "terraform-tf@gmail.com" +} +``` +*/ +package tencentcloud + +import ( + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + ses "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ses/v20201002" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudSesBlackListDelete() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudSesBlackListDeleteCreate, + Read: resourceTencentCloudSesBlackListDeleteRead, + Delete: resourceTencentCloudSesBlackListDeleteDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "email_address": { + Required: true, + ForceNew: true, + Type: schema.TypeString, + Description: "Email addresses to be unblocklisted.", + }, + }, + } +} + +func resourceTencentCloudSesBlackListDeleteCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_ses_black_list_delete.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = ses.NewDeleteBlackListRequest() + emailAddress string + ) + if v, ok := d.GetOk("email_address"); ok { + emailAddress = v.(string) + request.EmailAddressList = append(request.EmailAddressList, helper.String(v.(string))) + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseSesClient().DeleteBlackList(request) + if e != nil { + return retryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s operate ses BlackList failed, reason:%+v", logId, err) + return err + } + + d.SetId(emailAddress) + + return resourceTencentCloudSesBlackListDeleteRead(d, meta) +} + +func resourceTencentCloudSesBlackListDeleteRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_ses_black_list_delete.read")() + defer inconsistentCheck(d, meta)() + + return nil +} + +func resourceTencentCloudSesBlackListDeleteDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_ses_black_list_delete.delete")() + defer inconsistentCheck(d, meta)() + + return nil +} diff --git a/tencentcloud/resource_tc_ses_black_list_delete_test.go b/tencentcloud/resource_tc_ses_black_list_delete_test.go new file mode 100644 index 0000000000..4d9e8cca4d --- /dev/null +++ b/tencentcloud/resource_tc_ses_black_list_delete_test.go @@ -0,0 +1,50 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccTencentNeedFixCloudSesBlackListResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccStepSetRegion(t, "ap-hongkong") + testAccPreCheckBusiness(t, ACCOUNT_TYPE_SES) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccSesBlackList, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_ses_black_list_delete.black_list", "id"), + ), + }, + }, + }) +} + +const testAccSesBlackList = ` + +resource "tencentcloud_ses_send_email" "send_email" { + from_email_address = "aaa@iac-tf.cloud" + destination = ["terraform-tf@gmail.com"] + subject = "test subject" + reply_to_addresses = "aaa@iac-tf.cloud" + + template { + template_id = 99629 + template_data = "{\"name\":\"xxx\",\"age\":\"xx\"}" + } + + unsubscribe = "1" + trigger_type = 1 +} + +resource "tencentcloud_ses_black_list_delete" "black_list" { + email_address = "terraform-tf@gmail.com" + depends_on = [ tencentcloud_ses_send_email.send_email ] +} + +` diff --git a/website/docs/r/ses_black_list.html.markdown b/website/docs/r/ses_black_list.html.markdown new file mode 100644 index 0000000000..7037ffd942 --- /dev/null +++ b/website/docs/r/ses_black_list.html.markdown @@ -0,0 +1,37 @@ +--- +subcategory: "Simple Email Service(SES)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_ses_black_list" +sidebar_current: "docs-tencentcloud-resource-ses_black_list" +description: |- + Provides a resource to create a ses black_list +--- + +# tencentcloud_ses_black_list + +Provides a resource to create a ses black_list + +~> **NOTE:** Used to remove email addresses from blacklists. + +## Example Usage + +```hcl +resource "tencentcloud_ses_black_list" "black_list" { + email_address = "terraform-tf@gmail.com" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `email_address` - (Required, String, ForceNew) Email addresses to be unblocklisted. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. + + + diff --git a/website/docs/r/ses_black_list_delete.html.markdown b/website/docs/r/ses_black_list_delete.html.markdown new file mode 100644 index 0000000000..f9008bea0c --- /dev/null +++ b/website/docs/r/ses_black_list_delete.html.markdown @@ -0,0 +1,37 @@ +--- +subcategory: "Simple Email Service(SES)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_ses_black_list_delete" +sidebar_current: "docs-tencentcloud-resource-ses_black_list_delete" +description: |- + Provides a resource to create a ses black_list +--- + +# tencentcloud_ses_black_list_delete + +Provides a resource to create a ses black_list + +~> **NOTE:** Used to remove email addresses from blacklists. + +## Example Usage + +```hcl +resource "tencentcloud_ses_black_list_delete" "black_list" { + email_address = "terraform-tf@gmail.com" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `email_address` - (Required, String, ForceNew) Email addresses to be unblocklisted. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. + + + diff --git a/website/tencentcloud.erb b/website/tencentcloud.erb index f79ef7014d..feaf2efe26 100644 --- a/website/tencentcloud.erb +++ b/website/tencentcloud.erb @@ -2581,6 +2581,9 @@