From 002cfd4ef2fe1b14b91047bc7ba47aa6c3f7a82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 31 Jul 2019 15:23:31 -0400 Subject: [PATCH] create s3 bucket for backups of db.dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- ansible/group_vars/db.dev.yml | 2 +- dev.tf | 6 ++++++ modules/aws-s3-bucket/main.tf | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ansible/group_vars/db.dev.yml b/ansible/group_vars/db.dev.yml index c4bd17f..6d7658e 100644 --- a/ansible/group_vars/db.dev.yml +++ b/ansible/group_vars/db.dev.yml @@ -33,6 +33,6 @@ mongodb_backup_db_user: '{{ mongodb_users[0].name }}' mongodb_backup_db_pass: '{{ mongodb_users[0].password }}' # backup uploads to S3 -mongodb_backup_bucket_name: 's3://dev-dap-ps-mongodb-backups' +mongodb_backup_bucket_name: 's3://dev-dap-ps-db-backups' mongodb_backup_access_key: '{{lookup("passwordstore", "cloud/aws/s3/mongodb-backups/access-key")}}' mongodb_backup_secret_key: '{{lookup("passwordstore", "cloud/aws/s3/mongodb-backups/secret-key")}}' diff --git a/dev.tf b/dev.tf index d2cee33..2c1833a 100644 --- a/dev.tf +++ b/dev.tf @@ -27,6 +27,12 @@ locals { } } +module "dev_db_bucket" { + source = "./modules/aws-s3-bucket" + bucket_name = "dev-dap-ps-db-backups" + description = "Bucket for MongoDB backups on db.dev" +} + module "dev_db" { source = "./modules/aws-ec2-instance" groups = ["mongodb"] diff --git a/modules/aws-s3-bucket/main.tf b/modules/aws-s3-bucket/main.tf index 36b82b7..688b468 100644 --- a/modules/aws-s3-bucket/main.tf +++ b/modules/aws-s3-bucket/main.tf @@ -20,6 +20,10 @@ resource "aws_s3_bucket" "main" { Desc = var.description } + lifecycle { + prevent_destroy = true + } + policy = <