Skip to content
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

feat: Add event_bridge_destination block for aws_sesv2_configuration_set_event_destination #38458

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/38458.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_sesv2_configuration_set_event_destination: Add `event_destination.event_bridge_destination` configuration block
```
61 changes: 61 additions & 0 deletions internal/service/sesv2/configuration_set_event_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func ResourceConfigurationSetEventDestination() *schema.Resource {
MaxItems: 1,
ExactlyOneOf: []string{
"event_destination.0.cloud_watch_destination",
"event_destination.0.event_bridge_destination",
"event_destination.0.kinesis_firehose_destination",
"event_destination.0.pinpoint_destination",
"event_destination.0.sns_destination",
Expand Down Expand Up @@ -92,12 +93,34 @@ func ResourceConfigurationSetEventDestination() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"event_bridge_destination": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
ExactlyOneOf: []string{
"event_destination.0.cloud_watch_destination",
"event_destination.0.event_bridge_destination",
"event_destination.0.kinesis_firehose_destination",
"event_destination.0.pinpoint_destination",
"event_destination.0.sns_destination",
},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"event_bus_arn": {
Type: schema.TypeString,
Required: true,
ValidateFunc: verify.ValidARN,
},
},
},
},
"kinesis_firehose_destination": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
ExactlyOneOf: []string{
"event_destination.0.cloud_watch_destination",
"event_destination.0.event_bridge_destination",
"event_destination.0.kinesis_firehose_destination",
"event_destination.0.pinpoint_destination",
"event_destination.0.sns_destination",
Expand Down Expand Up @@ -131,6 +154,7 @@ func ResourceConfigurationSetEventDestination() *schema.Resource {
MaxItems: 1,
ExactlyOneOf: []string{
"event_destination.0.cloud_watch_destination",
"event_destination.0.event_bridge_destination",
"event_destination.0.kinesis_firehose_destination",
"event_destination.0.pinpoint_destination",
"event_destination.0.sns_destination",
Expand All @@ -151,6 +175,7 @@ func ResourceConfigurationSetEventDestination() *schema.Resource {
MaxItems: 1,
ExactlyOneOf: []string{
"event_destination.0.cloud_watch_destination",
"event_destination.0.event_bridge_destination",
"event_destination.0.kinesis_firehose_destination",
"event_destination.0.pinpoint_destination",
"event_destination.0.sns_destination",
Expand Down Expand Up @@ -336,6 +361,10 @@ func flattenEventDestination(apiObject types.EventDestination) map[string]interf
m["cloud_watch_destination"] = []interface{}{flattenCloudWatchDestination(v)}
}

if v := apiObject.EventBridgeDestination; v != nil {
m["event_bridge_destination"] = []interface{}{flattenEventBridgeDestination(v)}
}

if v := apiObject.KinesisFirehoseDestination; v != nil {
m["kinesis_firehose_destination"] = []interface{}{flattenKinesisFirehoseDestination(v)}
}
Expand Down Expand Up @@ -369,6 +398,20 @@ func flattenCloudWatchDestination(apiObject *types.CloudWatchDestination) map[st
return m
}

func flattenEventBridgeDestination(apiObject *types.EventBridgeDestination) map[string]interface{} {
if apiObject == nil {
return nil
}

m := map[string]interface{}{}

if v := apiObject.EventBusArn; v != nil {
m["event_bus_arn"] = aws.ToString(v)
}

return m
}

func flattenKinesisFirehoseDestination(apiObject *types.KinesisFirehoseDestination) map[string]interface{} {
if apiObject == nil {
return nil
Expand Down Expand Up @@ -460,6 +503,10 @@ func expandEventDestination(tfMap map[string]interface{}) *types.EventDestinatio
a.Enabled = v
}

if v, ok := tfMap["event_bridge_destination"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
a.EventBridgeDestination = expandEventBridgeDestinaton(v[0].(map[string]interface{}))
}

if v, ok := tfMap["kinesis_firehose_destination"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
a.KinesisFirehoseDestination = expandKinesisFirehoseDestination(v[0].(map[string]interface{}))
}
Expand Down Expand Up @@ -493,6 +540,20 @@ func expandCloudWatchDestination(tfMap map[string]interface{}) *types.CloudWatch
return a
}

func expandEventBridgeDestinaton(tfMap map[string]interface{}) *types.EventBridgeDestination {
if tfMap == nil {
return nil
}

a := &types.EventBridgeDestination{}

if v, ok := tfMap["event_bus_arn"].(string); ok && v != "" {
a.EventBusArn = aws.String(v)
}

return a
}

func expandKinesisFirehoseDestination(tfMap map[string]interface{}) *types.KinesisFirehoseDestination {
if tfMap == nil {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,35 @@ func TestAccSESV2ConfigurationSetEventDestination_cloudWatchDestination(t *testi
})
}

func TestAccSESV2ConfigurationSetEventDestination_eventBridgeDestination(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_sesv2_configuration_set_event_destination.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.SESV2ServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckConfigurationSetEventDestinationDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccConfigurationSetEventDestinationConfig_eventBridgeDestination(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckConfigurationSetEventDestinationExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "event_destination.#", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, "event_destination.0.event_bridge_destination.#", acctest.Ct1),
resource.TestCheckResourceAttrPair(resourceName, "event_destination.0.event_bridge_destination.0.event_bus_arn", "data.aws_cloudwatch_event_bus.default", names.AttrARN),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccSESV2ConfigurationSetEventDestination_kinesisFirehoseDestination(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
Expand Down Expand Up @@ -345,6 +374,31 @@ resource "aws_sesv2_configuration_set_event_destination" "test" {
`, rName, dimension)
}

func testAccConfigurationSetEventDestinationConfig_eventBridgeDestination(rName string) string {
return fmt.Sprintf(`
data "aws_cloudwatch_event_bus" "default" {
name = "default"
}

resource "aws_sesv2_configuration_set" "test" {
configuration_set_name = %[1]q
}

resource "aws_sesv2_configuration_set_event_destination" "test" {
configuration_set_name = aws_sesv2_configuration_set.test.configuration_set_name
event_destination_name = %[1]q

event_destination {
event_bridge_destination {
event_bus_arn = data.aws_cloudwatch_event_bus.default.arn
}

matching_event_types = ["SEND"]
}
}
`, rName)
}

func testAccConfigurationSetEventDestinationConfig_kinesisFirehoseDestinationBase(rName string) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Terraform resource for managing an AWS SESv2 (Simple Email V2) Configuration Set

## Example Usage

### Cloud Watch Destination
### CloudWatch Destination

```terraform
resource "aws_sesv2_configuration_set" "example" {
Expand All @@ -38,6 +38,28 @@ resource "aws_sesv2_configuration_set_event_destination" "example" {
}
```

### EventBridge Destination

```terraform
data "aws_cloudwatch_event_bus" "default" {
name = "default"
}

resource "aws_sesv2_configuration_set_event_destination" "example" {
configuration_set_name = aws_sesv2_configuration_set.example.configuration_set_name
event_destination_name = "example"

event_destination {
event_bridge_destination {
event_bus_arn = data.aws_cloudwatch_event_bus.default.arn
}

enabled = true
matching_event_types = ["SEND"]
}
}
```

### Kinesis Firehose Destination

```terraform
Expand Down Expand Up @@ -111,52 +133,56 @@ The following arguments are required:

* `configuration_set_name` - (Required) The name of the configuration set.
* `event_destination` - (Required) A name that identifies the event destination within the configuration set.
* `event_destination_name` - (Required) An object that defines the event destination. See [event_destination](#event_destination) below.
* `event_destination_name` - (Required) An object that defines the event destination. See [`event_destination` Block](#event_destination-block) for details.

### event_destination
### `event_destination` Block

The following arguments are required:
The `event_destination` configuration block supports the following arguments:

* `matching_event_types` - (Required) - An array that specifies which events the Amazon SES API v2 should send to the destinations. Valid values: `SEND`, `REJECT`, `BOUNCE`, `COMPLAINT`, `DELIVERY`, `OPEN`, `CLICK`, `RENDERING_FAILURE`, `DELIVERY_DELAY`, `SUBSCRIPTION`.

The following arguments are optional:

* `cloud_watch_destination` - (Optional) An object that defines an Amazon CloudWatch destination for email events. See [cloud_watch_destination](#cloud_watch_destination) below
* `cloud_watch_destination` - (Optional) An object that defines an Amazon CloudWatch destination for email events. See [`cloud_watch_destination` Block](#cloud_watch_destination-block) for details.
* `enabled` - (Optional) When the event destination is enabled, the specified event types are sent to the destinations. Default: `false`.
* `kinesis_firehose_destination` - (Optional) An object that defines an Amazon Kinesis Data Firehose destination for email events. See [kinesis_firehose_destination](#kinesis_firehose_destination) below.
* `pinpoint_destination` - (Optional) An object that defines an Amazon Pinpoint project destination for email events. See [pinpoint_destination](#pinpoint_destination) below.
* `sns_destination` - (Optional) An object that defines an Amazon SNS destination for email events. See [sns_destination](#sns_destination) below.
* `event_bridge_configuration` - (Optional) An object that defines an Amazon EventBridge destination for email events. You can use Amazon EventBridge to send notifications when certain email events occur. See [`event_bridge_configuration` Block](#event_bridge_configuration-block) for details.
* `kinesis_firehose_destination` - (Optional) An object that defines an Amazon Kinesis Data Firehose destination for email events. See [`kinesis_firehose_destination` Block](#kinesis_firehose_destination-block) for details.
* `pinpoint_destination` - (Optional) An object that defines an Amazon Pinpoint project destination for email events. See [`pinpoint_destination` Block](#pinpoint_destination-block) for details.
* `sns_destination` - (Optional) An object that defines an Amazon SNS destination for email events. See [`sns_destination` Block](#sns_destination-block) for details.

### cloud_watch_destination
### `cloud_watch_destination` Block

The following arguments are required:
The `cloud_watch_destination` configuration block supports the following arguments:

* `dimension_configuration` - (Required) An array of objects that define the dimensions to use when you send email events to Amazon CloudWatch. See [dimension_configuration](#dimension_configuration) below.
* `dimension_configuration` - (Required) An array of objects that define the dimensions to use when you send email events to Amazon CloudWatch. See [`dimension_configuration` Block](#dimension_configuration-block) for details.

### dimension_configuration
### `dimension_configuration` Block

The following arguments are required:
The `dimension_configuration` configuration block supports the following arguments:

* `default_dimension_value` - (Required) The default value of the dimension that is published to Amazon CloudWatch if you don't provide the value of the dimension when you send an email.
* `dimension_name` - (Required) The name of an Amazon CloudWatch dimension associated with an email sending metric.
* `dimension_value_source` - (Required) The location where the Amazon SES API v2 finds the value of a dimension to publish to Amazon CloudWatch. Valid values: `MESSAGE_TAG`, `EMAIL_HEADER`, `LINK_TAG`.

### kinesis_firehose_destination
### `event_bridge_configuration` Block

The following arguments are required:
The `event_bridge_configuration` configuration block supports the following arguments:

* `event_bus_arn` - (Required) The Amazon Resource Name (ARN) of the Amazon EventBridge bus to publish email events to. Only the default bus is supported.

### `kinesis_firehose_destination` Block

The `kinesis_firehose_destination` configuration block supports the following arguments:

* `delivery_stream_arn` - (Required) The Amazon Resource Name (ARN) of the Amazon Kinesis Data Firehose stream that the Amazon SES API v2 sends email events to.
* `iam_role_arn` - (Required) The Amazon Resource Name (ARN) of the IAM role that the Amazon SES API v2 uses to send email events to the Amazon Kinesis Data Firehose stream.

### pinpoint_destination
### `pinpoint_destination` Block

The following arguments are required:
The `pinpoint_destination` configuration block supports the following arguments:

* `pinpoint_application_arn` - (Required) The Amazon Resource Name (ARN) of the Amazon Pinpoint project to send email events to.

### sns_destination
### `sns_destination` Block

The following arguments are required:
The `sns_destination` configuration block supports the following arguments:

* `topic_arn` - (Required) The Amazon Resource Name (ARN) of the Amazon SNS topic to publish email events to.

Expand Down
Loading