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

r/ses_receipt_filter - add arn attribute + validations for all arguments + docs #13811

Merged
merged 3 commits into from
Jun 22, 2020

Conversation

DrFaust92
Copy link
Collaborator

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #13624, #13527

Release note for CHANGELOG:

resource_aws_ses_receipt_filter - add arn attribute
resource_aws_ses_receipt_filter - add plan time validations to `name`, `cidr`, and `policy`
resource_aws_ses_receipt_filter - add missing doc for import and attributes

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSSESReceiptFilter_'
--- PASS: TestAccAWSSESReceiptFilter_basic (46.59s)
--- PASS: TestAccAWSSESReceiptFilter_disappears (30.71s)

@DrFaust92 DrFaust92 requested a review from a team June 17, 2020 21:01
@ghost ghost added size/M Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/ses Issues and PRs that pertain to the ses service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jun 17, 2020
@DrFaust92 DrFaust92 changed the title r/ses_receipt_filter = add arn attribute + validations for all arguments + docs r/ses_receipt_filter - add arn attribute + validations for all arguments + docs Jun 17, 2020
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Jun 18, 2020
@bflad bflad self-assigned this Jun 18, 2020
@bflad bflad added this to the v2.67.0 milestone Jun 18, 2020
Copy link
Contributor

@bflad bflad left a 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.

Comment on lines 33 to 35
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"),
Copy link
Contributor

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. 👍

Copy link
Collaborator Author

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 {
Copy link
Contributor

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.

Copy link
Collaborator Author

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

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jun 18, 2020
@DrFaust92 DrFaust92 requested a review from bflad June 18, 2020 11:49
d.Set("policy", element.IpFilter.Policy)
d.Set("name", element.Name)
found = true
var filter *ses.ReceiptFilter
Copy link
Collaborator Author

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?

@breathingdust breathingdust modified the milestones: v2.67.0, v2.68.0 Jun 18, 2020
Copy link
Contributor

@bflad bflad left a 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)

@bflad bflad merged commit a0897f7 into hashicorp:master Jun 22, 2020
bflad added a commit that referenced this pull request Jun 22, 2020
@DrFaust92 DrFaust92 deleted the r/ses_receipt_filter_refactor branch June 23, 2020 11:14
@ghost
Copy link

ghost commented Jun 26, 2020

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!

@ghost
Copy link

ghost commented Jul 23, 2020

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!

@ghost ghost locked and limited conversation to collaborators Jul 23, 2020
@breathingdust breathingdust removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. provider Pertains to the provider itself, rather than any interaction with AWS. service/ses Issues and PRs that pertain to the ses service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants