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

New Data Source: azurerm_function_app_host_keys #7902

Merged

Conversation

3mard
Copy link

@3mard 3mard commented Jul 26, 2020

This PR closes #699

},
},

"system_keys": {
Copy link
Author

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.

Copy link
Member

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.

Copy link
Author

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

@georghildebrand
Copy link
Contributor

georghildebrand commented Aug 13, 2020

@njuCZ , do you know when this feature will be merged?

@njuCZ
Copy link
Contributor

njuCZ commented Aug 14, 2020

@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.

@georghildebrand
Copy link
Contributor

@njuCZ , thank you for having a look. Its quite urgent for me. I will also ping the devs in the slack channel

@georghildebrand
Copy link
Contributor

@njuCZ , just realized that I have no slack account anymore as i switched jobs. Could you ping the engineers please?

@3mard
Copy link
Author

3mard commented Aug 17, 2020

@georghildebrand you can use this link to request an invitation : https://join.slack.com/t/terraform-azure/shared_invite/enQtNDMzNjQ5NzcxMDc3LWNiY2ZhNThhNDgzNmY0MTM0N2MwZjE4ZGU0MjcxYjUyMzRmN2E5NjZhZmQ0ZTA1OTExMGNjYzA4ZDkwZDYxNDE

@sgettys
Copy link

sgettys commented Aug 18, 2020

I am also waiting on this!

@georghildebrand
Copy link
Contributor

@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

Copy link
Collaborator

@magodo magodo left a 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,
Copy link
Collaborator

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:

Suggested change
ForceNew: true,

},
},

"system_keys": {

This comment was marked as outdated.

if err := d.Set("master_key", res.MasterKey); err != nil {
return err
}
if err = d.Set("function_keys", res.FunctionKeys); err != nil {
Copy link
Collaborator

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?

Suggested change
if err = d.Set("function_keys", res.FunctionKeys); err != nil {
if err = d.Set("function_keys", utils.FlattenMapStringPtrString(res.FunctionKeys)); err != nil {

Copy link
Contributor

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

Copy link
Author

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

Copy link
Collaborator

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above:

Suggested change
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 {
Copy link
Collaborator

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:

Suggested change
if err := d.Set("master_key", res.MasterKey); err != nil {
d.Set("master_key", res.MasterKey)

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a 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,
},
Copy link
Contributor

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())
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 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+)

Copy link
Author

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 ?

Copy link
Contributor

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 👍

Copy link
Author

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 {
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Contributor

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

3mard and others added 3 commits August 29, 2020 23:15
@3mard 3mard force-pushed the add-data-source-function-appp-host-keys branch from 6b2ba8d to 1bae371 Compare August 31, 2020 22:24
Copy link
Collaborator

@magodo magodo left a comment

Choose a reason for hiding this comment

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

@3mard

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 👍

@3mard 3mard requested a review from magodo September 2, 2020 08:18
@jackofallops jackofallops added this to the v2.27.0 milestone Sep 4, 2020
Copy link
Collaborator

@magodo magodo left a comment

Choose a reason for hiding this comment

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

@3mard

It almost look good to me, except a minor wording change. Otherwise, it should be good to go 🚀

@3mard 3mard requested a review from magodo September 4, 2020 09:04
@magodo magodo changed the title Add new data source function_app_host_keys New Data Source: function_app_host_keys Sep 8, 2020
@magodo magodo changed the title New Data Source: function_app_host_keys New Data Source: azurerm_function_app_host_keys Sep 8, 2020
@magodo
Copy link
Collaborator

magodo commented Sep 8, 2020

image

@magodo magodo merged commit 153cf39 into hashicorp:master Sep 8, 2020
magodo added a commit that referenced this pull request Sep 8, 2020
update CHANGELOG.md for #7902
@ghost
Copy link

ghost commented Sep 10, 2020

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 ...

@ghost
Copy link

ghost commented Oct 8, 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 as resolved and limited conversation to collaborators Oct 8, 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.

Feature request: export Functions host keys
7 participants