generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config s3 bucket for nextcloud container + changes along the way (#6245)
- Loading branch information
1 parent
763e362
commit 0f9a7cf
Showing
12 changed files
with
530 additions
and
12 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
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
2 changes: 1 addition & 1 deletion
2
terraform/environments/delius-nextcloud/modules/components/nextcloud/efs.tf
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
3 changes: 3 additions & 0 deletions
3
terraform/environments/delius-nextcloud/modules/components/nextcloud/ip.tf
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,3 @@ | ||
module "ip_addresses" { | ||
source = "../../../../../modules/ip_addresses" | ||
} |
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
110 changes: 110 additions & 0 deletions
110
terraform/environments/delius-nextcloud/modules/components/nextcloud/s3.tf
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,110 @@ | ||
module "s3_bucket_config" { | ||
source = "github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket?ref=v7.0.0" | ||
|
||
providers = { | ||
aws.bucket-replication = aws | ||
} | ||
|
||
bucket_prefix = "${var.env_name}-config" | ||
versioning_enabled = true | ||
sse_algorithm = "AES256" | ||
# Useful guide - https://aws.amazon.com/blogs/storage/how-to-use-aws-datasync-to-migrate-data-between-amazon-s3-buckets/ | ||
bucket_policy_v2 = [{ | ||
effect = "Allow" | ||
actions = [ | ||
"s3:ListBucket", | ||
"s3:GetObject" | ||
] | ||
principals = { | ||
type = "AWS" | ||
identifiers = [ | ||
module.nextcloud_service.task_role_arn, | ||
] | ||
} | ||
}] | ||
|
||
ownership_controls = "BucketOwnerEnforced" # Disable all S3 bucket ACL | ||
|
||
lifecycle_rule = [ | ||
{ | ||
id = "main" | ||
enabled = "Enabled" | ||
prefix = "" | ||
|
||
tags = { | ||
rule = "log" | ||
autoclean = "true" | ||
} | ||
|
||
noncurrent_version_transition = [ | ||
{ | ||
days = 90 | ||
storage_class = "STANDARD_IA" | ||
}, { | ||
days = 365 | ||
storage_class = "GLACIER" | ||
} | ||
] | ||
|
||
noncurrent_version_expiration = { | ||
days = 730 | ||
} | ||
} | ||
] | ||
|
||
tags = var.tags | ||
} | ||
|
||
|
||
resource "random_password" "nextcloud_password_salt" { | ||
length = 16 | ||
} | ||
|
||
resource "aws_ssm_parameter" "nextcloud_secret" { | ||
name = "/${var.env_name}/nextcloud/secret" | ||
type = "SecureString" | ||
value = "replace_me" | ||
lifecycle { | ||
ignore_changes = [ | ||
value | ||
] | ||
} | ||
} | ||
|
||
data "aws_ssm_parameter" "nextcloud_secret" { | ||
name = aws_ssm_parameter.nextcloud_secret.name | ||
} | ||
|
||
resource "aws_s3_object" "config" { | ||
bucket = module.s3_bucket_config.bucket.id | ||
key = "config.json" | ||
content = templatefile("${path.module}/templates/nextcloud-conf.json.tftpl", | ||
{ | ||
nextcloud_passwordsalt = random_password.nextcloud_password_salt.result, | ||
nextcloud_secret = data.aws_ssm_parameter.nextcloud_secret.value, | ||
nextcloud_id = "nextcloud", | ||
redis = { | ||
host = module.nextcloud_service.elasticache_endpoint | ||
port = module.nextcloud_service.elasticache_port | ||
}, | ||
mail = { | ||
server = "replace" | ||
from_address = "replace" | ||
domain = "replace" | ||
} | ||
nextcloud_s01ldap_agent_password = "replace" | ||
fileshare_user_base = "replace" | ||
standard_user_base = "replace" | ||
fs_group_prefix = "replace" | ||
ldap_host = "ldap.dev.delius-core.hmpps-development.modernisation-platform.internal" | ||
pwm_url = "pwm.dev.delius-core.hmpps-development.modernisation-platform.service.justice.gov.uk" | ||
|
||
fileshare_base_groups = "replace" | ||
fileshare_user_base = "replace" | ||
standard_user_base = "replace" | ||
|
||
ldap_user = "cn=admin,ou=Users,dc=moj,dc=com" | ||
nextcloud_s01ldap_agent_password = "replace" | ||
} | ||
) | ||
} |
Oops, something went wrong.