The minimal aws_efs_file_system | Resources | hashicorp/aws | Terraform Registry resource example is:
resource "aws_efs_file_system" "my-app-data-efs" {
tags = {
Name = "my-app-data-efs"
}
}
tags = {
Name = "my-app-data-efs"
}
}
In AWS Console, we can go to Amazon EFS >> File systems and verify that it's created. Its attributes are:
Name: my-app-data-efs
File system ID: fs-1d130ce4a92769f59
Encrypted: Unencrypted
Total size: 6.00 KiB
Size in Standard / One Zone: 6.00 KiB
Size in Standard-IA / One Zone-IA: 0 Bytes
Provisioned Throughput (MiB/s): -
File system state: Available
Creation time: Thu, 09 Mar 2023 10:41:55 GMT
Availability Zone: Standard
Performance mode: General Purpose
Throughput mode: Bursting
Lifecycle management:
Lifecycle management:
Transition into IA: None
Transition out of IA: None
Availability zone: Standard
Automatic backups: Disabled
Encrypted: No
File system state: Available
DNS name: No mount targets available
Encrypted: No
File system state: Available
DNS name: No mount targets available
It will have no Access points and no Mount targets defined:
To provide mount target, we need to use aws_efs_mount_target | Resources | hashicorp/aws | Terraform Registry. Required attributes are EFS (for which we want to create mount target) and subnet (in which we want this mount target to be):
resource "aws_efs_mount_target" "my-app-data-efs-mt" {
file_system_id = aws_efs_file_system.my-app-data-efs.id
subnet_id = "subnet-14321c874d6d35c6a"
}
file_system_id = aws_efs_file_system.my-app-data-efs.id
subnet_id = "subnet-14321c874d6d35c6a"
}
terraform plan output:
Terraform will perform the following actions:
# aws_efs_mount_target.my-app-data-efs-mt will be created
+ resource "aws_efs_mount_target" "my-app-data-efs-mt" {
+ availability_zone_id = (known after apply)
+ availability_zone_name = (known after apply)
+ dns_name = (known after apply)
+ file_system_arn = (known after apply)
+ file_system_id = "fs-1d130ce4a92769f59"
+ id = (known after apply)
+ ip_address = (known after apply)
+ mount_target_dns_name = (known after apply)
+ network_interface_id = (known after apply)
+ owner_id = (known after apply)
+ security_groups = (known after apply)
+ subnet_id = "subnet-14321c874d6d35c6a"
}
Plan: 1 to add, 0 to change, 0 to destroy.
After applying this change, we can check again Network settings for EFS where we'll see that mount target is now available:
The next step will be mounting EFS onto EC2 instance.
No comments:
Post a Comment