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 azurerm_key_vault_certificate_issuer #7074

Merged
merged 32 commits into from
Jul 8, 2020

Conversation

sirlatrom
Copy link
Contributor

Fixes #7073.

@sirlatrom sirlatrom marked this pull request as ready for review May 29, 2020 08:23
@sirlatrom sirlatrom force-pushed the fix-7073 branch 2 times, most recently from 7aaf9af to 9e68b7c Compare June 3, 2020 14:27
@sirlatrom sirlatrom force-pushed the fix-7073 branch 2 times, most recently from 7c53815 to 8d212b5 Compare June 9, 2020 11:45
@sirlatrom
Copy link
Contributor Author

I've only been force-pushing to keep up to date with master. Other than that this should be ready.

@sirlatrom
Copy link
Contributor Author

@katbyte @tombuildsstuff I've been using this for a while and seems to work fine; is there anything missing?

@sirlatrom
Copy link
Contributor Author

sirlatrom commented Jun 14, 2020 via email

@pwiens
Copy link

pwiens commented Jun 16, 2020

I would love it if this got merged. I've been waiting for this feature since 2.0

@sirlatrom
Copy link
Contributor Author

Rebased on the main branch and resolved contention from the newly added azurerm_key_vault_certificate datasource.

@sirlatrom
Copy link
Contributor Author

I'd love for this to get merged too.

@pwiens Was it company policy or something that prevented you from contributing your fork?

@pwiens
Copy link

pwiens commented Jun 17, 2020

@sirlatrom This is the first time I've touched go code and I didn't feel comfortable enough putting together a PR with decent tests. I was going to invest some time in doing that but I saw your PR and the issue you opened. Thanks for taking the time to do the work.

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Hi @sirlatrom
Thanks for this PR for new resource and data source, it's off to a good start, and apologies for the fairly rushed review here (but I did promise I'd try to get to it today!).

I've made some comments and suggestions below on the code. I've not covered the testing or docs fully yet, but I'll loop back to that after you've had a look at the review so far. (I will mention that the tests for the data source are missing and we would want to see a requiresImport and an update test on the resource.)

Comment on lines 105 to 106
d.Set("org_id", resp.OrganizationDetails.ID)
d.Set("account_id", resp.Credentials.AccountID)
Copy link
Member

Choose a reason for hiding this comment

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

I think these should probably be nil checked before setting, if the response is missing elements for some reason we'll get a panic here.

Comment on lines 205 to 207
d.Set("org_id", resp.OrganizationDetails.ID)
d.Set("account_id", resp.Credentials.AccountID)
d.Set("password", resp.Credentials.Password)
Copy link
Member

Choose a reason for hiding this comment

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

These (OrganizationDetails and Credentials) are potentially nil, so should probably be nil checked before attempting to set the schema attributes to the values contained within to avoid panic.

Comment on lines 186 to 187
name := d.Get("name").(string)
keyVaultId := d.Get("key_vault_id").(string)
Copy link
Member

Choose a reason for hiding this comment

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

We should get the information to make the Read call from the ID in the state (using d.Id()), rather than the config, this allows us to understand the difference between the config and what Terraform last knew about.

if utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("KeyVault Certificate Issuer %q (KeyVault URI %q) does not exist", name, keyVaultBaseUri)
}
return fmt.Errorf("Error making Read request on Azure KeyVault Certificate Issuer %s: %+v", name, err)
Copy link
Member

Choose a reason for hiding this comment

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

As above, re: removing duplication of the word Error from message output

Comment on lines 247 to 248
name := d.Get("name").(string)
keyVaultId := d.Get("key_vault_id").(string)
Copy link
Member

Choose a reason for hiding this comment

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

As with Read, Delete should use the state for this information.

@sirlatrom
Copy link
Contributor Author

@jackofallops Just missing the datasource tests now, but perhaps you could already now validate the changes to the rest of the PR?

@ghost ghost removed the waiting-response label Jun 25, 2020
@sirlatrom
Copy link
Contributor Author

@jackofallops I've added a very basic test of the datasource. What is the expected level of detail?

@sirlatrom sirlatrom requested a review from jackofallops June 25, 2020 16:20
@jackofallops
Copy link
Member

@jackofallops I've added a very basic test of the datasource. What is the expected level of detail?

Thanks! Usually we create an example resource and ensure that each expected exported attribute in the data source is populated as expected. I'll re-review now, sorry for the delay in looping back.

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Hi @sirlatrom
Thanks for the updates and great work so far, a few more changes noted below (sorry, I missed a couple things last pass). I've also left a question around the change to the custom poller for certificate creation, if you can explain the scenario you're looking to mitigate I can review that again.

Thanks again!

@sirlatrom
Copy link
Contributor Author

Hi @jackofallops,

A quick answer regarding the poller: Our issuer turns out to include manual processing on the issuer's side, with an initial estimated time returned in a message that would be frail to parse. They do however have a SLA that should fall within the updated timeouts. Alternatively, the timeouts could be exposed as attributes, too.

I'll handle the other review items early next week.

sirlatrom and others added 16 commits July 7, 2020 13:19
Signed-off-by: Sune Keller <[email protected]>

Co-authored-by: Steve <[email protected]>
Signed-off-by: Sune Keller <[email protected]>
Signed-off-by: Sune Keller <[email protected]>
Signed-off-by: Sune Keller <[email protected]>
Signed-off-by: Sune Keller <[email protected]>

Co-authored-by: Steve <[email protected]>
Signed-off-by: Sune Keller <[email protected]>

Co-authored-by: Tom Harvey <[email protected]>
@sirlatrom
Copy link
Contributor Author

@tombuildsstuff @jackofallops I've applied your suggestions and also rebased on origin/mastermain to ensure the branch is sufficiently up to date.

@jackofallops
Copy link
Member

Thanks @sirlatrom - I've just fixed a minor issue we introduced along the way, so hopefully travis will be happy now. As soon as that goes green I think we're good to rerun the tests and, all being well, get this merged in.

@jackofallops
Copy link
Member

Tests re-run and passing after changes:
image

@jackofallops jackofallops merged commit 98317e5 into hashicorp:master Jul 8, 2020
jackofallops added a commit that referenced this pull request Jul 8, 2020
@sirlatrom sirlatrom deleted the fix-7073 branch July 8, 2020 07:34
@ghost
Copy link

ghost commented Jul 10, 2020

This has been released in version 2.18.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.18.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Aug 7, 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. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for azurerm_key_vault_certificate_issuer
4 participants