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

Add AWS SES DKIM resource #1786

Merged
merged 4 commits into from
Oct 23, 2017
Merged

Add AWS SES DKIM resource #1786

merged 4 commits into from
Oct 23, 2017

Conversation

arr-dev
Copy link
Contributor

@arr-dev arr-dev commented Oct 1, 2017

Added aws_ses_dkim resource, according to http://docs.aws.amazon.com/ses/latest/DeveloperGuide/easy-dkim-dns-records.html

Transfered the PR from hashicorp/terraform#14831

Closes #1347

@radeksimko radeksimko added enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. labels Oct 2, 2017
Copy link
Contributor

@handlerbot handlerbot left a comment

Choose a reason for hiding this comment

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

@arr-dev, thank you so much for uplifting this to the new provider location! 🙇

That said: This isn't working for me in the current version, but I got it working locally, so comments inbound...

Delete: resourceAwsSesDomainDkimDelete,

Schema: map[string]*schema.Schema{
"arn": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure what the arn field is used for in this resource? I didn't find any references to constructing an ARN for dkim/ as you do below, and I'm not sure where this is used. I was able to get my local use of this resource working fine even after removing the all arn-related 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.

I've based this resource on aws_ses_domain_identity which computes arn the same way.
I understand that it's not used, but I wasn't sure about leaving it out.

I'll remove it.

Create: resourceAwsSesDomainDkimCreate,
Read: resourceAwsSesDomainDkimRead,
Delete: resourceAwsSesDomainDkimDelete,

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add an Importer here so importing works?

Importer: &schema.ResourceImporter{
        State: schema.ImportStatePassthrough,
},

The above worked for me.

}

d.Set("arn", fmt.Sprintf("arn:%s:ses:%s:%s:dkim/%s", meta.(*AWSClient).partition, meta.(*AWSClient).region, meta.(*AWSClient).accountid, d.Id()))
d.Set("dkim_tokens", verificationAttrs.DkimTokens)
Copy link
Contributor

Choose a reason for hiding this comment

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

Most important: this resource did not work with this line as written!

Without changing this, the tokens weren't actually written to the state file under dkim_tokens, and the next plan attempted to update the resource, which isn't possible, so Terraform errored out.

I needed to wrap the DkimTokens in a aws.StringValueSlice to get the []*string converted to []string, as (sort of) documented here: https://godoc.org/github.com/aws/aws-sdk-go/aws

d.Set("dkim_tokens", aws.StringValueSlice(verificationAttrs.DkimTokens))

@handlerbot
Copy link
Contributor

@arr-dev Thank you so much for the changes! I'll test them live in a bit, but my eyeball read-over makes me think they will work just fine. :-)

In my perfect world, I'd love to see the documentation updated to mention that import works, and a test written to see that we're successfully recording the DKIM tokens to the state (like the now-deleted arn test, but checking that there are 3 tokens that look like what we expect the tokens to be, alphanumeric strings of the right length, etc). That said, you've done more than enough work over a long time on this functionality to get us to this place, so I'm glad to do a follow-on PR to this one to add those, if you don't have time or interest.

@handlerbot
Copy link
Contributor

(And FTR, I'm an outside contributor just like you, so I don't have any merge powers; we'll still need to wait for a Terraform project committer to approve and merge...)

@handlerbot
Copy link
Contributor

OK, confirmed working tested locally! Whoop, thank you!

@arr-dev
Copy link
Contributor Author

arr-dev commented Oct 4, 2017

@handlerbot Yes, you are right and I'd be glad to complete this PR.
I'll do follow-up commits in the next couple of days.

@arr-dev
Copy link
Contributor Author

arr-dev commented Oct 12, 2017

I've added a commit with doc fixes,
but am having issues running acceptance tests, even without any changes of my own.
I've tried running it for single resource only, but that doesn't seem to work.

TEST="aws/resource_aws_ses_domain_identity_test.go" make testacc

Not sure if I'm running it correctly.

@arr-dev
Copy link
Contributor Author

arr-dev commented Oct 13, 2017

Managed to run Acceptance tests, so I've added tests which verify tokens state.

If anyone needs it, command to run specific acceptance test:
make testacc TESTARGS='-run=TestAccAwsSESDomainDkim'

@handlerbot
Copy link
Contributor

@radeksimko This looks ready to go from a "I tested this in the field" perspective, can we get this looked at?

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.

@arr-dev Thanks for the PR
@handlerbot Thanks for the peer review and ping.

Yeey, teamwork 💯

@radeksimko radeksimko merged commit 20bdb38 into hashicorp:master Oct 23, 2017
@arr-dev arr-dev deleted the b-ses-dkim branch October 23, 2017 13:59
@handlerbot
Copy link
Contributor

Teamwork makes the dream work, as they say. :-D

@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
enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DKIM for SES
3 participants