

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 AWS SDKs Amazon EFS 程式碼範例
<a name="efs_code_examples"></a>

下列程式碼範例示範如何使用 Amazon Elastic File System 搭配 AWS 軟體開發套件 (SDK)。

*Actions* 是大型程式的程式碼摘錄，必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數，但您可以在其相關情境中查看內容中的動作。

**其他資源**
+  **[Amazon EFS 開發人員指南](https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html)** – Amazon EFS 的詳細資訊。
+ **[Amazon EFS API 參考](https://docs.aws.amazon.com/efs/latest/ug/api-reference.html)** – 所有可用 Amazon EFS 動作的詳細資訊。
+ **[AWS 開發人員中心](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23)** – 您可以依類別或全文搜尋篩選的程式碼範例。
+ **[AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)** – GitHub 儲存庫使用慣用語言的完整程式碼。包含設定和執行程式碼的指示。

**Contents**
+ [基本概念](efs_code_examples_basics.md)
  + [動作](efs_code_examples_actions.md)
    + [`CreateFileSystem`](efs_example_efs_CreateFileSystem_section.md)
    + [`CreateMountTarget`](efs_example_efs_CreateMountTarget_section.md)
    + [`DeleteFileSystem`](efs_example_efs_DeleteFileSystem_section.md)
    + [`DeleteMountTarget`](efs_example_efs_DeleteMountTarget_section.md)
    + [`DescribeFileSystems`](efs_example_efs_DescribeFileSystems_section.md)
    + [`DescribeMountTargets`](efs_example_efs_DescribeMountTargets_section.md)
    + [`DescribeTags`](efs_example_efs_DescribeTags_section.md)

# 使用 AWS SDKs 的 Amazon EFS 基本範例
<a name="efs_code_examples_basics"></a>

下列程式碼範例示範如何搭配 AWS SDK 使用 Amazon Elastic File System 的基本功能。

**Contents**
+ [動作](efs_code_examples_actions.md)
  + [`CreateFileSystem`](efs_example_efs_CreateFileSystem_section.md)
  + [`CreateMountTarget`](efs_example_efs_CreateMountTarget_section.md)
  + [`DeleteFileSystem`](efs_example_efs_DeleteFileSystem_section.md)
  + [`DeleteMountTarget`](efs_example_efs_DeleteMountTarget_section.md)
  + [`DescribeFileSystems`](efs_example_efs_DescribeFileSystems_section.md)
  + [`DescribeMountTargets`](efs_example_efs_DescribeMountTargets_section.md)
  + [`DescribeTags`](efs_example_efs_DescribeTags_section.md)

# Amazon EFS AWS SDKs的動作
<a name="efs_code_examples_actions"></a>

下列程式碼範例示範如何使用 AWS SDKs 執行個別 Amazon EFS 動作。每個範例均包含 GitHub 的連結，您可以在連結中找到設定和執行程式碼的相關說明。

 下列範例僅包含最常使用的動作。如需完整清單，請參閱《[Amazon Elastic File System API 參考](https://docs.aws.amazon.com/efs/latest/ug/api-reference.html)》。

**Topics**
+ [`CreateFileSystem`](efs_example_efs_CreateFileSystem_section.md)
+ [`CreateMountTarget`](efs_example_efs_CreateMountTarget_section.md)
+ [`DeleteFileSystem`](efs_example_efs_DeleteFileSystem_section.md)
+ [`DeleteMountTarget`](efs_example_efs_DeleteMountTarget_section.md)
+ [`DescribeFileSystems`](efs_example_efs_DescribeFileSystems_section.md)
+ [`DescribeMountTargets`](efs_example_efs_DescribeMountTargets_section.md)
+ [`DescribeTags`](efs_example_efs_DescribeTags_section.md)

# 搭配使用 `CreateFileSystem` 與 CLI
<a name="efs_example_efs_CreateFileSystem_section"></a>

下列程式碼範例示範如何使用 `CreateFileSystem`。

------
#### [ CLI ]

**AWS CLI**  
**建立加密的檔案系統**  
下列 `create-file-system` 範例會使用預設 CMK 建立加密的檔案系統。另外也會新增標籤 `Name=my-file-system`。  

```
aws efs create-file-system \
    --performance-mode generalPurpose \
    --throughput-mode bursting \
    --encrypted \
    --tags Key=Name,Value=my-file-system
```
輸出：  

```
{
    "OwnerId": "123456789012",
    "CreationToken": "console-d7f56c5f-e433-41ca-8307-9d9c0example",
    "FileSystemId": "fs-c7a0456e",
    "FileSystemArn": "arn:aws:elasticfilesystem:us-west-2:123456789012:file-system/fs-48499b4d",
    "CreationTime": 1595286880.0,
    "LifeCycleState": "creating",
    "Name": "my-file-system",
    "NumberOfMountTargets": 0,
    "SizeInBytes": {
        "Value": 0,
        "ValueInIA": 0,
        "ValueInStandard": 0
    },
    "PerformanceMode": "generalPurpose",
    "Encrypted": true,
    "KmsKeyId": "arn:aws:kms:us-west-2:123456789012:key/a59b3472-e62c-42e4-adcf-30d92example",
    "ThroughputMode": "bursting",
    "Tags": [
        {
            "Key": "Name",
            "Value": "my-file-system"
        }
    ]
}
```
如需詳細資訊，請參閱《Amazon Elastic File System 使用者指南》**中的[建立 Amazon EFS 檔案系統](https://docs.aws.amazon.com/efs/latest/ug/creating-using-create-fs.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateFileSystem](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/create-file-system.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：建立新的空檔案系統。用於確保冪等建立的字符會自動產生，並且可以從傳回物件的 `CreationToken` 成員存取。**  

```
New-EFSFileSystem
```
**輸出：**  

```
CreationTime         : 5/26/2015 4:02:38 PM
CreationToken        : 1a2bff54-85e0-4747-bd95-7bc172c4f555
FileSystemId         : fs-1a2b3c4d
LifeCycleState       : creating
Name                 :
NumberOfMountTargets : 0
OwnerId              : 123456789012
SizeInBytes          : Amazon.ElasticFileSystem.Model.FileSystemSize
```
**範例 2：使用自訂字符建立新的空檔案系統，以確保冪等建立。**  

```
New-EFSFileSystem -CreationToken "MyUniqueToken"
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [CreateFileSystem](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：建立新的空檔案系統。用於確保冪等建立的字符會自動產生，並且可以從傳回物件的 `CreationToken` 成員存取。**  

```
New-EFSFileSystem
```
**輸出：**  

```
CreationTime         : 5/26/2015 4:02:38 PM
CreationToken        : 1a2bff54-85e0-4747-bd95-7bc172c4f555
FileSystemId         : fs-1a2b3c4d
LifeCycleState       : creating
Name                 :
NumberOfMountTargets : 0
OwnerId              : 123456789012
SizeInBytes          : Amazon.ElasticFileSystem.Model.FileSystemSize
```
**範例 2：使用自訂字符建立新的空檔案系統，以確保冪等建立。**  

```
New-EFSFileSystem -CreationToken "MyUniqueToken"
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [CreateFileSystem](https://docs.aws.amazon.com/powershell/v5/reference)。

------

# 搭配使用 `CreateMountTarget` 與 CLI
<a name="efs_example_efs_CreateMountTarget_section"></a>

下列程式碼範例示範如何使用 `CreateMountTarget`。

------
#### [ CLI ]

**AWS CLI**  
**建立掛載目標**  
下列 `create-mount-target` 範例會為指定的檔案系統建立掛載目標。  

```
aws efs create-mount-target \
    --file-system-id fs-c7a0456e \
    --subnet-id subnet-02bf4c428bexample \
    --security-groups sg-068f739363example
```
輸出：  

```
{
    "OwnerId": "123456789012",
    "MountTargetId": "fsmt-f9a14450",
    "FileSystemId": "fs-c7a0456e",
    "SubnetId": "subnet-02bf4c428bexample",
    "LifeCycleState": "creating",
    "IpAddress": "10.0.1.24",
    "NetworkInterfaceId": "eni-02d542216aexample",
    "AvailabilityZoneId": "use2-az2",
    "AvailabilityZoneName": "us-east-2b",
    "VpcId": "vpc-0123456789abcdef0"
}
```
如需詳細資訊，請參閱《*Amazon Elastic File System 使用者指南*》中的[建立掛載目標](https://docs.aws.amazon.com/efs/latest/ug/accessing-fs.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateMountTarget](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/create-mount-target.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：建立檔案系統的新掛載目標。指定的子網路將用於判斷將在其中建立掛載目標的虛擬私有雲端 (VPC)，以及將自動指派的 IP 位址 (來自子網路的位址範圍)。指派的 IP 位址可用於在 Amazon EC2 執行個體上掛載此檔案系統。由於未指定安全群組，為目標建立的網路介面會與子網路 VPC 的預設安全群組相關聯。**  

```
New-EFSMountTarget -FileSystemId fs-1a2b3c4d -SubnetId subnet-1a2b3c4d
```
**輸出：**  

```
FileSystemId       : fs-1a2b3c4d
IpAddress          : 10.0.0.131
LifeCycleState     : creating
MountTargetId      : fsmt-1a2b3c4d
NetworkInterfaceId : eni-1a2b3c4d
OwnerId            : 123456789012
SubnetId           : subnet-1a2b3c4d
```
**範例 2：為具有自動指派 IP 位址的指定檔案系統，建立新的掛載目標。將掛載目標建立的網路介面，與指定的安全群組相關聯 (最多可指定 5 個，格式為 "sg-xxxxxxxx")**。  

```
New-EFSMountTarget -FileSystemId fs-1a2b3c4d -SubnetId subnet-1a2b3c4d -SecurityGroup sg-group1,sg-group2,sg-group3
```
**範例 3：為具有指定 IP 位址的指定檔案系統，建立新的掛載目標。**  

```
New-EFSMountTarget -FileSystemId fs-1a2b3c4d -SubnetId subnet-1a2b3c4d -IpAddress 10.0.0.131
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [CreateMountTarget](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：建立檔案系統的新掛載目標。指定的子網路將用於判斷將在其中建立掛載目標的虛擬私有雲端 (VPC)，以及將自動指派的 IP 位址 (來自子網路的位址範圍)。指派的 IP 位址可用於在 Amazon EC2 執行個體上掛載此檔案系統。由於未指定安全群組，為目標建立的網路介面會與子網路 VPC 的預設安全群組相關聯。**  

```
New-EFSMountTarget -FileSystemId fs-1a2b3c4d -SubnetId subnet-1a2b3c4d
```
**輸出：**  

```
FileSystemId       : fs-1a2b3c4d
IpAddress          : 10.0.0.131
LifeCycleState     : creating
MountTargetId      : fsmt-1a2b3c4d
NetworkInterfaceId : eni-1a2b3c4d
OwnerId            : 123456789012
SubnetId           : subnet-1a2b3c4d
```
**範例 2：為具有自動指派 IP 位址的指定檔案系統，建立新的掛載目標。將掛載目標建立的網路介面，與指定的安全群組相關聯 (最多可指定 5 個，格式為 "sg-xxxxxxxx")**。  

```
New-EFSMountTarget -FileSystemId fs-1a2b3c4d -SubnetId subnet-1a2b3c4d -SecurityGroup sg-group1,sg-group2,sg-group3
```
**範例 3：為具有指定 IP 位址的指定檔案系統，建立新的掛載目標。**  

```
New-EFSMountTarget -FileSystemId fs-1a2b3c4d -SubnetId subnet-1a2b3c4d -IpAddress 10.0.0.131
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [CreateMountTarget](https://docs.aws.amazon.com/powershell/v5/reference)。

------

# 搭配使用 `DeleteFileSystem` 與 CLI
<a name="efs_example_efs_DeleteFileSystem_section"></a>

下列程式碼範例示範如何使用 `DeleteFileSystem`。

------
#### [ CLI ]

**AWS CLI**  
**刪除檔案系統**  
以下 `delete-file-system` 範例會刪除指定的檔案系統。  

```
aws efs delete-file-system \
    --file-system-id fs-c7a0456e
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《Amazon Elastic File System 使用者指南》**中的[刪除 Amazon EFS 檔案系統](https://docs.aws.amazon.com/efs/latest/ug/delete-efs-fs.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteFileSystem](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/delete-file-system.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：刪除不再使用的指定檔案系統 (如果檔案系統具有掛載目標，必須先將其移除)。在 Cmdlet 繼續進行之前，系統會提示您確認 - 若要隱藏確認，請使用 `-Force` 切換變數。**  

```
Remove-EFSFileSystem -FileSystemId fs-1a2b3c4d
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [DeleteFileSystem](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：刪除不再使用的指定檔案系統 (如果檔案系統具有掛載目標，必須先將其移除)。在 Cmdlet 繼續進行之前，系統會提示您確認 - 若要隱藏確認，請使用 `-Force` 切換變數。**  

```
Remove-EFSFileSystem -FileSystemId fs-1a2b3c4d
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [DeleteFileSystem](https://docs.aws.amazon.com/powershell/v5/reference)。

------

# 搭配使用 `DeleteMountTarget` 與 CLI
<a name="efs_example_efs_DeleteMountTarget_section"></a>

下列程式碼範例示範如何使用 `DeleteMountTarget`。

------
#### [ CLI ]

**AWS CLI**  
**刪除掛載目標**  
以下 `delete-mount-target` 範例會刪除指定的掛載目標。  

```
aws efs delete-mount-target \
    --mount-target-id fsmt-f9a14450
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon Elastic File System 使用者指南*》中的[建立掛載目標](https://docs.aws.amazon.com/efs/latest/ug/accessing-fs.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteMountTarget](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/delete-mount-target.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：刪除指定的掛載目標。在繼續操作之前，系統會提示您確認。若要隱藏提示，請使用 `-Force` 切換變數。請注意，此操作會透過目標強制中斷檔案系統的任何掛載 - 如果可行，您可能需要考慮在執行此命令之前卸載檔案系統。**  

```
Remove-EFSMountTarget -MountTargetId fsmt-1a2b3c4d
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [DeleteMountTarget](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：刪除指定的掛載目標。在繼續操作之前，系統會提示您確認。若要隱藏提示，請使用 `-Force` 切換變數。請注意，此操作會透過目標強制中斷檔案系統的任何掛載 - 如果可行，您可能需要考慮在執行此命令之前卸載檔案系統。**  

```
Remove-EFSMountTarget -MountTargetId fsmt-1a2b3c4d
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [DeleteMountTarget](https://docs.aws.amazon.com/powershell/v5/reference)。

------

# 搭配使用 `DescribeFileSystems` 與 CLI
<a name="efs_example_efs_DescribeFileSystems_section"></a>

下列程式碼範例示範如何使用 `DescribeFileSystems`。

------
#### [ CLI ]

**AWS CLI**  
**設定檔案系統**  
下列 `describe-file-systems` 範例會描述指定的檔案系統。  

```
aws efs describe-file-systems \
    --file-system-id fs-c7a0456e
```
輸出：  

```
{
    "FileSystems": [
        {
            "OwnerId": "123456789012",
            "CreationToken": "console-d7f56c5f-e433-41ca-8307-9d9c0example",
            "FileSystemId": "fs-c7a0456e",
            "FileSystemArn": "arn:aws:elasticfilesystem:us-west-2:123456789012:file-system/fs-48499b4d",
            "CreationTime": 1595286880.0,
            "LifeCycleState": "available",
            "Name": "my-file-system",
            "NumberOfMountTargets": 3,
            "SizeInBytes": {
                "Value": 6144,
                "Timestamp": 1600991437.0,
                "ValueInIA": 0,
                "ValueInStandard": 6144
            },
            "PerformanceMode": "generalPurpose",
            "Encrypted": true,
            "KmsKeyId": "arn:aws:kms:us-west-2:123456789012:key/a59b3472-e62c-42e4-adcf-30d92example",
            "ThroughputMode": "bursting",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "my-file-system"
                }
            ]
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon Elastic File System 使用者指南*》中的[管理 Amazon EFS 檔案系統](https://docs.aws.amazon.com/efs/latest/ug/managing.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeFileSystems](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/describe-file-systems.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：傳回區域中呼叫者帳戶擁有的所有檔案系統的集合。**  

```
Get-EFSFileSystem
```
**輸出：**  

```
CreationTime         : 5/26/2015 4:02:38 PM
CreationToken        : 1a2bff54-85e0-4747-bd95-7bc172c4f555
FileSystemId         : fs-1a2b3c4d
LifeCycleState       : available
Name                 :
NumberOfMountTargets : 0
OwnerId              : 123456789012
SizeInBytes          : Amazon.ElasticFileSystem.Model.FileSystemSize

CreationTime         : 5/26/2015 4:06:23 PM
CreationToken        : 2b4daa14-85e0-4747-bd95-7bc172c4f555
FileSystemId         : fs-4d3c2b1a
...
```
**範例 2：傳回指定檔案系統的詳細資訊。**  

```
Get-EFSFileSystem -FileSystemId fs-1a2b3c4d
```
**範例 3：使用建立檔案系統時指定的冪等性建立字符，傳回檔案系統的詳細資訊。**  

```
Get-EFSFileSystem -CreationToken 1a2bff54-85e0-4747-bd95-7bc172c4f555
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [DescribeFileSystems](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：傳回區域中呼叫者帳戶擁有的所有檔案系統的集合。**  

```
Get-EFSFileSystem
```
**輸出：**  

```
CreationTime         : 5/26/2015 4:02:38 PM
CreationToken        : 1a2bff54-85e0-4747-bd95-7bc172c4f555
FileSystemId         : fs-1a2b3c4d
LifeCycleState       : available
Name                 :
NumberOfMountTargets : 0
OwnerId              : 123456789012
SizeInBytes          : Amazon.ElasticFileSystem.Model.FileSystemSize

CreationTime         : 5/26/2015 4:06:23 PM
CreationToken        : 2b4daa14-85e0-4747-bd95-7bc172c4f555
FileSystemId         : fs-4d3c2b1a
...
```
**範例 2：傳回指定檔案系統的詳細資訊。**  

```
Get-EFSFileSystem -FileSystemId fs-1a2b3c4d
```
**範例 3：使用建立檔案系統時指定的冪等性建立字符，傳回檔案系統的詳細資訊。**  

```
Get-EFSFileSystem -CreationToken 1a2bff54-85e0-4747-bd95-7bc172c4f555
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [DescribeFileSystems](https://docs.aws.amazon.com/powershell/v5/reference)。

------

# 搭配使用 `DescribeMountTargets` 與 CLI
<a name="efs_example_efs_DescribeMountTargets_section"></a>

下列程式碼範例示範如何使用 `DescribeMountTargets`。

------
#### [ CLI ]

**AWS CLI**  
**描述掛載目標**  
下列 `describe-mount-targets` 範例會描述指定的掛載目標。  

```
aws efs describe-mount-targets \
    --mount-target-id fsmt-f9a14450
```
輸出：  

```
{
    "MountTargets": [
        {
            "OwnerId": "123456789012",
            "MountTargetId": "fsmt-f9a14450",
            "FileSystemId": "fs-c7a0456e",
            "SubnetId": "subnet-02bf4c428bexample",
            "LifeCycleState": "creating",
            "IpAddress": "10.0.1.24",
            "NetworkInterfaceId": "eni-02d542216aexample",
            "AvailabilityZoneId": "use2-az2",
            "AvailabilityZoneName": "us-east-2b",
            "VpcId": "vpc-0123456789abcdef0"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon Elastic File System 使用者指南*》中的[建立掛載目標](https://docs.aws.amazon.com/efs/latest/ug/accessing-fs.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeMountTargets](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/describe-mount-targets.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：傳回與指定檔案系統相關聯的掛載目標集合。**  

```
Get-EFSMountTarget -FileSystemId fs-1a2b3c4d
```
**輸出：**  

```
FileSystemId       : fs-1a2b3c4d
IpAddress          : 10.0.0.131
LifeCycleState     : available
MountTargetId      : fsmt-1a2b3c4d
NetworkInterfaceId : eni-1a2b3c4d
OwnerId            : 123456789012
SubnetId           : subnet-1a2b3c4d
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [DescribeMountTargets](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：傳回與指定檔案系統相關聯的掛載目標集合。**  

```
Get-EFSMountTarget -FileSystemId fs-1a2b3c4d
```
**輸出：**  

```
FileSystemId       : fs-1a2b3c4d
IpAddress          : 10.0.0.131
LifeCycleState     : available
MountTargetId      : fsmt-1a2b3c4d
NetworkInterfaceId : eni-1a2b3c4d
OwnerId            : 123456789012
SubnetId           : subnet-1a2b3c4d
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [DescribeMountTargets](https://docs.aws.amazon.com/powershell/v5/reference)。

------

# 搭配使用 `DescribeTags` 與 CLI
<a name="efs_example_efs_DescribeTags_section"></a>

下列程式碼範例示範如何使用 `DescribeTags`。

------
#### [ CLI ]

**AWS CLI**  
**描述檔案系統的標籤**  
下列 `describe-tags` 範例描述指定的檔案系統標籤。  

```
aws efs describe-tags \
    --file-system-id fs-c7a0456e
```
輸出：  

```
{
    "Tags": [
        {
            "Key": "Name",
            "Value": "my-file-system"
        },
        {
            "Key": "Department",
            "Value": "Business Intelligence"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon Elastic File System 使用者指南*》中的[管理檔案系統標籤](https://docs.aws.amazon.com/efs/latest/ug/manage-fs-tags.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeTags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/describe-tags.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：傳回目前與指定檔案系統相關聯的標籤集合。**  

```
Get-EFSTag -FileSystemId fs-1a2b3c4d
```
**輸出：**  

```
Key         Value
---         -----
Name        My File System
tagkey1     tagvalue1
tagkey2     tagvalue2
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [DescribeTags](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：傳回目前與指定檔案系統相關聯的標籤集合。**  

```
Get-EFSTag -FileSystemId fs-1a2b3c4d
```
**輸出：**  

```
Key         Value
---         -----
Name        My File System
tagkey1     tagvalue1
tagkey2     tagvalue2
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [DescribeTags](https://docs.aws.amazon.com/powershell/v5/reference)。

------