Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot init the EFS volume #4

Open
victor-axelsson opened this issue Mar 4, 2024 · 1 comment
Open

Cannot init the EFS volume #4

victor-axelsson opened this issue Mar 4, 2024 · 1 comment

Comments

@victor-axelsson
Copy link

When starting the task, for some reason, the EFS cannot be mounted.

ResourceInitializationError: failed to invoke EFS utils commands to set up EFS volumes: stderr: b'mount.nfs4: mounting fs-<some numbers>.efs.<region>.amazonaws.com:/grafana failed, reason given by server: No such file or directory' : unsuccessful EFS utils command execution; code: 32

It there some misconfiguration with the network or security groups?

@jwavoet
Copy link

jwavoet commented Jul 23, 2024

I solved it by adding an aws_efs_access_point to the ECS service:

resource "aws_efs_access_point" "ecs_service_storage" {
  file_system_id = aws_efs_file_system.ecs_service_storage.id

  posix_user {
    gid = 0
    uid = 472
  }

  root_directory {

    creation_info {
      owner_gid   = 0
      owner_uid   = 472
      permissions = 0755
    }

    path = "/grafana"
  }
}

resource "aws_ecs_task_definition" "ecs_task_definition" {
  family                   = var.service_name
  container_definitions    = local.container_definitions
  network_mode             = "awsvpc"
  cpu                      = var.cpu
  memory                   = var.memory
  requires_compatibilities = ["FARGATE"]
  task_role_arn            = aws_iam_role.ecs_task_role.arn
  execution_role_arn       = aws_iam_role.ecs_task_execution_role.arn

  volume {
    name = "grafana-db"

    efs_volume_configuration {
      file_system_id     = aws_efs_file_system.ecs_service_storage.id
      root_directory     = "/"
      transit_encryption = "ENABLED"
      authorization_config {
        access_point_id = aws_efs_access_point.ecs_service_storage.id
        iam             = "DISABLED"
      }
    }
  }
}

The access point gives the grafana user the correct permissions to write files and folders to EFS.

I created a PR that includes this solution and several other fixes to have this module working again: #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants