Updates from bitrot livestream (#16)

- Remove minor version pin for postgres versions (i.e. 12.5 -> 12)
- Update s3 config to use separate versioning and encryption terraform resources
- Use bucket_prefix instead of bucket for bucket naming to avoid name conflicts

Stream: https://youtu.be/KWwKPYuOGBw
This commit is contained in:
sidpalas
2023-01-13 12:43:41 -05:00
committed by GitHub
parent 7a3fdaca72
commit 9949d314f3
13 changed files with 56 additions and 45 deletions

View File

@@ -2,7 +2,7 @@ resource "aws_db_instance" "db_instance" {
allocated_storage = 20
storage_type = "standard"
engine = "postgres"
engine_version = "12.5"
engine_version = "12"
instance_class = "db.t2.micro"
name = var.db_name
username = var.db_user

View File

@@ -1,15 +1,20 @@
resource "aws_s3_bucket" "bucket" {
bucket = var.bucket_name
bucket_prefix = var.bucket_prefix
force_destroy = true
versioning {
enabled = true
}
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
resource "aws_s3_bucket_versioning" "bucket_versioning" {
bucket = aws_s3_bucket.bucket.id
versioning_configuration {
status = "Enabled"
}
}
resource "aws_s3_bucket_server_side_encryption_configuration" "bucket_crypto_conf" {
bucket = aws_s3_bucket.bucket.bucket
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}

View File

@@ -34,8 +34,8 @@ variable "instance_type" {
# S3 Variables
variable "bucket_name" {
description = "name of s3 bucket for app data"
variable "bucket_prefix" {
description = "prefix of s3 bucket for app data"
type = string
}

View File

@@ -37,11 +37,11 @@ module "web_app_1" {
source = "../web-app-module"
# Input Variables
bucket_name = "web-app-1-devops-directive-web-app-data"
bucket_prefix = "web-app-1-data"
domain = "devopsdeployed.com"
app_name = "web-app-1"
environment_name = "production"
instance_type = "t2.small"
instance_type = "t2.micro"
create_dns_zone = true
db_name = "webapp1db"
db_user = "foo"
@@ -52,11 +52,11 @@ module "web_app_2" {
source = "../web-app-module"
# Input Variables
bucket_name = "web-app-2-devops-directive-web-app-data"
bucket_prefix = "web-app-2-data"
domain = "anotherdevopsdeployed.com"
app_name = "web-app-2"
environment_name = "production"
instance_type = "t2.small"
instance_type = "t2.micro"
create_dns_zone = true
db_name = "webapp2db"
db_user = "bar"