From e7e35b5c074935d15e5113a6d08dd4f0a9be74e6 Mon Sep 17 00:00:00 2001 From: Doug Neal Date: Mon, 27 Mar 2017 13:56:57 +0100 Subject: [PATCH] provider/aws: aws_ses_receipt_rule: fix off-by-one errors (#12961) In function `resourceAwsSesReceiptRuleRead` the position of the receipt rules in the rule set was taken directly from the index of the rule's position in the slice returned by the AWS API call. As the slice is zero-based and the ruleset is one-based, this results in an incorrect representation. This manifests as `aws_ses_receipt_rule` resources always showing a diff during plan or apply. --- .../providers/aws/resource_aws_ses_receipt_rule.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/builtin/providers/aws/resource_aws_ses_receipt_rule.go b/builtin/providers/aws/resource_aws_ses_receipt_rule.go index 54cb88c34..912620acd 100644 --- a/builtin/providers/aws/resource_aws_ses_receipt_rule.go +++ b/builtin/providers/aws/resource_aws_ses_receipt_rule.go @@ -443,7 +443,7 @@ func resourceAwsSesReceiptRuleRead(d *schema.ResourceData, meta interface{}) err addHeaderAction := map[string]interface{}{ "header_name": *element.AddHeaderAction.HeaderName, "header_value": *element.AddHeaderAction.HeaderValue, - "position": i, + "position": i + 1, } addHeaderActionList = append(addHeaderActionList, addHeaderAction) } @@ -453,7 +453,7 @@ func resourceAwsSesReceiptRuleRead(d *schema.ResourceData, meta interface{}) err "message": *element.BounceAction.Message, "sender": *element.BounceAction.Sender, "smtp_reply_code": *element.BounceAction.SmtpReplyCode, - "position": i, + "position": i + 1, } if element.BounceAction.StatusCode != nil { @@ -470,7 +470,7 @@ func resourceAwsSesReceiptRuleRead(d *schema.ResourceData, meta interface{}) err if element.LambdaAction != nil { lambdaAction := map[string]interface{}{ "function_arn": *element.LambdaAction.FunctionArn, - "position": i, + "position": i + 1, } if element.LambdaAction.InvocationType != nil { @@ -487,7 +487,7 @@ func resourceAwsSesReceiptRuleRead(d *schema.ResourceData, meta interface{}) err if element.S3Action != nil { s3Action := map[string]interface{}{ "bucket_name": *element.S3Action.BucketName, - "position": i, + "position": i + 1, } if element.S3Action.KmsKeyArn != nil { @@ -508,7 +508,7 @@ func resourceAwsSesReceiptRuleRead(d *schema.ResourceData, meta interface{}) err if element.SNSAction != nil { snsAction := map[string]interface{}{ "topic_arn": *element.SNSAction.TopicArn, - "position": i, + "position": i + 1, } snsActionList = append(snsActionList, snsAction) @@ -517,7 +517,7 @@ func resourceAwsSesReceiptRuleRead(d *schema.ResourceData, meta interface{}) err if element.StopAction != nil { stopAction := map[string]interface{}{ "scope": *element.StopAction.Scope, - "position": i, + "position": i + 1, } if element.StopAction.TopicArn != nil { @@ -530,7 +530,7 @@ func resourceAwsSesReceiptRuleRead(d *schema.ResourceData, meta interface{}) err if element.WorkmailAction != nil { workmailAction := map[string]interface{}{ "organization_arn": *element.WorkmailAction.OrganizationArn, - "position": i, + "position": i + 1, } if element.WorkmailAction.TopicArn != nil {