Skip to content

Commit 8fa3e6c

Browse files
authored
Merge pull request #101 from PerfectThymeTech/marvinbuss/update_storage
Update Permission Details in Terraform
2 parents f463c7f + 909eb9f commit 8fa3e6c

File tree

3 files changed

+44
-52
lines changed

3 files changed

+44
-52
lines changed

code/infra/function.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ resource "azapi_resource" "function" {
207207
})
208208

209209
schema_validation_enabled = false
210-
# ignore_body_changes = [
210+
# ignore_body_changes = [ # Required when app settings are managed in a separate process
211211
# "properties.siteConfig.appSettings"
212212
# ]
213213
depends_on = [

code/infra/roleassignments.tf

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,34 @@ resource "azurerm_role_assignment" "current_role_assignment_key_vault" {
44
principal_id = data.azurerm_client_config.current.object_id
55
}
66

7-
resource "azurerm_role_assignment" "function_role_assignment_storage" {
7+
resource "azurerm_role_assignment" "function_role_assignment_storage_blob_data_owner" {
88
scope = azurerm_storage_account.storage.id
99
role_definition_name = "Storage Blob Data Owner"
1010
principal_id = azapi_resource.function.identity[0].principal_id
1111
}
1212

13+
# resource "azurerm_role_assignment" "function_role_assignment_storage_account_contributor" { # Enable when using blob triggers
14+
# scope = azurerm_storage_account.storage.id
15+
# role_definition_name = "Storage Account Contributor"
16+
# principal_id = azapi_resource.function.identity[0].principal_id
17+
# }
18+
19+
# resource "azurerm_role_assignment" "function_role_assignment_storage_queue_data_contributor" { # Enable when using blob triggers
20+
# scope = azurerm_storage_account.storage.id
21+
# role_definition_name = "Storage Queue Data Contributor"
22+
# principal_id = azapi_resource.function.identity[0].principal_id
23+
# }
24+
25+
# Additional permissions may be required based on the trigger that is being used.
26+
# For more details, refer to: https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference?tabs=blob&pivots=programming-language-python#grant-permission-to-the-identity
27+
1328
resource "azurerm_role_assignment" "function_role_assignment_key_vault" {
1429
scope = azurerm_key_vault.key_vault.id
1530
role_definition_name = "Key Vault Secrets Officer"
1631
principal_id = azapi_resource.function.identity[0].principal_id
1732
}
1833

19-
# resource "azurerm_role_assignment" "function_role_assignment_application_insights" {
34+
# resource "azurerm_role_assignment" "function_role_assignment_application_insights" { # Enable to rely on Entra ID-based authentication to Application Insights
2035
# scope = azurerm_application_insights.application_insights.id
2136
# role_definition_name = "Monitoring Metrics Publisher"
2237
# principal_id = azapi_resource.function.identity[0].principal_id

code/infra/storage.tf

Lines changed: 26 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -45,57 +45,34 @@ resource "azurerm_storage_account" "storage" {
4545
publish_microsoft_endpoints = false
4646
}
4747
sftp_enabled = false
48-
shared_access_key_enabled = false
48+
shared_access_key_enabled = false # Required to be set to 'true' when creating a Windows host
4949
}
5050

51-
resource "azurerm_storage_management_policy" "storage_management_policy" {
52-
storage_account_id = azurerm_storage_account.storage.id
53-
54-
rule {
55-
name = "default"
56-
enabled = true
57-
actions {
58-
base_blob {
59-
tier_to_cool_after_days_since_modification_greater_than = 360
60-
# delete_after_days_since_modification_greater_than = 720
61-
}
62-
snapshot {
63-
change_tier_to_cool_after_days_since_creation = 180
64-
delete_after_days_since_creation_greater_than = 360
65-
}
66-
version {
67-
change_tier_to_cool_after_days_since_creation = 180
68-
delete_after_days_since_creation = 360
69-
}
70-
}
71-
filters {
72-
blob_types = ["blockBlob"]
73-
prefix_match = []
74-
}
75-
}
76-
}
77-
78-
resource "azapi_resource" "storage_file_share" {
79-
type = "Microsoft.Storage/storageAccounts/fileServices/shares@2022-09-01"
80-
name = "logicapp"
81-
parent_id = "${azurerm_storage_account.storage.id}/fileServices/default"
82-
83-
body = jsonencode({
84-
properties = {
85-
accessTier = "TransactionOptimized"
86-
enabledProtocols = "SMB"
87-
shareQuota = 5120
88-
}
89-
})
90-
}
91-
92-
# resource "azurerm_storage_share" "storage_file_share" {
93-
# name = "logicapp"
94-
# storage_account_name = azurerm_storage_account.storage.name
95-
96-
# access_tier = "TransactionOptimized"
97-
# enabled_protocol = "SMB"
98-
# quota = 5120
51+
# resource "azurerm_storage_management_policy" "storage_management_policy" {
52+
# storage_account_id = azurerm_storage_account.storage.id
53+
54+
# rule {
55+
# name = "default"
56+
# enabled = true
57+
# actions {
58+
# base_blob {
59+
# tier_to_cool_after_days_since_modification_greater_than = 360
60+
# # delete_after_days_since_modification_greater_than = 720
61+
# }
62+
# snapshot {
63+
# change_tier_to_cool_after_days_since_creation = 180
64+
# delete_after_days_since_creation_greater_than = 360
65+
# }
66+
# version {
67+
# change_tier_to_cool_after_days_since_creation = 180
68+
# delete_after_days_since_creation = 360
69+
# }
70+
# }
71+
# filters {
72+
# blob_types = ["blockBlob"]
73+
# prefix_match = []
74+
# }
75+
# }
9976
# }
10077

10178
data "azurerm_monitor_diagnostic_categories" "diagnostic_categories_storage" {

0 commit comments

Comments
 (0)