

# AWS CLI를 사용한 Amazon EFS 예제
<a name="cli_efs_code_examples"></a>

다음 코드 예제에서는 Amazon EFS에서 AWS Command Line Interface를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여 줍니다.

*작업*은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

**Topics**
+ [작업](#actions)

## 작업
<a name="actions"></a>

### `create-file-system`
<a name="efs_CreateFileSystem_cli_topic"></a>

다음 코드 예시는 `create-file-system`의 사용 방법을 보여줍니다.

**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 사용 설명서*에서 [Creating Amazon EFS file systems](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)을 참조하세요.

### `create-mount-target`
<a name="efs_CreateMountTarget_cli_topic"></a>

다음 코드 예시는 `create-mount-target`의 사용 방법을 보여줍니다.

**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 사용 설명서*의 [Creating mount targets](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)을 참조하세요.

### `delete-file-system`
<a name="efs_DeleteFileSystem_cli_topic"></a>

다음 코드 예시는 `delete-file-system`의 사용 방법을 보여줍니다.

**AWS CLI**  
**파일 시스템을 삭제하는 방법**  
다음 `delete-file-system` 예제에서는 지정된 파일 시스템을 삭제합니다.  

```
aws efs delete-file-system \
    --file-system-id fs-c7a0456e
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *Amazon Elastic File System 사용 설명서*의 [Deleting an Amazon EFS file system](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)을 참조하세요.

### `delete-mount-target`
<a name="efs_DeleteMountTarget_cli_topic"></a>

다음 코드 예시는 `delete-mount-target`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탑재 대상을 삭제하는 방법**  
다음 `delete-mount-target` 예제에서는 지정된 탑재 대상을 삭제합니다.  

```
aws efs delete-mount-target \
    --mount-target-id fsmt-f9a14450
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *Amazon Elastic File System 사용 설명서*의 [Creating mount targets](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)을 참조하세요.

### `describe-file-systems`
<a name="efs_DescribeFileSystems_cli_topic"></a>

다음 코드 예시는 `describe-file-systems`의 사용 방법을 보여줍니다.

**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 사용 설명서*의 [Managing Amazon EFS file systems](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)를 참조하세요.

### `describe-mount-targets`
<a name="efs_DescribeMountTargets_cli_topic"></a>

다음 코드 예시는 `describe-mount-targets`의 사용 방법을 보여줍니다.

**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 사용 설명서*의 [Creating mount targets](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)를 참조하세요.

### `describe-tags`
<a name="efs_DescribeTags_cli_topic"></a>

다음 코드 예시는 `describe-tags`의 사용 방법을 보여줍니다.

**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 사용 설명서의 [Managing file system tags](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) 섹션을 참조하세요.

### `list-tags-for-resource`
<a name="efs_ListTagsForResource_cli_topic"></a>

다음 코드 예시는 `list-tags-for-resource`의 사용 방법을 보여줍니다.

**AWS CLI**  
**리소스에 대한 태그를 검색하는 방법**  
다음 `list-tags-for-resource` 예제에서는 지정된 파일 시스템과 연결된 태그를 검색합니다.  

```
aws efs list-tags-for-resource \
    --resource-id fs-c7a0456e
```
출력:  

```
{
    "Tags": [
        {
            "Key": "Name",
            "Value": "my-file-system"
        },
        {
            "Key": "Department",
            "Value": "Business Intelligence"
        }
    ]
}
```
자세한 내용은 **Amazon Elastic File System 사용 설명서의 [Managing file system tags](https://docs.aws.amazon.com/efs/latest/ug/manage-fs-tags.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/list-tags-for-resource.html)를 참조하세요.

### `tag-resource`
<a name="efs_TagResource_cli_topic"></a>

다음 코드 예시에서는 `tag-resource`의 사용 방법을 보여줍니다.

**AWS CLI**  
**리소스에 태그를 지정하려면**  
다음 `tag-resource` 예제에서는 지정된 파일 시스템에 `Department=Business Intelligence` 태그를 추가합니다.  

```
aws efs tag-resource \
    --resource-id fs-c7a0456e \
    --tags Key=Department,Value="Business Intelligence"
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 **Amazon Elastic File System 사용 설명서의 [Managing file system tags](https://docs.aws.amazon.com/efs/latest/ug/manage-fs-tags.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/tag-resource.html)를 참조하세요.

### `untag-resource`
<a name="efs_UntagResource_cli_topic"></a>

다음 코드 예시에서는 `untag-resource`의 사용 방법을 보여줍니다.

**AWS CLI**  
**리소스에서 태그를 제거하는 방법**  
다음 `untag-resource` 예제에서는 지정된 파일 시스템에서 `Department` 태그 키가 있는 태그를 제거합니다.  

```
aws efs untag-resource \
    --resource-id fs-c7a0456e \
    --tag-keys Department
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 **Amazon Elastic File System 사용 설명서의 [Managing file system tags](https://docs.aws.amazon.com/efs/latest/ug/manage-fs-tags.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/efs/untag-resource.html)를 참조하세요.