-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
r/ses_receipt_filter - add arn attribute + validations for all arguments + docs #13811
r/ses_receipt_filter - add arn attribute + validations for all arguments + docs #13811
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reach out with any questions.
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[0-9a-zA-Z][0-9A-Za-z-_]{1,62}[0-9a-zA-Z]$`), | ||
"This value can only contain ASCII letters, Start and end with a letter or number,"+ | ||
" and Contain less than 64 characters"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good although you may find it simpler in the future to separate the validation into separate rules for code maintainer and operator readability (since separate errors will all return), e.g.
validation.All(
validation.StringLenBetween(1, 64),
validation.StringMatch(regexp.MustCompile(`^[0-9a-zA-Z_-]+$`), "must contain only alphanumeric, underscore, and hyphen characters"),
validation.StringMatch(regexp.MustCompile(`^[0-9a-zA-Z]`), "must begin with a alphanumeric character"),
validation.StringMatch(regexp.MustCompile(`[0-9a-zA-Z]$`), "must end with a alphanumeric character"),
),
Once we've seen common patterns of these we may further condense them or make helpers. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, ill split these, it took me 20 mins to play with a regex checker to build this 😿
@@ -75,21 +93,33 @@ func resourceAwsSesReceiptFilterRead(d *schema.ResourceData, meta interface{}) e | |||
return err | |||
} | |||
|
|||
found := false | |||
for _, element := range response.Filters { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the SES API does not provide the ability to fetch a single filter, this looping is unfortunately necessary to handle accounts with multiple Receipt Filters. Otherwise it will always return errors like:
TestAccAWSSESReceiptFilter_basic: testing.go:684: Step 0 error: errors during apply:
Error: Provider produced inconsistent result after apply
When applying changes to aws_ses_receipt_filter.test, provider "aws" produced
an unexpected new value for was present, but now absent.
This is a bug in the provider, which should be reported in the provider's own
issue tracker.
You can use a pattern like this to move the filter object up:
var filter
for _, responseFilter := range response.Filters {
if aws.StringValue(responseFilter.Name) == d.Id() {
filter = responseFilter
break
}
}
if filter == nil {
// bye bye
}
We should probably add a new covering test for this while we're adjusting this logic, e.g. a test configuration utilizing count and count.index
, since this resource does especially need to handle multiple resources correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ive made a small change, let me know what you think. i can revert this to the original for now with minor changes
d.Set("policy", element.IpFilter.Policy) | ||
d.Set("name", element.Name) | ||
found = true | ||
var filter *ses.ReceiptFilter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bflad , is that what you had in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 🚀
Output from acceptance testing:
--- PASS: TestAccAWSSESReceiptFilter_disappears (6.36s)
--- PASS: TestAccAWSSESReceiptFilter_basic (8.03s)
This has been released in version 2.68.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Relates #13624, #13527
Release note for CHANGELOG:
Output from acceptance testing: