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

Allow for creating a IoT Core certificate without CSR. #9283

Merged
merged 2 commits into from
Aug 6, 2019

Conversation

borisroman
Copy link
Contributor

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" comments, they generate extra noise for pull request followers and do not help prioritize the request

Allow for creating a IoT Core certificate without CSR. Makes the CSR field optional and adds the CreateKeysAndCertificate API call.

@borisroman borisroman requested a review from a team July 9, 2019 13:25
@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/iot Issues and PRs that pertain to the iot service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. labels Jul 9, 2019
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Jul 9, 2019
@borisroman
Copy link
Contributor Author

Hi @bflad @ryndaniels

Does one of you have time to take a look at this PR?

Thanks in advance

@bflad bflad added this to the v2.23.0 milestone Aug 1, 2019
@bflad bflad self-assigned this Aug 1, 2019
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.

Hi @borisroman 👋 Thanks for this contribution. Looking pretty good, just left some items before we can get this merged. Please reach out with any questions or if you do not have time to implement them. 👍

CertificateSigningRequest: aws.String(d.Get("csr").(string)),
SetAsActive: aws.Bool(d.Get("active").(bool)),
})
if d.Get("csr") != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since d.Get() returns an interface, we should either check it after type assertion or switch the check to d.GetOk() which will automatically check the value against the zero value for the type:

Suggested change
if d.Get("csr") != "" {
if _, ok := d.GetOk("csr"); ok {

log.Printf("[DEBUG] Created certificate from csr")
if err != nil {
log.Printf("[ERROR] %s", err)
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

Terraform will automatically log returned errors so the line above this is extraneous. We should also return some error context here for operators and code maintainers about when this error occurred, e.g.

Suggested change
return err
return fmt.Errorf("error creating IoT Certificate from CSR: %s", err)


if err != nil {
log.Printf("[ERROR] %s", err)
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here regarding the log message and error context 👍

Suggested change
return err
return fmt.Errorf("error creating IoT Keys and Certificate: %s", err)

website/docs/r/iot_certificate.html.markdown Show resolved Hide resolved
@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Aug 1, 2019
@svanharmelen
Copy link
Contributor

@bflad all feedback is addressed by the latest commit.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Aug 5, 2019
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, thanks @borisroman 🚀

--- PASS: TestAccAWSIoTCertificate_csr (6.71s)
--- PASS: TestAccAWSIoTCertificate_keys_certificate (6.76s)

@bflad bflad merged commit 8fd91f3 into hashicorp:master Aug 6, 2019
bflad added a commit that referenced this pull request Aug 6, 2019
@ghost
Copy link

ghost commented Aug 7, 2019

This has been released in version 2.23.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!

@borisroman borisroman deleted the feature/CreateKeysAndCertificate branch August 12, 2019 13:19
@ghost
Copy link

ghost commented Nov 1, 2019

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 Nov 1, 2019
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. service/iot Issues and PRs that pertain to the iot 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