Skip to content

Commit

Permalink
Updates to Docker build and Terraform Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
h2ouw8n4 committed Nov 4, 2023
1 parent c4be471 commit 68da0f7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 9 deletions.
61 changes: 57 additions & 4 deletions db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,72 @@ resource "random_string" "snapshot_suffix" {

resource "aws_rds_cluster" "this" {
cluster_identifier = "${var.prefix}-${var.environment}"
engine = "aurora-mysql"
engine_mode = "provisioned"
database_name = "wordpress"
engine_version = var.db_engine_version
engine = "aurora-mysql"
engine_version = "8.0.mysql_aurora.3.04.0"
enable_http_endpoint = false
master_username = var.db_master_username
master_password = var.db_master_password
backup_retention_period = var.db_backup_retention_days
preferred_backup_window = var.db_backup_window
final_snapshot_identifier = "${var.prefix}-${var.environment}-${random_string.snapshot_suffix.result}"
storage_encrypted = true
enabled_cloudwatch_logs_exports = ["audit"]

serverlessv2_scaling_configuration {
min_capacity = 1
max_capacity = 2
}

db_subnet_group_name = aws_db_subnet_group.this.name
vpc_security_group_ids = [aws_security_group.db.id]
availability_zones = [data.aws_availability_zones.this.names[0], data.aws_availability_zones.this.names[1], data.aws_availability_zones.this.names[2]]
tags = var.tags

skip_final_snapshot = true
apply_immediately = true
}

resource "aws_rds_cluster_instance" "cluster_instances" {
engine = "aurora-mysql"
engine_version = "8.0.mysql_aurora.3.04.0"
cluster_identifier = "${var.prefix}-${var.environment}"
instance_class = "db.serverless"

# Enhanced monitoring
monitoring_interval = 30
monitoring_role_arn = aws_iam_role.rds_enhanced_monitoring.arn

performance_insights_enabled = true
performance_insights_retention_period = 7
}

################################################################################
# Create an IAM role to allow enhanced monitoring
################################################################################

resource "aws_iam_role" "rds_enhanced_monitoring" {
name_prefix = "rds-enhanced-monitoring-"
assume_role_policy = data.aws_iam_policy_document.rds_enhanced_monitoring.json
}

resource "aws_iam_role_policy_attachment" "rds_enhanced_monitoring" {
role = aws_iam_role.rds_enhanced_monitoring.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole"
}

data "aws_iam_policy_document" "rds_enhanced_monitoring" {
statement {
actions = [
"sts:AssumeRole",
]

effect = "Allow"

principals {
type = "Service"
identifiers = ["monitoring.rds.amazonaws.com"]
}
}
}

resource "aws_db_subnet_group" "this" {
Expand Down
13 changes: 9 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ RUN apt-get update && \
pecl install memcache && \
docker-php-ext-enable memcache

# Download and install Memcached plugin
RUN curl -o memcached.zip -L -O https://downloads.wordpress.org/plugin/memcached.4.0.0.zip && \
unzip memcached.zip -d /usr/src/wordpress/wp-content/plugins && \
rm memcached.zip
# Download and install Total Cache plugin
RUN curl -o w3-total-cache.zip -L -O https://downloads.wordpress.org/plugin/w3-total-cache.2.5.0.zip && \
unzip w3-total-cache.zip -d /usr/src/wordpress/wp-content/plugins && \
rm w3-total-cache.zip

RUN curl -o latest-64bit -L -O https://elasticache-downloads.s3.amazonaws.com/ClusterClient/PHP-8.2/latest-64bit-X86-openssl3 && \
tar -zxvf latest-64bit && \
mv artifact/amazon-elasticache-cluster-client.so /usr/lib64/php/8.2/modules/ && \
echo "extension=amazon-elasticache-cluster-client.so" | sudo tee --append /etc/php-7.x.d/50-memcached.ini

# Copy custom .htaccess
COPY custom.htaccess /usr/src/wordpress/.htaccess
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ variable "db_master_password" {
}
variable "db_engine_version" {
description = "The database engine version"
default = "8.0.mysql_aurora.3.03.1"
default = "3.03.2"
}
variable "db_auto_pause" {
description = "Whether to enable auto pause"
Expand Down

0 comments on commit 68da0f7

Please sign in to comment.