{"action":"created","issue":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/2547","repository_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm","labels_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/2547/labels{/name}","comments_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/2547/comments","events_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/2547/events","html_url":"https://github.com/terraform-providers/terraform-provider-azurerm/issues/2547","id":392625489,"node_id":"MDU6SXNzdWUzOTI2MjU0ODk=","number":2547,"title":"Implement Application Insights API Key management","user":{"login":"BzSpi","id":1766776,"node_id":"MDQ6VXNlcjE3NjY3NzY=","avatar_url":"https://avatars1.githubusercontent.com/u/1766776?v=4","gravatar_id":"","url":"https://api.github.com/users/BzSpi","html_url":"https://github.com/BzSpi","followers_url":"https://api.github.com/users/BzSpi/followers","following_url":"https://api.github.com/users/BzSpi/following{/other_user}","gists_url":"https://api.github.com/users/BzSpi/gists{/gist_id}","starred_url":"https://api.github.com/users/BzSpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BzSpi/subscriptions","organizations_url":"https://api.github.com/users/BzSpi/orgs","repos_url":"https://api.github.com/users/BzSpi/repos","events_url":"https://api.github.com/users/BzSpi/events{/privacy}","received_events_url":"https://api.github.com/users/BzSpi/received_events","type":"User","site_admin":false},"labels":[{"id":625925838,"node_id":"MDU6TGFiZWw2MjU5MjU4Mzg=","url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/labels/new-resource","name":"new-resource","color":"d4c5f9","default":false},{"id":838482899,"node_id":"MDU6TGFiZWw4Mzg0ODI4OTk=","url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/labels/service/application-insights","name":"service/application-insights","color":"2dcec1","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-12-19T14:27:40Z","updated_at":"2018-12-21T14:45:17Z","closed_at":null,"author_association":"NONE","body":"<!--- Please keep this note for the community --->\r\n\r\n### Community Note\r\n\r\n* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request\r\n* Please do not leave \"+1\" or \"me too\" comments, they generate extra noise for issue followers and do not help prioritize the request\r\n* If you are interested in working on this issue or have submitted a pull request, please leave a comment\r\n\r\n<!--- Thank you for keeping this note for the community --->\r\n\r\n### Description\r\n\r\nWe should have the availability to create an API Key in Terraform.\r\n\r\n### New or Affected Resource(s)\r\n\r\n<!--- Please list the new or affected resources and data sources. --->\r\n\r\n* azurerm_application_insights_api_key\r\n\r\n### Potential Terraform Configuration\r\n\r\n<!--- Information about code formatting: https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code --->\r\n\r\n```hcl\r\nresource \"azurerm_application_insights\" \"my_application_insights\" {\r\n  name = \"my-application-insights\"\r\n\r\n  location            = \"${var.location}\"\r\n  resource_group_name = \"${var.resource_group_name}\"\r\n\r\n  application_type = \"Other\"\r\n}\r\n\r\nresource \"azurerm_application_insights_api_key\" \"my_api_key\" {\r\n  name = \"my-api-key\"\r\n\r\n  application_insights_id = \"${azurerm_application_insights.my_application_insights.id}\"\r\n\r\n  resource_group_name = \"${var.resource_group_name}\"\r\n\r\n  read_telemetry = false\r\n  write_annotations = false\r\n  authenticate_sdk_control_channel = false\r\n}\r\n\r\noutput \"my_api_key_id\" {\r\n  value = \"${azurerm_application_insights_api_key.my_api_key.id}\"\r\n}\r\n\r\noutput \"my_api_key_api_key\" {\r\n  value = \"${azurerm_application_insights_api_key.my_api_key.apikey}\"\r\n}\r\n\r\noutput \"my_api_key_name\" {\r\n  value = \"${azurerm_application_insights_api_key.my_api_key.name}\"\r\n}\r\n\r\noutput \"my_api_key_linked_read_properties\" {\r\n  value = \"${azurerm_application_insights_api_key.my_api_key.linked_read_properties}\"\r\n}\r\n\r\noutput \"my_api_key_linked_write_properties\" {\r\n  value = \"${azurerm_application_insights_api_key.my_api_key.linked_write_properties}\"\r\n}```\r\n"},"comment":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/comments/449406507","html_url":"https://github.com/terraform-providers/terraform-provider-azurerm/issues/2547#issuecomment-449406507","issue_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/2547","id":449406507,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTQwNjUwNw==","user":{"login":"BzSpi","id":1766776,"node_id":"MDQ6VXNlcjE3NjY3NzY=","avatar_url":"https://avatars1.githubusercontent.com/u/1766776?v=4","gravatar_id":"","url":"https://api.github.com/users/BzSpi","html_url":"https://github.com/BzSpi","followers_url":"https://api.github.com/users/BzSpi/followers","following_url":"https://api.github.com/users/BzSpi/following{/other_user}","gists_url":"https://api.github.com/users/BzSpi/gists{/gist_id}","starred_url":"https://api.github.com/users/BzSpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BzSpi/subscriptions","organizations_url":"https://api.github.com/users/BzSpi/orgs","repos_url":"https://api.github.com/users/BzSpi/repos","events_url":"https://api.github.com/users/BzSpi/events{/privacy}","received_events_url":"https://api.github.com/users/BzSpi/received_events","type":"User","site_admin":false},"created_at":"2018-12-21T14:45:17Z","updated_at":"2018-12-21T14:45:17Z","author_association":"NONE","body":"The PR works well. Thanks @pdecat !\r\n\r\nOne thing that bothers me is that if I only ask for the `api` permission, I have a diff on the next apply since Azure automatically sets the permissions `aggregate`, `draft`, `extendqueries` and `search`.\r\nIf I automatically set the permissions `[\"aggregate\", \"api\", \"draft\", \"extendqueries\", \"search\"]` I don't have any issue, even if I change the list order.\r\n\r\nI haven't found any documentation on this subject.\r\n\r\nMy code\r\n```\r\nresource \"azurerm_application_insights_api_key\" \"my_api_key\" {\r\n  name = \"my-api-key\"\r\n\r\n  application_insights_id = \"${azurerm_application_insights.appinsights_functions.id}\"\r\n\r\n  read_permissions  = [\"api\"]\r\n}\r\n```\r\n\r\nFirst apply\r\n```\r\nTerraform will perform the following actions:\r\n\r\n  + azurerm_application_insights_api_key.my_api_key\r\n      id:                          <computed>\r\n      api_key:                     <computed>\r\n      application_insights_id:     \"xxxxxxxxxxxxxxxxxxxxxx\"\r\n      name:                        \"my-api-key\"\r\n      read_permissions.#:          \"1\"\r\n      read_permissions.2902841359: \"api\"\r\n```\r\n\r\nSecond apply\r\n```\r\n-/+ azurerm_application_insights_api_key.my_api_key (new resource required)\r\n      id:                          \"xxxxxxxxxxxxxxxxxxxxxx\" => <computed> (forces new resource)\r\n      api_key:                     <sensitive> => <computed> (attribute changed)\r\n      application_insights_id:     \"xxxxxxxxxxxxxxxxxxxxxx\" => \"xxxxxxxxxxxxxxxxxxxxxx\"\r\n      name:                        \"my-api-key\" => \"my-api-key\"\r\n      read_permissions.#:          \"5\" => \"1\" (forces new resource)\r\n      read_permissions.1182570132: \"draft\" => \"\" (forces new resource)\r\n      read_permissions.2421119739: \"extendqueries\" => \"\" (forces new resource)\r\n      read_permissions.2902841359: \"api\" => \"api\"\r\n      read_permissions.3035683751: \"search\" => \"\" (forces new resource)\r\n      read_permissions.3078179327: \"aggregate\" => \"\" (forces new resource)\r\n```\r\n\r\n@tombuildsstuff Any idea on how to handle this ?"}}
{"actor":{"display_login":"BzSpi"}}