-
Notifications
You must be signed in to change notification settings - Fork 3
/
python-function.tf
71 lines (65 loc) · 1.55 KB
/
python-function.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
resource "local_file" "function_json" {
filename = "${path.module}/azure_function/resource-graph-collector/function.json"
content = <<EOT
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "event",
"type": "timerTrigger",
"direction": "in",
"schedule": "${var.schedule_cron}"
}
]
}
EOT
}
resource "local_file" "host_json" {
filename = "${path.module}/azure_function/host.json"
content = <<EOT
{
"version": "2.0",
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"default": "${var.log_level}"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
}
}
EOT
}
resource "time_sleep" "wait_for_app" {
depends_on = [
azurerm_function_app.function_app
]
create_duration = "30s"
}
resource "null_resource" "deploy_function" {
depends_on = [
time_sleep.wait_for_app
]
triggers = {
code = data.archive_file.function_data.output_sha
config = sha1(jsonencode(azurerm_function_app.function_app.app_settings))
}
provisioner "local-exec" {
command = <<EXEC
python tools/deploy_function_app.py \
--root-dir azure_function \
--function-dir resource-graph-collector \
--subscription ${data.azurerm_subscription.current.display_name} \
--resource-group ${azurerm_resource_group.rg.name} \
--app-name ${azurerm_function_app.function_app.name}
EXEC
}
}