diff --git a/CHANGELOG.md b/CHANGELOG.md index b76e247..9d7f56a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ ## 0.1.0 (Unreleased) FEATURES: + +* **New Resource:** `sendgrid_bounce_settings` - Manage bounce settings for your SendGrid account, including soft bounce purge configuration +* **New Data Source:** `sendgrid_bounce_settings` - Retrieve current bounce settings from your SendGrid account + +IMPROVEMENTS: + +* **Bounce Settings API Migration:** Moved bounce settings API implementation from terraform provider to sendgrid library for better maintainability and consistency diff --git a/docs/data-sources/bounce_settings.md b/docs/data-sources/bounce_settings.md new file mode 100644 index 0000000..2ba6ef4 --- /dev/null +++ b/docs/data-sources/bounce_settings.md @@ -0,0 +1,39 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sendgrid_bounce_settings Data Source - terraform-provider-sendgrid" +subcategory: "" +description: |- + Retrieve bounce settings for your SendGrid account. + Bounce settings allow you to configure how long soft bounces are retained in your suppression list. Soft bounces are temporary delivery failures, such as a full mailbox or temporary server issues. + The Soft Bounces setting specifies the number of days soft bounces will be kept in your soft bounces suppression list. Any soft bounces older than this value will be purged. + For more information, see the SendGrid Mail Settings Guide https://support.sendgrid.com/hc/en-us/articles/9489871931803-Mail-Settings-Guide-within-a-SendGrid-Account. +--- + +# sendgrid_bounce_settings (Data Source) + +Retrieve bounce settings for your SendGrid account. + +Bounce settings allow you to configure how long soft bounces are retained in your suppression list. +Soft bounces are temporary delivery failures, such as a full mailbox or temporary server issues. + +The Soft Bounces setting specifies the number of days soft bounces will be kept in your soft bounces suppression list. +Any soft bounces older than this value will be purged. + +For more information, see the [SendGrid Mail Settings Guide](https://support.sendgrid.com/hc/en-us/articles/9489871931803-Mail-Settings-Guide-within-a-SendGrid-Account). + +## Example Usage + +```terraform +data "sendgrid_bounce_settings" "example" {} + +output "soft_bounce_purge_days" { + value = data.sendgrid_bounce_settings.example.soft_bounce_purge_days +} +``` + + +## Schema + +### Read-Only + +- `soft_bounce_purge_days` (Number) The number of days soft bounces will be kept in your soft bounces suppression list. Any soft bounces older than this value will be purged. \ No newline at end of file diff --git a/docs/resources/bounce_settings.md b/docs/resources/bounce_settings.md new file mode 100644 index 0000000..607676d --- /dev/null +++ b/docs/resources/bounce_settings.md @@ -0,0 +1,47 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "sendgrid_bounce_settings Resource - terraform-provider-sendgrid" +subcategory: "" +description: |- + Manage bounce settings for your SendGrid account. + Bounce settings allow you to configure how long soft bounces are retained in your suppression list. Soft bounces are temporary delivery failures, such as a full mailbox or temporary server issues. + The Soft Bounces setting specifies the number of days soft bounces will be kept in your soft bounces suppression list. Any soft bounces older than this value will be purged. + For more information, see the SendGrid Mail Settings Guide https://support.sendgrid.com/hc/en-us/articles/9489871931803-Mail-Settings-Guide-within-a-SendGrid-Account. +--- + +# sendgrid_bounce_settings (Resource) + +Manage bounce settings for your SendGrid account. + +Bounce settings allow you to configure how long soft bounces are retained in your suppression list. +Soft bounces are temporary delivery failures, such as a full mailbox or temporary server issues. + +The Soft Bounces setting specifies the number of days soft bounces will be kept in your soft bounces suppression list. +Any soft bounces older than this value will be purged. + +For more information, see the [SendGrid Mail Settings Guide](https://support.sendgrid.com/hc/en-us/articles/9489871931803-Mail-Settings-Guide-within-a-SendGrid-Account). + +## Example Usage + +```terraform +resource "sendgrid_bounce_settings" "example" { + soft_bounce_purge_days = 30 +} +``` + + +## Schema + +### Optional + +- `soft_bounce_purge_days` (Number) The number of days soft bounces will be kept in your soft bounces suppression list. Any soft bounces older than this value will be purged. Must be between 1 and 3650 days. + +## Import + +Import is supported using the following syntax: + +The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: + +```shell +% terraform import sendgrid_bounce_settings.example "" +``` \ No newline at end of file diff --git a/examples/data-sources/sendgrid_bounce_settings/data-source.tf b/examples/data-sources/sendgrid_bounce_settings/data-source.tf new file mode 100644 index 0000000..898d32c --- /dev/null +++ b/examples/data-sources/sendgrid_bounce_settings/data-source.tf @@ -0,0 +1,5 @@ +data "sendgrid_bounce_settings" "example" {} + +output "soft_bounce_purge_days" { + value = data.sendgrid_bounce_settings.example.soft_bounce_purge_days +} \ No newline at end of file diff --git a/examples/resources/sendgrid_bounce_settings/resource.tf b/examples/resources/sendgrid_bounce_settings/resource.tf new file mode 100644 index 0000000..7cc2e8e --- /dev/null +++ b/examples/resources/sendgrid_bounce_settings/resource.tf @@ -0,0 +1,3 @@ +resource "sendgrid_bounce_settings" "example" { + soft_bounce_purge_days = 30 +} \ No newline at end of file diff --git a/go.sum b/go.sum index 7a65ca4..4f5ccf5 100644 --- a/go.sum +++ b/go.sum @@ -136,8 +136,6 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94= github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8= -github.com/kenzo0107/sendgrid v1.7.0 h1:ZaPwWcjR3EE974qsrkCgFFYmQq2hE9Y4jRfp4qR7JVc= -github.com/kenzo0107/sendgrid v1.7.0/go.mod h1:o93EmGpbWbhaxLoiGB+x6g3tLof7TwbUlzjHNLvpDP8= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -199,8 +197,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= diff --git a/internal/provider/bounce_settings_data_source.go b/internal/provider/bounce_settings_data_source.go new file mode 100644 index 0000000..212f9d3 --- /dev/null +++ b/internal/provider/bounce_settings_data_source.go @@ -0,0 +1,112 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/kenzo0107/sendgrid" +) + +// Ensure the implementation satisfies the expected interfaces. +var ( + _ datasource.DataSource = &bounceSettingsDataSource{} + _ datasource.DataSourceWithConfigure = &bounceSettingsDataSource{} +) + +func newBounceSettingsDataSource() datasource.DataSource { + return &bounceSettingsDataSource{} +} + +type bounceSettingsDataSource struct { + client *sendgrid.Client +} + +type bounceSettingsDataSourceModel struct { + SoftBouncePurgeDays types.Int64 `tfsdk:"soft_bounce_purge_days"` +} + +func (d *bounceSettingsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_bounce_settings" +} + +func (d *bounceSettingsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*sendgrid.Client) + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *sendgrid.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + return + } + + d.client = client +} + +func (d *bounceSettingsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: ` +Retrieve bounce settings for your SendGrid account. + +Bounce settings allow you to configure how long soft bounces are retained in your suppression list. +Soft bounces are temporary delivery failures, such as a full mailbox or temporary server issues. + +The Soft Bounces setting specifies the number of days soft bounces will be kept in your soft bounces suppression list. +Any soft bounces older than this value will be purged. + +For more information, see the [SendGrid Mail Settings Guide](https://support.sendgrid.com/hc/en-us/articles/9489871931803-Mail-Settings-Guide-within-a-SendGrid-Account). + `, + Attributes: map[string]schema.Attribute{ + "soft_bounce_purge_days": schema.Int64Attribute{ + MarkdownDescription: "The number of days soft bounces will be kept in your soft bounces suppression list. Any soft bounces older than this value will be purged.", + Computed: true, + }, + }, + } +} + +func (d *bounceSettingsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var state bounceSettingsDataSourceModel + + resp.Diagnostics.Append(req.Config.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + res, err := retryOnRateLimit(ctx, func() (interface{}, error) { + return d.client.GetBounceSettings(ctx) + }) + if err != nil { + resp.Diagnostics.AddError( + "Reading bounce settings", + fmt.Sprintf("Unable to get bounce settings, got error: %s", err), + ) + return + } + + o, ok := res.(*sendgrid.BounceSettings) + if !ok { + resp.Diagnostics.AddError( + "Reading bounce settings", + "Failed to assert type *sendgrid.BounceSettings", + ) + return + } + + state.SoftBouncePurgeDays = types.Int64Value(o.SoftBouncePurgeDays) + + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } +} diff --git a/internal/provider/bounce_settings_data_source_test.go b/internal/provider/bounce_settings_data_source_test.go new file mode 100644 index 0000000..aadcbd5 --- /dev/null +++ b/internal/provider/bounce_settings_data_source_test.go @@ -0,0 +1,30 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccBounceSettingsDataSource(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Read testing + { + Config: testAccBounceSettingsDataSourceConfig, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttrSet("data.sendgrid_bounce_settings.test", "soft_bounce_purge_days"), + ), + }, + }, + }) +} + +const testAccBounceSettingsDataSourceConfig = ` +data "sendgrid_bounce_settings" "test" {} +` \ No newline at end of file diff --git a/internal/provider/bounce_settings_resource.go b/internal/provider/bounce_settings_resource.go new file mode 100644 index 0000000..9467655 --- /dev/null +++ b/internal/provider/bounce_settings_resource.go @@ -0,0 +1,273 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/kenzo0107/sendgrid" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &bounceSettingsResource{} +var _ resource.ResourceWithImportState = &bounceSettingsResource{} + +func newBounceSettingsResource() resource.Resource { + return &bounceSettingsResource{} +} + +type bounceSettingsResource struct { + client *sendgrid.Client +} + +type bounceSettingsResourceModel struct { + SoftBouncePurgeDays types.Int64 `tfsdk:"soft_bounce_purge_days"` +} + +func (r *bounceSettingsResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_bounce_settings" +} + +func (r *bounceSettingsResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: ` +Manage bounce settings for your SendGrid account. + +Bounce settings allow you to configure how long soft bounces are retained in your suppression list. +Soft bounces are temporary delivery failures, such as a full mailbox or temporary server issues. + +The Soft Bounces setting specifies the number of days soft bounces will be kept in your soft bounces suppression list. +Any soft bounces older than this value will be purged. + +For more information, see the [SendGrid Mail Settings Guide](https://support.sendgrid.com/hc/en-us/articles/9489871931803-Mail-Settings-Guide-within-a-SendGrid-Account). + `, + Attributes: map[string]schema.Attribute{ + "soft_bounce_purge_days": schema.Int64Attribute{ + MarkdownDescription: "The number of days soft bounces will be kept in your soft bounces suppression list. Any soft bounces older than this value will be purged. Must be between 1 and 3650 days.", + Optional: true, + Computed: true, + Default: int64default.StaticInt64(7), // Default to 7 days as a reasonable default + }, + }, + } +} + +func (r *bounceSettingsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*sendgrid.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected *sendgrid.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client +} + +func (r *bounceSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan bounceSettingsResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + // Validate the value is within acceptable range + days := plan.SoftBouncePurgeDays.ValueInt64() + if days < 1 || days > 3650 { + resp.Diagnostics.AddError( + "Invalid soft_bounce_purge_days value", + "soft_bounce_purge_days must be between 1 and 3650 days", + ) + return + } + + input := &sendgrid.InputUpdateBounceSettings{ + SoftBouncePurgeDays: plan.SoftBouncePurgeDays.ValueInt64(), + } + + res, err := retryOnRateLimit(ctx, func() (interface{}, error) { + return r.client.UpdateBounceSettings(ctx, input) + }) + if err != nil { + resp.Diagnostics.AddError( + "Creating bounce settings", + fmt.Sprintf("Unable to update bounce settings, got error: %s", err), + ) + return + } + + o, ok := res.(*sendgrid.BounceSettings) + if !ok { + resp.Diagnostics.AddError( + "Creating bounce settings", + "Failed to assert type *sendgrid.BounceSettings", + ) + return + } + + plan = bounceSettingsResourceModel{ + SoftBouncePurgeDays: types.Int64Value(o.SoftBouncePurgeDays), + } + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *bounceSettingsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state bounceSettingsResourceModel + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + res, err := retryOnRateLimit(ctx, func() (interface{}, error) { + return r.client.GetBounceSettings(ctx) + }) + if err != nil { + resp.Diagnostics.AddError( + "Reading bounce settings", + fmt.Sprintf("Unable to read bounce settings, got error: %s", err), + ) + return + } + + o, ok := res.(*sendgrid.BounceSettings) + if !ok { + resp.Diagnostics.AddError( + "Reading bounce settings", + "Failed to assert type *sendgrid.BounceSettings", + ) + return + } + + state = bounceSettingsResourceModel{ + SoftBouncePurgeDays: types.Int64Value(o.SoftBouncePurgeDays), + } + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *bounceSettingsResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var data, state bounceSettingsResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + // Validate the value is within acceptable range + days := data.SoftBouncePurgeDays.ValueInt64() + if days < 1 || days > 3650 { + resp.Diagnostics.AddError( + "Invalid soft_bounce_purge_days value", + "soft_bounce_purge_days must be between 1 and 3650 days", + ) + return + } + + input := &sendgrid.InputUpdateBounceSettings{} + if !data.SoftBouncePurgeDays.IsNull() && data.SoftBouncePurgeDays.ValueInt64() != state.SoftBouncePurgeDays.ValueInt64() { + input.SoftBouncePurgeDays = data.SoftBouncePurgeDays.ValueInt64() + } + + res, err := retryOnRateLimit(ctx, func() (interface{}, error) { + return r.client.UpdateBounceSettings(ctx, input) + }) + if err != nil { + resp.Diagnostics.AddError( + "Updating bounce settings", + fmt.Sprintf("Unable to update bounce settings, got error: %s", err), + ) + return + } + + o, ok := res.(*sendgrid.BounceSettings) + if !ok { + resp.Diagnostics.AddError( + "Updating bounce settings", + "Failed to assert type *sendgrid.BounceSettings", + ) + return + } + + data = bounceSettingsResourceModel{ + SoftBouncePurgeDays: types.Int64Value(o.SoftBouncePurgeDays), + } + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *bounceSettingsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state bounceSettingsResourceModel + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + // For bounce settings, we can't really "delete" them, but we can reset to a reasonable default + // Let's reset to 7 days as a default value + input := &sendgrid.InputUpdateBounceSettings{ + SoftBouncePurgeDays: 7, + } + + _, err := retryOnRateLimit(ctx, func() (interface{}, error) { + return r.client.UpdateBounceSettings(ctx, input) + }) + if err != nil { + resp.Diagnostics.AddError( + "Deleting bounce settings", + fmt.Sprintf("Unable to reset bounce settings, got error: %s", err), + ) + return + } +} + +func (r *bounceSettingsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + var data bounceSettingsResourceModel + + res, err := retryOnRateLimit(ctx, func() (interface{}, error) { + return r.client.GetBounceSettings(ctx) + }) + if err != nil { + resp.Diagnostics.AddError( + "Importing bounce settings", + fmt.Sprintf("Unable to read bounce settings, got error: %s", err), + ) + return + } + + o, ok := res.(*sendgrid.BounceSettings) + if !ok { + resp.Diagnostics.AddError( + "Importing bounce settings", + "Failed to assert type *sendgrid.BounceSettings", + ) + return + } + + data = bounceSettingsResourceModel{ + SoftBouncePurgeDays: types.Int64Value(o.SoftBouncePurgeDays), + } + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } +} diff --git a/internal/provider/bounce_settings_resource_test.go b/internal/provider/bounce_settings_resource_test.go new file mode 100644 index 0000000..169e909 --- /dev/null +++ b/internal/provider/bounce_settings_resource_test.go @@ -0,0 +1,47 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccBounceSettingsResource(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create and Read testing + { + Config: testAccBounceSettingsResourceConfig("30"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("sendgrid_bounce_settings.test", "soft_bounce_purge_days", "30"), + ), + }, + // ImportState testing + { + ResourceName: "sendgrid_bounce_settings.test", + ImportState: true, + ImportStateVerify: true, + }, + // Update and Read testing + { + Config: testAccBounceSettingsResourceConfig("60"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("sendgrid_bounce_settings.test", "soft_bounce_purge_days", "60"), + ), + }, + }, + }) +} + +func testAccBounceSettingsResourceConfig(days string) string { + return ` +resource "sendgrid_bounce_settings" "test" { + soft_bounce_purge_days = ` + days + ` +} +` +} \ No newline at end of file diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 766d1f8..a2a4745 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -138,6 +138,7 @@ func (p *sendgridProvider) Resources(ctx context.Context) []func() resource.Reso newInboundParseWebhookResource, newSSOTeammateResource, newClickTrackingSettingsResource, + newBounceSettingsResource, newAlertResource, } } @@ -160,6 +161,7 @@ func (p *sendgridProvider) DataSources(ctx context.Context) []func() datasource. newEventWebhookDataSource, newInboundParseWebhookDataSource, newClickTrackingSettingsDataSource, + newBounceSettingsDataSource, newAlertDataSource, } }