-
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 Data Source: azurerm_function_app_host_keys
#7902
New Data Source: azurerm_function_app_host_keys
#7902
Conversation
}, | ||
}, | ||
|
||
"system_keys": { |
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 am not sure about system_keys .. it exists in the api, however I never used it nor was able to see it being set while I was testing
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went 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.
If its value is not returned by the API / we're not using it, then it should be removed.
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 agree with @jackofallops, I am going to remove it
@njuCZ , do you know when this feature will be merged? |
@georghildebrand I am sorry that I don't know the detail plan. If you are urgent about this PR, I could make a ping to the reviewers, or you could directly ping the reviewers in the slack channel. |
@njuCZ , thank you for having a look. Its quite urgent for me. I will also ping the devs in the slack channel |
@njuCZ , just realized that I have no slack account anymore as i switched jobs. Could you ping the engineers please? |
@georghildebrand you can use this link to request an invitation : https://join.slack.com/t/terraform-azure/shared_invite/enQtNDMzNjQ5NzcxMDc3LWNiY2ZhNThhNDgzNmY0MTM0N2MwZjE4ZGU0MjcxYjUyMzRmN2E5NjZhZmQ0ZTA1OTExMGNjYzA4ZDkwZDYxNDE |
I am also waiting on this! |
@sgettys , please consider upvoting in slack. actually there is currently now response from the devs. https://app.slack.com/client/TB9RVKMGW/CJD3VK9Q9/thread/CJD3VK9Q9-1596945807.467000 |
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.
@3mard Thanks for this PR!
I've taken a look through and left some comments inline, but this is mostly looking good to me 👍
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
ForceNew: true, |
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.
ForceNew
is not needed for a data source:
ForceNew: true, |
}, | ||
}, | ||
|
||
"system_keys": { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
if err := d.Set("master_key", res.MasterKey); err != nil { | ||
return err | ||
} | ||
if err = d.Set("function_keys", res.FunctionKeys); err != nil { |
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.
Can we use utils.FlattenMapStringPtrString()
here?
if err = d.Set("function_keys", res.FunctionKeys); err != nil { | |
if err = d.Set("function_keys", utils.FlattenMapStringPtrString(res.FunctionKeys)); err != nil { |
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.
actually instead can we expose the values from this field in a defensive manner (see above) - exposing a map of values isn't a great UX since these can change in the API response
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 like to go with @tombuildsstuff approach on this if that's okay with @magodo
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.
@3mard Sure, that makes more sense
if err = d.Set("function_keys", res.FunctionKeys); err != nil { | ||
return err | ||
} | ||
if err = d.Set("system_keys", res.SystemKeys); err != nil { |
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.
Same as above:
if err = d.Set("system_keys", res.SystemKeys); err != nil { | |
if err = d.Set("system_keys", utils.FlattenMapStringPtrString(res.SystemKeys)); err != nil { |
} | ||
|
||
d.SetId(time.Now().UTC().String()) | ||
if err := d.Set("master_key", res.MasterKey); err != nil { |
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.
For primitive type, there is no need to error check for d.Set:
if err := d.Set("master_key", res.MasterKey); err != nil { | |
d.Set("master_key", res.MasterKey) |
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.
hey @3mard
Thanks for this PR :)
I've taken a look through and left some comments inline but if we can fix those up then this otherwise LGTM 👍
Thanks!
Type: schema.TypeString, | ||
}, | ||
Sensitive: true, | ||
}, |
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.
rather than exposing this as a Map - can we lookup the data in a defensive fashion and output those specific fields, so that users don't have to deal with breaking changes in the response format here e.g.
defaultFunctionKey := ""
if v, ok := keys["default"]; ok {
defaultFunctionKey = v
}
d.Set("default_function_key", defaultFunctionKey)
return fmt.Errorf("Error making Read request on AzureRM Function App Hostkeys %q: %+v", name, err) | ||
} | ||
|
||
d.SetId(time.Now().UTC().String()) |
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.
can we use the ID of the Function App/Key returned here, rather than a date which'll change all the time (and causes issues in Terraform 0.13+)
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.
@tombuildsstuff I don't think I have the access to the function Id in the response AFAIK,
should I do a
client.Get(ctx, resourceGroup, name)
just to get the function Id ?
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.
makes sense for now - we'll switch this out for something else later on 👍
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.
Oh sorry for the confusion @tombuildsstuff , I went with your suggested solution, (one more API request to retrieve the function Id ), should I keep it like this?
if err := d.Set("master_key", res.MasterKey); err != nil { | ||
return err | ||
} | ||
if err = d.Set("function_keys", res.FunctionKeys); err != nil { |
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.
actually instead can we expose the values from this field in a defensive manner (see above) - exposing a map of values isn't a great UX since these can change in the API response
layout: 'azurerm' | ||
page_title: 'Azure Resource Manager: azurerm_function_app_host_keys' | ||
description: |- | ||
Gets HostKeys of an existing Function App. |
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.
Gets HostKeys of an existing Function App. | |
Gets the Host Keys of an existing Function App. |
|
||
# Data Source: azurerm_function_app_host_keys | ||
|
||
Use this data source to fetch the Hostkeys of an existing Function App |
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.
Use this data source to fetch the Hostkeys of an existing Function App | |
Use this data source to fetch the Host Keys of an existing Function App |
|
||
```hcl | ||
data "azurerm_function_app_host_keys" "example" { | ||
name = "test-azure-functions" |
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.
name = "test-azure-functions" | |
name = "example-function" |
|
||
- `function_keys` - A key-value pair of Host level function keys. | ||
|
||
- `system_keys` - A key-value pair of system keys |
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.
(as above) can we make these specific fields rather than maps
Co-authored-by: Tom Harvey <[email protected]>
…3mard/terraform-provider-azurerm into add-data-source-function-appp-host-keys
6b2ba8d
to
1bae371
Compare
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've taken another look through and left some comments inline, one thing I'm uncertain is about how should we set the ID for this data source, maybe Tom shall shed some light on it.
Otherwise, this is mostly looking good to me 👍
azurerm/internal/services/web/data_source_function_app_host_keys.go
Outdated
Show resolved
Hide resolved
…ys.go Co-authored-by: magodo <[email protected]>
…vider-azurerm into add-data-source-function-appp-host-keys
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.
It almost look good to me, except a minor wording change. Otherwise, it should be good to go 🚀
Co-authored-by: magodo <[email protected]>
function_app_host_keys
function_app_host_keys
function_app_host_keys
azurerm_function_app_host_keys
This has been released in version 2.27.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.27.0"
}
# ... other configuration ... |
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! |
This PR closes #699