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

Getting host/function keys #1493

Closed

Conversation

TsuyoshiUshio
Copy link
Contributor

Hi, I open this pull request to start discussion of this feature.

This PR is related for this issue. #699

I start with creating data source and document for start discussion. Once the design is accepted, I'll implement test code as well.

Design

The initial design is something like this.

data "azurerm_function_app_key_management" "test" {
  name                = "yourfunctionappname"
  function_name       = "HttpTriggerCSharp1"
  resource_group_name = "AzureFunctionSpike"
}

output "function_function_name_key" {
  value = "${data.azurerm_function_app_key_management.test.function_keys["default"]}"
}

Currently, I implement to retrive function key. I'll add host key after finishing the first reivew.

The API is not ARM api, that is why the resource doesn't return host keys.
To fetch function/host key is

https://github.com/Azure/azure-functions-host/wiki/Key-management-API

That is why I create a new data source for this API.

Questions

I have some questions.

I have issue for missing variables

I implement the code however, I've got this error.

* output.function_function_name_key: Resource 'data.azurerm_function_app_key_management.test' not found for variable 'data.azurerm_function_app_key_management.test.function_keys'

terraform can find the new data resource however not for the variable.

$ terraform apply
data.azurerm_function_app_key_management.test: Refreshing state...

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
 <= read (data resources)

Terraform will perform the following actions:

 <= data.azurerm_function_app_key_management.test
      id:                  <computed>
      function_keys.%:     <computed>
      function_name:       "HttpTriggerCSharp1"
      name:                "somename"
      resource_group_name: "AzureFunctionSpike"


Plan: 0 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

data.azurerm_function_app_key_management.test: Refreshing state...

Error: Error applying plan:

1 error(s) occurred:

* output.function_function_name_key: Resource 'data.azurerm_function_app_key_management.test' not found for variable 'data.azurerm_function_app_key_management.test.function_keys'

The then function_key is implemented on the

		Schema: map[string]*schema.Schema{
			"name": {
				Type:     schema.TypeString,
				Required: true,
				ForceNew: true,
			},
			"function_name": {
				Type:     schema.TypeString,
				Required: true,
				ForceNew: true,
			},
			"resource_group_name": resourceGroupNameDiffSuppressSchema(),
			"function_keys": {
				Type:     schema.TypeMap,
				Computed: true,
			},
		},

I don't know why it can't find the variable. Could you give me some advice?

Design review

I create the new resource data_source_function_app_key_management. Could you provide review for the naming, design before I'm adding host keys feature and test code.

@tombuildsstuff
Copy link
Contributor

hey @TsuyoshiUshio

Thanks for opening this PR - apologies for the delayed response here!

I implement the code however, I've got this error.

  • output.function_function_name_key: Resource 'data.azurerm_function_app_key_management.test' not found for variable 'data.azurerm_function_app_key_management.test.function_keys'

So you're seeing this error because no ID's being set for the Data Source - which means it's not persisted in the state (and thus the values aren't available). Setting a value via d.SetId("") should be all that's needed here

I start with creating data source and document for start discussion. Once the design is accepted, I'll implement test code as well.

I think there's a larger question of where this SDK belongs, if I'm honest I think this probably belongs within the Azure SDK for Go repository as a Data Plane SDK, rather than being located within this repository. Once that's available in the Go SDK - I believe this'd make sense to be located as properties on the azurerm_function_app Data Source and Resource, rather than as a separate resource; what do you think?

Thanks!

@TsuyoshiUshio
Copy link
Contributor Author

Hi @tombuildsstuff ,

Thank you for your response! Agree. Start implementing the azure_function_app Data Source. KeyManagmentAPI is confusing. I hide it behind the azurerm_function_app. :)

@TsuyoshiUshio
Copy link
Contributor Author

@tombuildsstuff Yes. You right. The KeyManagement SDK should be included Azure-SDK-for-Go. I'll talk with them.

@tombuildsstuff tombuildsstuff added upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR and removed waiting-response labels Aug 6, 2018
@tombuildsstuff
Copy link
Contributor

hey @TsuyoshiUshio

Since this PR is blocked on the upstream feature request for an SDK for Function Apps - rather than leaving this PR open until then I'm going to close this PR for the moment until that's resolved - I hope you don't mind. Once the SDK for Function Apps is available we should be able to re-use the bits of this PR with the new SDK.

Thanks!

@ghost
Copy link

ghost commented Mar 6, 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. 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 Mar 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-data-source service/functions Function Apps upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants