-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(testing): add new test case for #9
- Loading branch information
Showing
5 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
terraform { | ||
required_providers { | ||
storagegrid = { | ||
source = "github.com/dmpe/storagegrid" | ||
} | ||
} | ||
} | ||
|
||
provider "storagegrid" { | ||
address = "https://grid.firm.com:9443/api/v3" | ||
username = var.grid_username | ||
password = var.grid_password | ||
tenant = var.grid_tenant_iid | ||
insecure = true | ||
} | ||
|
||
# Create multiple groups dynamically | ||
resource "storagegrid_groups" "groups" { | ||
for_each = { for g in var.groups : g.unique_name => g } | ||
unique_name = each.value.unique_name | ||
display_name = each.value.display_name | ||
management_read_only = each.value.management_read_only | ||
|
||
policies = { | ||
management = each.value.management_policies | ||
s3 = each.value.s3 | ||
} | ||
} | ||
|
||
# Create multiple users dynamically | ||
resource "storagegrid_users" "users" { | ||
for_each = { for u in var.users : u.unique_name => u } | ||
unique_name = each.value.unique_name | ||
full_name = each.value.full_name | ||
disable = each.value.disable | ||
member_of = [for group_name in each.value.member_of : storagegrid_groups.groups[group_name].id] | ||
} | ||
|
||
# Create multiple user's s3 access keys dynamically | ||
resource "storagegrid_s3_access_key" "user_keys" { | ||
for_each = { for u in var.users : u.unique_name => u if u.create_key == true } | ||
user_uuid = storagegrid_users.users[each.value.unique_name].id | ||
expires = each.value.key_expiry | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
groups = [ | ||
{ | ||
unique_name = "group/demo" | ||
display_name = "Demo" | ||
management_policies = { | ||
manage_all_containers = false | ||
manage_endpoints = false | ||
manage_own_container_objects = true | ||
manage_own_s3_credentials = true | ||
root_access = false | ||
view_all_containers = false | ||
} | ||
s3 = { | ||
statement = [ | ||
{ | ||
sid = "deny-policy" | ||
effect = "Deny" | ||
action = ["s3:*"] | ||
resource = ["arn:aws:s3:::"] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
|
||
users = [ | ||
{ | ||
unique_name = "user/bill" | ||
full_name = "Bill" | ||
disable = false | ||
member_of = ["group/demo"] | ||
create_key = true | ||
key_expiry = "2026-01-01T00:00:00.000Z" | ||
}, | ||
{ | ||
unique_name = "user/jill" | ||
full_name = "Jill" | ||
disable = false | ||
member_of = ["group/demo"] | ||
create_key = false | ||
}, | ||
|
||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
variable "grid_username" { | ||
description = "Grid username" | ||
type = string | ||
} | ||
|
||
variable "grid_password" { | ||
description = "Grid password" | ||
type = string | ||
} | ||
|
||
variable "grid_tenant_iid" { | ||
description = "Tenant ID" | ||
type = string | ||
} | ||
|
||
variable "groups" { | ||
description = "List of groups to create" | ||
type = list(object({ | ||
unique_name = string | ||
display_name = string | ||
management_read_only = optional(bool, true) | ||
management_policies = object({ | ||
manage_all_containers = bool | ||
manage_endpoints = bool | ||
manage_own_container_objects = bool | ||
manage_own_s3_credentials = bool | ||
root_access = bool | ||
view_all_containers = bool | ||
}) | ||
s3 = object({ | ||
statement = list(object({ | ||
sid = string | ||
effect = string | ||
action = list(string) | ||
resource = list(string) | ||
})) | ||
}) | ||
})) | ||
} | ||
|
||
variable "users" { | ||
description = "List of users to create" | ||
type = list(object({ | ||
unique_name = string | ||
full_name = string | ||
disable = optional(bool, false) | ||
member_of = list(string) # List of group unique_names to assign the user to | ||
create_key = optional(bool, false) # New field to determine if a key should be created | ||
key_expiry = optional(string, "") # Optional expiration for the key (ISO 8601 format, e.g., "2028-01-01T00:00:00.000Z") | ||
})) | ||
} |