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 mount_targets.tf contains the following, to get the details of the Elastic File System Mount Target that has ID fsap-123456789abcdefg.
data "aws_efs_mount_target" "efs-mount-target" {
  mount_target_id = "fsmt-123456789abcdefg"
}
And outputs.tf could then have something like this.
output "efs_mount_target" {
  value = data.aws_efs_mount_target.efs-mount-target
}
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_mount_target = {
  "access_point_id" = tostring(null)
  "availability_zone_id" = "use1-az1"
  "availability_zone_name" = "us-east-1a"
  "dns_name" = "fs-123456789abcefg.efs.us-east-1.amazonaws.com"
  "file_system_arn" = "arn:aws:elasticfilesystem:us-east-1:123456789012:file-system/fs-123456789abcefg"
  "file_system_id" = "fs-123456789abcefg"
  "id" = "fsmt-123456789abcefg"
  "ip_address" = "10.29.40.66"
  "mount_target_dns_name" = "us-east-1a.fs-123456789abcefg.efs.us-east-1.amazonaws.com"
  "mount_target_id" = "fsmt-123456789abcefg"
  "network_interface_id" = "eni-123456789abcefg"
  "owner_id" = "123456789012"
  "security_groups" = toset([
    "sg-123456789abcefg",
  ])
  "subnet_id" = "subnet-123456789abcefg"
}
Did you find this article helpful?
If so, consider buying me a coffee over at 