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

Storage - Add files to storage shares #626

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ storage_accounts = {
name = "testdirectory"
}
}
files = {
file1 = {
name = "fileA"
source = "/tf/caf/examples/storage_accounts/104-file-share-with-backup/fileA"
}
file2 = {
name = "fileB"
source = "/tf/caf/examples/storage_accounts/104-file-share-with-backup/fileB"
path = "testdirectory"
}
file3 = {
name = "fileC"
source = "./storage_accounts/104-file-share-with-backup/fileC"
path = "testdirectory"
}
}

# backups = {
# policy_key = "policy1"
Expand Down
1 change: 1 addition & 0 deletions examples/storage_accounts/104-file-share-with-backup/fileA
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is fileA
1 change: 1 addition & 0 deletions examples/storage_accounts/104-file-share-with-backup/fileB
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is file B
1 change: 1 addition & 0 deletions examples/storage_accounts/104-file-share-with-backup/fileC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is fileC
8 changes: 8 additions & 0 deletions modules/storage_account/file_share/share_file.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module "file_share_file" {
source = "../file_share_file"
depends_on = [module.file_share_directory]
for_each = try(var.settings.files, {})

share_id = azurerm_storage_share.fs.id
settings = each.value
}
11 changes: 11 additions & 0 deletions modules/storage_account/file_share_file/file.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "azurerm_storage_share_file" "share_file" {
name = var.settings.name
storage_share_id = var.share_id
path = try(var.settings.path, null)
source = try(var.settings.source, null)
content_type = try(var.settings.content_type, null)
content_md5 = try(var.settings.content_md5, null)
content_encoding = try(var.settings.content_encoding, null)
content_disposition = try(var.settings.content_disposition, null)
metadata = try(var.settings.metadata, null)
}
4 changes: 4 additions & 0 deletions modules/storage_account/file_share_file/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "id" {
value = azurerm_storage_share_file.share_file.id
}

2 changes: 2 additions & 0 deletions modules/storage_account/file_share_file/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
variable "share_id" {}
variable "settings" {}