Last active
July 26, 2022 17:45
-
-
Save lawrencegripper/48cb08fe1c7952f1caf2a18828c6a357 to your computer and use it in GitHub Desktop.
Terraform Azure functions keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the functions keys out of the app | |
resource "azurerm_template_deployment" "function_keys" { | |
name = "javafunckeys${var.random_name_ending}" | |
parameters = { | |
"functionApp" = "${azurerm_function_app.function-app.name}" | |
} | |
resource_group_name = "${var.resource_group_name}" | |
deployment_mode = "Incremental" | |
template_body = <<BODY | |
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"functionApp": {"type": "string", "defaultValue": ""} | |
}, | |
"variables": { | |
"functionAppId": "[resourceId('Microsoft.Web/sites', parameters('functionApp'))]" | |
}, | |
"resources": [ | |
], | |
"outputs": { | |
"functionkey": { | |
"type": "string", | |
"value": "[listkeys(concat(variables('functionAppId'), '/host/default'), '2018-11-01').functionKeys.default]" } | |
} | |
} | |
BODY | |
} | |
output "func_keys" { | |
value = "${lookup(azurerm_template_deployment.function_keys.outputs, "functionkey")}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the response from the `listkeys` function in ARM so we use `.functionKeys.default` to reach into it and output | |
// the function key we need. | |
{ | |
"functionKeys": { | |
"default": "KEYEHERE...qtocq1safFGhAwZkzPe1VdRflvg==" | |
}, | |
"masterKey": "KEYEHERE......Ju1384KHUprI01kH5GIKH2uvrqew==", | |
"systemKeys": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment