Skip to content

Commit

Permalink
Attempt to mount log folder to EC2 host
Browse files Browse the repository at this point in the history
  • Loading branch information
Pozo committed Jul 16, 2024
1 parent 6390e24 commit 1da922e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<configuration>
<!-- Define a file appender -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/investment-funds.log</file>
<file>/var/log/investment-funds.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>logs/investment-funds.%d{yyyy-MM-dd}.log</fileNamePattern>
Expand Down
10 changes: 10 additions & 0 deletions terraform/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ resource "aws_ecs_task_definition" "investment-funds" {
family = "service"
network_mode = "bridge"
execution_role_arn = aws_iam_role.investmentfunds-ecs-role.arn
volume {
name = "application-logs"
host_path = "/var/log/investment-funds"
}
container_definitions = jsonencode([
{
name = var.ecs_api_container_name
Expand All @@ -79,6 +83,12 @@ resource "aws_ecs_task_definition" "investment-funds" {
containerPort = 8080
}
],
mountPoints = [
{
sourceVolume = "application-logs"
containerPath = "/var/log"
}
]
links = ["investmentfunds-redis"]
},
{
Expand Down
3 changes: 2 additions & 1 deletion terraform/init.sh.tfpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ echo ECS_CLUSTER="${ecs_cluster_name}" >> /etc/ecs/ecs.config
yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
systemctl start amazon-ssm-agent
systemctl enable amazon-ssm-agent

# logs
mkdir -p /var/log/investment-funds
# swapping 2G
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
Expand Down

0 comments on commit 1da922e

Please sign in to comment.