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

New Resource: aws_ses_template #2003

Merged
merged 3 commits into from
Nov 7, 2017
Merged

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Oct 22, 2017

Supports all SES template CRUD activity however the UpdateTemplate call is eventually consistent and I couldn't find an easy workaround in the testing, so set those acceptance tests to skip for now.

This closes #1921 and #1981.

make testacc TESTARGS='-run=TestAccAWSSesTemplate'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccAWSSesTemplate -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSSesTemplate_Basic
--- PASS: TestAccAWSSesTemplate_Basic (12.33s)
=== RUN   TestAccAWSSesTemplate_Update
--- SKIP: TestAccAWSSesTemplate_Update (0.00s)
	resource_aws_ses_template_test.go:40: Skip due to SES.UpdateTemplate eventual consistency issues
=== RUN   TestAccAWSSesTemplate_Import
--- PASS: TestAccAWSSesTemplate_Import (11.38s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	23.748s

@Ninir
Copy link
Contributor

Ninir commented Oct 30, 2017

Hey @bflad

Can you fix the conflicts so that we can test & merge accordingly please.

Thank you! 😄 🚀

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bflad
thanks for the PR. It's looking pretty good.

I did a preliminary review and left you some questions there, the most important one about eventual consistency.

Besides that - as @Ninir mentioned it would be great if you can resolve the conflict.

}

func TestAccAWSSesTemplate_Update(t *testing.T) {
t.Skipf("Skip due to SES.UpdateTemplate eventual consistency issues")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain the effect of eventual consistency? We have many tests which can deal with this sort of situation, usually by retrying operations on a particular error code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior I was seeing was that the AWS API always immediately returns a 200 for the SDK UpdateTemplate function, however when reading the resource the updates are not immediately propagated.

For example, changing the html field from "foo" to "bar" will mostly fail testing saying its still "foo" => "bar" for a few seconds. Sometimes it would pass on immediate read then fail on the acceptance testing framework's next refresh. After some time, the resource will eventually synchronize in AWS.

If you have some ideas for how to handle this situation, would love to know. Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. We don't have any good helpers for this yet, but I observed very similar behaviour in a few other existing tests, so we should probably create one at some point.

Create: schema.DefaultTimeout(30 * time.Minute),
Update: schema.DefaultTimeout(30 * time.Minute),
Delete: schema.DefaultTimeout(30 * time.Minute),
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see these timeouts being used anywhere 🤔

"id": {
Type: schema.TypeString,
Computed: true,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is unnecessary, every resource gets one automatically. In fact if you rebased to the latest master you'd see a failing test because of that as we recently improved the schema validation.

"text": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateSesTemplateText,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the validation here 👍

log.Printf("[DEBUG] Reading SES template: %#v", input)
gto, err := conn.GetTemplate(&input)
if err != nil {
if scErr, ok := err.(awserr.Error); ok && scErr.Code() == "TemplateDoesNotExist" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a nice helper function for this which can save us some characters + 1 import line.

if isAWSErr(err, "TemplateDoesNotExist", "") {

@radeksimko radeksimko added the waiting-response Maintainers are waiting on response from community or contributor. label Oct 31, 2017
@bflad
Copy link
Contributor Author

bflad commented Nov 2, 2017

Working on this now!

* remove extraneous id field in schema
* remove extraneous schema timeout definitions
* use isAWSErr instead of manual awserr check
@bflad
Copy link
Contributor Author

bflad commented Nov 2, 2017

Merged master into PR and addressed:

  • remove extraneous id field in schema
  • remove extraneous schema timeout definitions
  • use isAWSErr instead of manual awserr check

If you have ideas for the UpdateTemplate eventual consistency, please let me know.

@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Nov 7, 2017
@radeksimko radeksimko merged commit 058ba61 into hashicorp:master Nov 7, 2017
@ghost
Copy link

ghost commented Apr 10, 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 Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws ses create-template
3 participants