Bootstrap FreeKB - Amazon Web Services (AWS) - List Elastic File System (EFS) Access Points using Terraform
Amazon Web Services (AWS) - List Elastic File System (EFS) Access Points using Terraform

Updated:   |  Amazon Web Services (AWS) articles

Let's say you have the following files on your Terraform server.

├ required_providers.tf
├ efs (directory)
├── access_points.tf
├── elastic_file_systems.tf
├── mount_targets.tf
├── outputs.tf
├── provider.tf

 

required_providers.tf will almost always have this.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
    }
  }
}

 

Let's say provider.tf has the following. In this example, the "default" profile in /home/username/.aws/config and /home/username/.aws/credentials is being used. This assumes you have setup Terraform as described in Amazon Web Services (AWS) - Getting Started with Terraform.

provider "aws" {
  alias   = "default"
  profile = "default"
  region  = "default"
}

 

And let's say access_points.tf contains the following, to get the details of the Elastic File System Access Point that has ID fsap-123456789abcdefg.

data "aws_efs_access_point" "efs-access-point" {
  access_point_id = "fsap-123456789abcdefg"
}

 

And outputs.tf could then have something like this.

output "efs_access_point" {
  value = data.aws_efs_access_point.efs-access-point
}

 

You may need to issue the terraform init command.

terraform init

 

And then the terraform refresh command should return something like this.

]$ terraform refresh

efs_access_point = {
  "access_point_id" = "fsap-123456789abcdefg"
  "arn" = "arn:aws:elasticfilesystem:us-east-1:123456789012:access-point/fsap-123456789abcdefg"
  "file_system_arn" = "arn:aws:elasticfilesystem:us-east-1:123456789012:file-system/fs-123456789abcdefg"
  "file_system_id" = "fs-123456789abcdefg"
  "id" = "fsap-123456789abcdefg"
  "owner_id" = "123456789012"
  "posix_user" = tolist([
    {
      "gid" = 1000
      "secondary_gids" = toset([])
      "uid" = 1000
    },
  ])
  "root_directory" = tolist([
    {
      "creation_info" = tolist([
        {
          "owner_gid" = 1000
          "owner_uid" = 1000
          "permissions" = "0755"
        },
      ])
      "path" = "/efs"
    },
  ])
  "tags" = tomap({
    "Environment" = "Development"
  })
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c58017 in the box below so that we can be sure you are a human.