Skip to content

Commit

Permalink
Merge pull request #17654 from DrFaust92/r/ses_receipt_rule_encoding
Browse files Browse the repository at this point in the history
r/ses_receipt_rule - add `encoding` + tests
  • Loading branch information
ewbankkit authored Apr 29, 2021
2 parents 3db0522 + 9a9b0e2 commit b6d154d
Show file tree
Hide file tree
Showing 4 changed files with 349 additions and 114 deletions.
3 changes: 3 additions & 0 deletions .changelog/17654.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_ses_receipt_rule: Add `encoding` argument to `sns_action` configuration block.
```
11 changes: 10 additions & 1 deletion aws/resource_aws_ses_receipt_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func resourceAwsSesReceiptRule() *schema.Resource {
"invocation_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Default: ses.InvocationTypeEvent,
ValidateFunc: validation.StringInSlice(ses.InvocationType_Values(), false),
},

Expand Down Expand Up @@ -285,6 +285,12 @@ func resourceAwsSesReceiptRule() *schema.Resource {
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"encoding": {
Type: schema.TypeString,
Default: ses.SNSActionEncodingUtf8,
Optional: true,
ValidateFunc: validation.StringInSlice(ses.SNSActionEncoding_Values(), false),
},
"topic_arn": {
Type: schema.TypeString,
Required: true,
Expand All @@ -300,6 +306,7 @@ func resourceAwsSesReceiptRule() *schema.Resource {
Set: func(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["encoding"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["topic_arn"].(string)))
buf.WriteString(fmt.Sprintf("%d-", m["position"].(int)))

Expand Down Expand Up @@ -560,6 +567,7 @@ func resourceAwsSesReceiptRuleRead(d *schema.ResourceData, meta interface{}) err
if element.SNSAction != nil {
snsAction := map[string]interface{}{
"topic_arn": aws.StringValue(element.SNSAction.TopicArn),
"encoding": aws.StringValue(element.SNSAction.Encoding),
"position": i + 1,
}

Expand Down Expand Up @@ -771,6 +779,7 @@ func buildReceiptRule(d *schema.ResourceData) *ses.ReceiptRule {

snsAction := &ses.SNSAction{
TopicArn: aws.String(elem["topic_arn"].(string)),
Encoding: aws.String(elem["encoding"].(string)),
}

actions[elem["position"].(int)] = &ses.ReceiptAction{
Expand Down
Loading

0 comments on commit b6d154d

Please sign in to comment.