-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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: azurerm_key_vault_secret
#269
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, couple of potential panics that should be caught, but otherwise looks good.
keyVaultBaseUrl := d.Get("vault_uri").(string) | ||
value := d.Get("value").(string) | ||
contentType := d.Get("content_type").(string) | ||
tags := d.Get("tags").(map[string]interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If tags
is optional, this cast will panic on a nil "tags"
block:
tags { }
With the complex types here, easier to try the cast to verify against potential panics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& repeated other areas 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd agree, but afaik HCL is returning an empty map here - given we use this pattern throughout the provider - example from azurerm_resource_group
:
$ cat main.tf
resource "azurerm_resource_group" "test"{
name = "tom"
location = "westus"
tags { }
}
$ envchain azurerm terraform plan -refresh
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.
Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.
+ azurerm_resource_group.test
location: "westus"
name: "tom"
tags.%: "<computed>"
Plan: 1 to add, 0 to change, 0 to destroy.
✔ ~/code/src/tmp/jake
17:01 $ envchain azurerm terraform apply
azurerm_resource_group.test: Creating...
location: "" => "westus"
name: "" => "tom"
tags.%: "" => "<computed>"
azurerm_resource_group.test: Creation complete (ID: /subscriptions/xxxxxxxxxx/resourceGroups/tom)
d.Set("version", respID.Version) | ||
d.Set("content_type", resp.ContentType) | ||
|
||
flattenAndSetTags(d, resp.Tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
complex types should always check the returned error from d.Set()
, more opportunities for things to go wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given this affects every resource in the Provider - I'm going to make this a separate task & do this across everything
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 👉 hashibot-feedback@hashicorp.com. Thanks! |
Adds the
azurerm_key_vault_secret
resource - with support for setting secrets at particular versions.Note this doesn't implement the
Enabled
,Activation Date
orExpiration Date
fields due to us being unable to make API calls for a disabled secret (due to the way the API's designed.Tests pass: