

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

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

# 使用 的 Lake Formation 範例 AWS CLI
<a name="cli_2_lakeformation_code_examples"></a>

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 Lake Formation 執行動作和實作常見案例。

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

每個範例均包含完整原始碼的連結，您可在連結中找到如何設定和執行內容中程式碼的相關指示。

**Topics**
+ [動作](#actions)

## 動作
<a name="actions"></a>

### `add-lf-tags-to-resource`
<a name="lakeformation_AddLfTagsToResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `add-lf-tags-to-resource`。

**AWS CLI**  
**將一或多個 LF 標籤連接至現有資源**  
下列 `add-lf-tags-to-resource` 範例會將指定的 LF 標籤連接至資料表資源。  

```
aws lakeformation add-lf-tags-to-resource \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Resource": {
        "Table": {
            "CatalogId": "123456789111",
            "DatabaseName": "tpc",
            "Name": "dl_tpc_promotion"
        }
    },
    "LFTags": [{
        "CatalogId": "123456789111",
        "TagKey": "usergroup",
        "TagValues": [
            "analyst"
        ]
    }]
}
```
輸出：  

```
{
    "Failures": []
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[將 LF 標籤指派給 Data Catalog 資源](https://docs.aws.amazon.com/lake-formation/latest/dg/TBAC-assigning-tags.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [AddLfTagsToResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/add-lf-tags-to-resource.html)。

### `batch-grant-permissions`
<a name="lakeformation_BatchGrantPermissions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-grant-permissions`。

**AWS CLI**  
**將資源上將許可權大量授予主體**  
下列 `batch-grant-permissions` 範例大量將指定資源的存取權授予主體。  

```
aws lakeformation batch-grant-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Entries": [{
            "Id": "1",
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-developer"
            },
            "Resource": {
                "Table": {
                    "CatalogId": "123456789111",
                    "DatabaseName": "tpc",
                    "Name": "dl_tpc_promotion"
                }
            },
            "Permissions": [
                "ALL"
            ],
            "PermissionsWithGrantOption": [
                "ALL"
            ]
        },
        {
            "Id": "2",
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-developer"
            },
            "Resource": {
                "Table": {
                    "CatalogId": "123456789111",
                    "DatabaseName": "tpc",
                    "Name": "dl_tpc_customer"
                }
            },
            "Permissions": [
                "ALL"
            ],
            "PermissionsWithGrantOption": [
                "ALL"
            ]
        },
        {
            "Id": "3",
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-business-analyst"
            },
            "Resource": {
                "Table": {
                    "CatalogId": "123456789111",
                    "DatabaseName": "tpc",
                    "Name": "dl_tpc_promotion"
                }
            },
            "Permissions": [
                "ALL"
            ],
            "PermissionsWithGrantOption": [
                "ALL"
            ]
        },
        {
            "Id": "4",
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-developer"
            },
            "Resource": {
                "DataCellsFilter": {
                    "TableCatalogId": "123456789111",
                    "DatabaseName": "tpc",
                    "TableName": "dl_tpc_item",
                    "Name": "developer_item"
                }
            },
            "Permissions": [
                "SELECT"
            ],
            "PermissionsWithGrantOption": []
        }
    ]
}
```
輸出：  

```
{
    "Failures": []
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[授予和撤銷 Data Catalog 資源的許可](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [BatchGrantPermissions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/batch-grant-permissions.html)。

### `batch-revoke-permissions`
<a name="lakeformation_BatchRevokePermissions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-revoke-permissions`。

**AWS CLI**  
**從主體大量撤銷資源的許可**  
下列 `batch-revoke-permissions` 範例大量撤銷主體對指定資源的存取權。  

```
aws lakeformation batch-revoke-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Entries": [{
            "Id": "1",
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-developer"
            },
            "Resource": {
                "Table": {
                    "CatalogId": "123456789111",
                    "DatabaseName": "tpc",
                    "Name": "dl_tpc_promotion"
                }
            },
            "Permissions": [
                "ALL"
            ],
            "PermissionsWithGrantOption": [
                "ALL"
            ]
        },
        {
            "Id": "2",
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-business-analyst"
            },
            "Resource": {
                "Table": {
                    "CatalogId": "123456789111",
                    "DatabaseName": "tpc",
                    "Name": "dl_tpc_promotion"
                }
            },
            "Permissions": [
                "ALL"
            ],
            "PermissionsWithGrantOption": [
                "ALL"
            ]
        }
    ]
}
```
輸出：  

```
{
    "Failures": []
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[授予和撤銷 Data Catalog 資源的許可](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [BatchRevokePermissions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/batch-revoke-permissions.html)。

### `cancel-transaction`
<a name="lakeformation_CancelTransaction_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `cancel-transaction`。

**AWS CLI**  
**取消交易**  
下列 `cancel-transaction` 範例會取消交易。  

```
aws lakeformation cancel-transaction \
    --transaction-id='b014d972ca8347b89825e33c5774aec4'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CancelTransaction](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/cancel-transaction.html)。

### `commit-transaction`
<a name="lakeformation_CommitTransaction_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `commit-transaction`。

**AWS CLI**  
**遞交交易**  
下列 `commit-transaction` 範例會遞交交易。  

```
aws lakeformation commit-transaction \
    --transaction-id='b014d972ca8347b89825e33c5774aec4'
```
輸出：  

```
{
    "TransactionStatus": "committed"
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CommitTransaction](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/commit-transaction.html)。

### `create-data-cells-filter`
<a name="lakeformation_CreateDataCellsFilter_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-data-cells-filter`。

**AWS CLI**  
**範例 1：建立資料儲存格篩選條件**  
下列 `create-data-cells-filter` 範例會建立資料儲存格篩選條件，以允許根據資料列條件，授予特定資料欄的存取權。  

```
aws lakeformation create-data-cells-filter \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "TableData": {
        "ColumnNames": ["p_channel_details", "p_start_date_sk", "p_promo_name"],
        "DatabaseName": "tpc",
        "Name": "developer_promotion",
        "RowFilter": {
            "FilterExpression": "p_promo_name='ese'"
        },
        "TableCatalogId": "123456789111",
        "TableName": "dl_tpc_promotion"
    }
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的 [Lake Formation 中的資料篩選與儲存格層級安全性](https://docs.aws.amazon.com/lake-formation/latest/dg/data-filtering.html)。  
**範例 2：建立資料欄篩選條件**  
下列 `create-data-cells-filter` 範例會建立資料篩選條件，以允許其授予特定資料欄的存取權。  

```
aws lakeformation create-data-cells-filter \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "TableData": {
        "ColumnNames": ["p_channel_details", "p_start_date_sk", "p_promo_name"],
        "DatabaseName": "tpc",
        "Name": "developer_promotion_allrows",
        "RowFilter": {
            "AllRowsWildcard": {}
        },
        "TableCatalogId": "123456789111",
        "TableName": "dl_tpc_promotion"
    }
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的 [Lake Formation 中的資料篩選與儲存格層級安全性](https://docs.aws.amazon.com/lake-formation/latest/dg/data-filtering.html)。  
**範例 3：使用排除資料欄建立資料篩選條件**  
下列 `create-data-cells-filter` 範例會建立資料篩選條件，以允許其授予上述資料欄以外的所有存取權。  

```
aws lakeformation create-data-cells-filter \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "TableData": {
        "ColumnWildcard": {
            "ExcludedColumnNames": ["p_channel_details", "p_start_date_sk"]
        },
        "DatabaseName": "tpc",
        "Name": "developer_promotion_excludecolumn",
        "RowFilter": {
            "AllRowsWildcard": {}
        },
        "TableCatalogId": "123456789111",
        "TableName": "dl_tpc_promotion"
    }
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的 [Lake Formation 中的資料篩選與儲存格層級安全性](https://docs.aws.amazon.com/lake-formation/latest/dg/data-filtering.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateDataCellsFilter](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/create-data-cells-filter.html)。

### `create-lf-tag`
<a name="lakeformation_CreateLfTag_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-lf-tag`。

**AWS CLI**  
**建立 LF 標籤**  
下列 `create-lf-tag` 範例會建立具有指定名稱和值的 LF 標籤。  

```
aws lakeformation create-lf-tag \
    --catalog-id '123456789111' \
    --tag-key 'usergroup' \
    --tag-values '["developer","analyst","campaign"]'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[管理用於中繼資料存取控制的 LF 標籤](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-tags.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateLfTag](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/create-lf-tag.html)。

### `delete-data-cells-filter`
<a name="lakeformation_DeleteDataCellsFilter_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-data-cells-filter`。

**AWS CLI**  
**刪除資料儲存格篩選條件**  
下列 `delete-data-cells-filter` 範例會刪除指定的資料儲存格篩選條件。  

```
aws lakeformation delete-data-cells-filter \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "TableCatalogId": "123456789111",
    "DatabaseName": "tpc",
    "TableName": "dl_tpc_promotion",
    "Name": "developer_promotion"
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的 [Lake Formation 中的資料篩選與儲存格層級安全性](https://docs.aws.amazon.com/lake-formation/latest/dg/data-filtering.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteDataCellsFilter](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/delete-data-cells-filter.html)。

### `delete-lf-tag`
<a name="lakeformation_DeleteLfTag_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-lf-tag`。

**AWS CLI**  
**刪除 LF 標籤定義**  
下列 `delete-lf-tag` 範例會刪除 LF-Tag 定義。  

```
aws lakeformation delete-lf-tag \
    --catalog-id '123456789111' \
    --tag-key 'usergroup'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[管理用於中繼資料存取控制的 LF 標籤](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-tags.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteLfTag](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/delete-lf-tag.html)。

### `delete-objects-on-cancel`
<a name="lakeformation_DeleteObjectsOnCancel_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-objects-on-cancel`。

**AWS CLI**  
**在交易取消時刪除物件**  
下列 `delete-objects-on-cancel` 範例會在交易取消時刪除列出的 S3 物件。  

```
aws lakeformation delete-objects-on-cancel \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "012345678901",
    "DatabaseName": "tpc",
    "TableName": "dl_tpc_household_demographics_gov",
    "TransactionId": "1234d972ca8347b89825e33c5774aec4",
    "Objects": [{
        "Uri": "s3://lf-data-lake-012345678901/target/dl_tpc_household_demographics_gov/run-unnamed-1-part-block-0-r-00000-snappy-ff26b17504414fe88b302cd795eabd00.parquet",
        "ETag": "1234ab1fc50a316b149b4e1f21a73800"
    }]
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteObjectsOnCancel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/delete-objects-on-cancel.html)。

### `deregister-resource`
<a name="lakeformation_DeregisterResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `deregister-resource`。

**AWS CLI**  
**取消註冊資料湖儲存**  
下列 `deregister-resource` 範例會取消註冊由 Lake Formation 管理的資源。  

```
aws lakeformation deregister-resource \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "ResourceArn": "arn:aws:s3:::lf-emr-athena-result-123"
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[將 Amazon S3 位置新增至您的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/register-data-lake.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeregisterResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/deregister-resource.html)。

### `describe-transaction`
<a name="lakeformation_DescribeTransaction_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-transaction`。

**AWS CLI**  
**擷取交易詳細資訊**  
下列 `describe-transaction` 範例會傳回單一交易的詳細資訊。  

```
aws lakeformation describe-transaction \
    --transaction-id='8cb4b1a7cc8d486fbaca9a64e7d9f5ce'
```
輸出：  

```
{
    "TransactionDescription": {
        "TransactionId": "12345972ca8347b89825e33c5774aec4",
        "TransactionStatus": "committed",
        "TransactionStartTime": "2022-08-10T14:29:04.046000+00:00",
        "TransactionEndTime": "2022-08-10T14:29:09.681000+00:00"
    }
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeTransaction](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/describe-transaction.html)。

### `extend-transaction`
<a name="lakeformation_ExtendTransaction_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `extend-transaction`。

**AWS CLI**  
**擴展交易**  
下列 `extend-transaction` 範例會擴展交易。  

```
aws lakeformation extend-transaction \
    --transaction-id='8cb4b1a7cc8d486fbaca9a64e7d9f5ce'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [ExtendTransaction](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/extend-transaction.html)。

### `get-data-lake-settings`
<a name="lakeformation_GetDataLakeSettings_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-data-lake-settings`。

**AWS CLI**  
**擷取 AWS Lake Formation 管理的資料湖設定**  
下列 `get-data-lake-settings` 範例會擷取資料湖管理員和其他資料湖設定的清單。  

```
aws lakeformation get-data-lake-settings \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111"
}
```
輸出：  

```
{
    "DataLakeSettings": {
        "DataLakeAdmins": [{
            "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-admin"
        }],
        "CreateDatabaseDefaultPermissions": [],
        "CreateTableDefaultPermissions": [
                {
                        "Principal": {
                            "DataLakePrincipalIdentifier": "IAM_ALLOWED_PRINCIPALS"
                        },
                        "Permissions": [
                            "ALL"
                        ]
                }
        ],
        "TrustedResourceOwners": [],
        "AllowExternalDataFiltering": true,
        "ExternalDataFilteringAllowList": [{
            "DataLakePrincipalIdentifier": "123456789111"
        }],
        "AuthorizedSessionTagValueList": [
            "Amazon EMR"
        ]
    }
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[變更資料湖的預設安全設定](https://docs.aws.amazon.com/lake-formation/latest/dg/change-settings.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetDataLakeSettings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/get-data-lake-settings.html)。

### `get-effective-permissions-for-path`
<a name="lakeformation_GetEffectivePermissionsForPath_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-effective-permissions-for-path`。

**AWS CLI**  
**擷取位於特定路徑之資源的許可權**  
下列 `get-effective-permissions-for-path` 範例會傳回位於 Amazon S3 路徑之指定資料表或資料庫資源的 Lake Formation 許可權。  

```
aws lakeformation get-effective-permissions-for-path \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "ResourceArn": "arn:aws:s3:::lf-data-lake-123456789111"
}
```
輸出：  

```
{
    "Permissions": [{
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-campaign-manager"
            },
            "Resource": {
                "Database": {
                    "Name": "tpc"
                }
            },
            "Permissions": [
                "DESCRIBE"
            ],
            "PermissionsWithGrantOption": []
        },
        {
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:role/EMR-RuntimeRole"
            },
            "Resource": {
                "Database": {
                    "Name": "tpc"
                }
            },
            "Permissions": [
                "ALL"
            ],
            "PermissionsWithGrantOption": []
        },
        {
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:saml-provider/oktaSAMLProvider:user/emr-developer"
            },
            "Resource": {
                "Database": {
                    "Name": "tpc"
                }
            },
            "Permissions": [
                "ALL",
                "DESCRIBE"
            ],
            "PermissionsWithGrantOption": []
        },
        {
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-admin"
            },
            "Resource": {
                "Database": {
                    "Name": "tpc"
                }
            },
            "Permissions": [
                "ALL",
                "ALTER",
                "CREATE_TABLE",
                "DESCRIBE",
                "DROP"
            ],
            "PermissionsWithGrantOption": [
                "ALL",
                "ALTER",
                "CREATE_TABLE",
                "DESCRIBE",
                "DROP"
            ]
        },
        {
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:role/LF-GlueServiceRole"
            },
            "Resource": {
                "Database": {
                    "Name": "tpc"
                }
            },
            "Permissions": [
                "CREATE_TABLE"
            ],
            "PermissionsWithGrantOption": []
        }
    ],
    "NextToken": "E5SlJDSTZleUp6SWpvaU9UQTNORE0zTXpFeE5Ua3pJbjE5TENKbGVIQnBjbUYwYVc5dUlqcDdJbk5sWTI5dVpITWlPakUyTm=="
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[管理 Lake Formation 許可權](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-permissions.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetEffectivePermissionsForPath](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/get-effective-permissions-for-path.html)。

### `get-lf-tag`
<a name="lakeformation_GetLfTag_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-lf-tag`。

**AWS CLI**  
**擷取 LF 標籤定義**  
下列 `get-lf-tag` 範例會擷取 LF 標籤定義。  

```
aws lakeformation get-lf-tag \
    --catalog-id '123456789111' \
    --tag-key 'usergroup'
```
輸出：  

```
{
    "CatalogId": "123456789111",
    "TagKey": "usergroup",
    "TagValues": [
        "analyst",
        "campaign",
        "developer"
    ]
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[管理用於中繼資料存取控制的 LF 標籤](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-tags.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetLfTag](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/get-lf-tag.html)。

### `get-query-state`
<a name="lakeformation_GetQueryState_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-query-state`。

**AWS CLI**  
**擷取已提交查詢的狀態**  
下列 `get-query-state` 範例會傳回先前提交的查詢狀態。  

```
aws lakeformation get-query-state \
    --query-id='1234273f-4a62-4cda-8d98-69615ee8be9b'
```
輸出：  

```
{
    "State": "FINISHED"
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[交易資料操作](https://docs.aws.amazon.com/lake-formation/latest/dg/transactions-data-operations.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetQueryState](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/get-query-state.html)。

### `get-query-statistics`
<a name="lakeformation_GetQueryStatistics_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-query-statistics`。

**AWS CLI**  
**擷取查詢統計資料**  
下列 `get-query-statistics` 範例會擷取查詢規劃和執行的統計資料。  

```
aws lakeformation get-query-statistics \
    --query-id='1234273f-4a62-4cda-8d98-69615ee8be9b'
```
輸出：  

```
{
    "ExecutionStatistics": {
        "AverageExecutionTimeMillis": 0,
        "DataScannedBytes": 0,
        "WorkUnitsExecutedCount": 0
    },
    "PlanningStatistics": {
        "EstimatedDataToScanBytes": 43235,
        "PlanningTimeMillis": 2377,
        "QueueTimeMillis": 440,
        "WorkUnitsGeneratedCount": 1
    },
    "QuerySubmissionTime": "2022-08-11T02:14:38.641870+00:00"
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[交易資料操作](https://docs.aws.amazon.com/lake-formation/latest/dg/transactions-data-operations.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetQueryStatistics](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/get-query-statistics.html)。

### `get-resource-lf-tags`
<a name="lakeformation_GetResourceLfTags_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-resource-lf-tags`。

**AWS CLI**  
**列出 LF 標籤**  
下列 `list-lf-tags` 範例會傳回請求者有權檢視的 LF 標籤清單。  

```
aws lakeformation list-lf-tags \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "ResourceShareType": "ALL",
    "MaxResults": 2
}
```
輸出：  

```
{
"LFTags": [{
        "CatalogId": "123456789111",
        "TagKey": "category",
        "TagValues": [
            "private",
            "public"
        ]
    },
    {
        "CatalogId": "123456789111",
        "TagKey": "group",
        "TagValues": [
            "analyst",
            "campaign",
            "developer"
        ]
    }],
    "NextToken": "kIiwiZXhwaXJhdGlvbiI6eyJzZWNvbmRzIjoxNjYwMDY4dCI6ZmFsc2V9"
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[管理用於中繼資料存取控制的 LF 標籤](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-tags.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetResourceLfTags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/get-resource-lf-tags.html)。

### `get-table-objects`
<a name="lakeformation_GetTableObjects_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-table-objects`。

**AWS CLI**  
**列出管控資料表的物件**  
下列 `get-table-objects` 範例會傳回組成指定之管控資料表的一組 Amazon S3 物件。  

```
aws lakeformation get-table-objects \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "012345678901",
    "DatabaseName": "tpc",
    "TableName": "dl_tpc_household_demographics_gov",
    "QueryAsOfTime": "2022-08-10T15:00:00"
}
```
輸出：  

```
{
    "Objects": [{
        "PartitionValues": [],
        "Objects": [{
            "Uri": "s3://lf-data-lake-012345678901/target/dl_tpc_household_demographics_gov/run-unnamed-1-part-block-0-r-00000-snappy-ff26b17504414fe88b302cd795eabd00.parquet",
            "ETag": "12345b1fc50a316b149b4e1f21a73800",
            "Size": 43235
        }]
    }]
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetTableObjects](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/get-table-objects.html)。

### `get-work-unit-results`
<a name="lakeformation_GetWorkUnitResults_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-work-unit-results`。

**AWS CLI**  
**擷取給定查詢的工作單位**  
下列 `get-work-unit-results` 範例會傳回查詢所產生的工作單位。  

```
aws lakeformation get-work-units \
    --query-id='1234273f-4a62-4cda-8d98-69615ee8be9b' \
    --work-unit-id '0' \
    --work-unit-token 'B2fMSdmQXe9umX8Ux8XCo4=' outfile
```
輸出：  

```
outfile with Blob content.
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[交易資料操作](https://docs.aws.amazon.com/lake-formation/latest/dg/transactions-data-operations.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetWorkUnitResults](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/get-work-unit-results.html)。

### `get-work-units`
<a name="lakeformation_GetWorkUnits_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-work-units`。

**AWS CLI**  
**擷取工作單位**  
下列 `get-work-units` 範例會擷取 StartQueryPlanning 操作所產生的工作單位。  

```
aws lakeformation get-work-units \
    --query-id='1234273f-4a62-4cda-8d98-69615ee8be9b'
```
輸出：  

```
{
    "WorkUnitRanges": [{
        "WorkUnitIdMax": 0,
        "WorkUnitIdMin": 0,
        "WorkUnitToken": "1234eMAk4kLO4umqEL4Z5WuxL04AXwABABVhd3MtY3J5cHRvLXB1YmxpYy1rZXkAREEwYm9QbkhINmFYTWphbmMxZW1PQmEyMGlUb0JFbXNlWmRYc0NmckRIR1dmQ0hjY2YzNFdMcmNXb2JGZmhEK0QvZz09AAEAB2F3cy1rbXMAS2Fybjphd3M6a21zOnVzLWVhc3QtMTo3MDkxNTAyNDkyNDk6a2V5L2VmYmI3NDUyLTY1MjYtNGJiOS1iNmZhLTEzYzJkMTM3MmU2OQC4AQIBAHg6eWNF2ZrQATTAuPDJVCEAQSyIF67vX+f88jzGrYq22gE6jkQlpOB+Oet2eqNUmFudAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMCOEWRdafowek3RUmAgEQgDsYZZE84nnnbNmvsqCBPLh19nLQ10mUWOg9IfiaOwefEn6L920V0x1LpJACo7MtIBLXnbGcz2dFDZjFygIAAAAADAAAEAAAAAAAAAAAAAAAAAAQSQf8XDSI5pvR4Fx4JsrS/////wAAAAEAAAAAAAAAAAAAAAEAAACX3/w5h75QAPomfKH+cyEKYU1yccUmBl+VSojiGOtdsUk7vcjYXUUboYm3dvqRqX2s4gROMOn+Ij8R0/8jYmnHkpvyAFNVRPyETyIKg7k5Z9+5I1c2d3446Jw/moWGGxjH8AEG9h27ytmOhozxDOEi/F2ZoXz6wlGDfGUo/2WxCkYOhTyNaw6TM+7drTM7yrW4iNVLUM0LX0xnFjIAhLhooWJek6vjQZUAZzBlAjBH8okRtYP8R7AY2Wls/hqFBhG0V4l42AC0LxsuZbMQrE2SzWZUZ0E9Uew7/n0cyX4CMQDR79INyv4ysMByW9kKGGKyba+cCNklExMR+btBQBmMuB2fMSdmQXe9umX8Ux8XCo4="
    }],
    "QueryId": "1234273f-4a62-4cda-8d98-69615ee8be9b"
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[交易資料操作](https://docs.aws.amazon.com/lake-formation/latest/dg/transactions-data-operations.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetWorkUnits](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/get-work-units.html)。

### `grant-permissions`
<a name="lakeformation_GrantPermissions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `grant-permissions`。

**AWS CLI**  
**範例 1：使用 LF-Tags 將許可權授予資源上的主體**  
下列 `grant-permissions` 範例會將所有許可權授予資料庫資源上符合 LF-Tag 政策的主體。  

```
aws lakeformation grant-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Principal": {
        "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-admin"
    },
    "Resource": {
        "LFTagPolicy": {
            "CatalogId": "123456789111",
            "ResourceType": "DATABASE",
            "Expression": [{
                "TagKey": "usergroup",
                "TagValues": [
                    "analyst",
                    "developer"
                ]
            }]
        }
    },
    "Permissions": [
        "ALL"
    ],
    "PermissionsWithGrantOption": [
        "ALL"
    ]
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[授予和撤銷 Data Catalog 資源的許可](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html)。  
**範例 2：將資料欄層級許可權授予主體**  
下列 `grant-permissions` 範例會授予許可權，用以選取主體的特定資料欄。  

```
aws lakeformation grant-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Principal": {
        "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-developer"
    },
    "Resource": {
        "TableWithColumns": {
            "CatalogId": "123456789111",
            "ColumnNames": ["p_end_date_sk"],
            "DatabaseName": "tpc",
            "Name": "dl_tpc_promotion"
        }
    },
    "Permissions": [
        "SELECT"
    ],
    "PermissionsWithGrantOption": []
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[授予和撤銷 Data Catalog 資源的許可](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html)。  
**範例 3：將資料表許可權授予主體**  
下列 `grant-permissions` 範例會將給定資料庫之所有資料表的特定許可權，授予主體。  

```
aws lakeformation grant-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Principal": {
        "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-developer"
    },
    "Resource": {
        "Table": {
            "CatalogId": "123456789111",
            "DatabaseName": "tpc",
            "TableWildcard": {}
        }
    },
    "Permissions": [
        "SELECT"
    ],
    "PermissionsWithGrantOption": []
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[授予和撤銷 Data Catalog 資源的許可](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html)。  
**範例 4：將 LF 標籤的許可權授予主體**  
下列 `grant-permissions` 範例會將 LF 標籤的關聯許可權授予主體。  

```
aws lakeformation grant-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Principal": {
        "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-developer"
    },
    "Resource": {
        "LFTag": {
            "CatalogId": "123456789111",
            "TagKey": "category",
            "TagValues": [
                "private", "public"
            ]
        }

    },
    "Permissions": [
        "ASSOCIATE"
    ],
    "PermissionsWithGrantOption": []
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[授予和撤銷 Data Catalog 資源的許可](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html)。  
**範例 5：將資料位置的許可權授予主體**  
下列 `grant-permissions` 範例會將資料位置的許可權授予主體。  

```
aws lakeformation grant-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Principal": {
        "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-developer"
    },
    "Resource": {
        "DataLocation": {
            "CatalogId": "123456789111",
            "ResourceArn": "arn:aws:s3:::lf-data-lake-123456789111"
        }
    },
    "Permissions": [
        "DATA_LOCATION_ACCESS"
    ],
    "PermissionsWithGrantOption": []
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[授予和撤銷 Data Catalog 資源的許可](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [GrantPermissions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/grant-permissions.html)。

### `list-data-cells-filter`
<a name="lakeformation_ListDataCellsFilter_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-data-cells-filter`。

**AWS CLI**  
**列出資料儲存格篩選條件**  
下列 `list-data-cells-filter` 範例列出給定資料表的資料儲存格篩選條件。  

```
aws lakeformation list-data-cells-filter \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "MaxResults": 2,
    "Table": {
        "CatalogId": "123456789111",
        "DatabaseName": "tpc",
        "Name": "dl_tpc_promotion"
    }
}
```
輸出：  

```
{
    "DataCellsFilters": [{
            "TableCatalogId": "123456789111",
            "DatabaseName": "tpc",
            "TableName": "dl_tpc_promotion",
            "Name": "developer_promotion",
            "RowFilter": {
                "FilterExpression": "p_promo_name='ese'"
            },
            "ColumnNames": [
                "p_channel_details",
                "p_start_date_sk",
                "p_purpose",
                "p_promo_id",
                "p_promo_name",
                "p_end_date_sk",
                "p_discount_active"
            ]
        },
        {
            "TableCatalogId": "123456789111",
            "DatabaseName": "tpc",
            "TableName": "dl_tpc_promotion",
            "Name": "developer_promotion_allrows",
            "RowFilter": {
                "FilterExpression": "TRUE",
                "AllRowsWildcard": {}
            },
            "ColumnNames": [
                "p_channel_details",
                "p_start_date_sk",
                "p_promo_name"
            ]
        }
    ],
    "NextToken": "2MDA2MTgwNiwibmFub3MiOjE0MDAwMDAwMH19"
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的 [Lake Formation 中的資料篩選與儲存格層級安全性](https://docs.aws.amazon.com/lake-formation/latest/dg/data-filtering.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListDataCellsFilter](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/list-data-cells-filter.html)。

### `list-permissions`
<a name="lakeformation_ListPermissions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-permissions`。

**AWS CLI**  
**範例 1：擷取資源上的主體許可權清單**  
下列 `list-permissions` 範例會傳回資料庫資源上的主體許可權清單。  

```
aws lakeformation list-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "ResourceType": "DATABASE",
    "MaxResults": 2
}
```
輸出：  

```
{
    "PrincipalResourcePermissions": [{
        "Principal": {
            "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-campaign-manager"
        },
        "Resource": {
            "Database": {
                "CatalogId": "123456789111",
                "Name": "tpc"
            }
        },
        "Permissions": [
            "DESCRIBE"
        ],
        "PermissionsWithGrantOption": []
    }],
    "NextToken": "E5SlJDSTZleUp6SWpvaU9UQTNORE0zTXpFeE5Ua3pJbjE5TENKbGVIQnBjbUYwYVc5dUlqcDdJbk5sWTI5dVpITWlPakUyTm"
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[管理 Lake Formation 許可權](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-permissions.html)。  
**範例 2：使用資料篩選條件擷取資料表上的主體許可權清單**  
下列 `list-permissions` 範例會列出資料表上的許可權，並將相關資料篩選條件授予主體。  

```
aws lakeformation list-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Resource": {
        "Table": {
            "CatalogId": "123456789111",
            "DatabaseName": "tpc",
            "Name": "dl_tpc_customer"
        }
    },
    "IncludeRelated": "TRUE",
    "MaxResults": 10
}
```
輸出：  

```
{
    "PrincipalResourcePermissions": [{
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:role/Admin"
            },
            "Resource": {
                "Table": {
                    "CatalogId": "123456789111",
                    "DatabaseName": "customer",
                    "Name": "customer_invoice"
                }
            },
            "Permissions": [
                "ALL",
                "ALTER",
                "DELETE",
                "DESCRIBE",
                "DROP",
                "INSERT"
            ],
            "PermissionsWithGrantOption": [
                "ALL",
                "ALTER",
                "DELETE",
                "DESCRIBE",
                "DROP",
                "INSERT"
            ]
        },
        {
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:role/Admin"
            },
            "Resource": {
                "TableWithColumns": {
                    "CatalogId": "123456789111",
                    "DatabaseName": "customer",
                    "Name": "customer_invoice",
                    "ColumnWildcard": {}
                }
            },
            "Permissions": [
                "SELECT"
            ],
            "PermissionsWithGrantOption": [
                "SELECT"
            ]
        },
        {
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:role/Admin"
            },
            "Resource": {
                "DataCellsFilter": {
                    "TableCatalogId": "123456789111",
                    "DatabaseName": "customer",
                    "TableName": "customer_invoice",
                    "Name": "dl_us_customer"
                }
            },
            "Permissions": [
                "DESCRIBE",
                "SELECT",
                "DROP"
            ],
            "PermissionsWithGrantOption": []
        }
    ],
    "NextToken": "VyeUFjY291bnRQZXJtaXNzaW9ucyI6ZmFsc2V9"
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[管理 Lake Formation 許可權](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-permissions.html)。  
**範例 3：擷取 LF 標籤上主體許可權的清單**  
下列 `list-permissions` 範例列出授予主體的 LF 標籤許可權。  

```
aws lakeformation list-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Resource": {
        "LFTag": {
            "CatalogId": "123456789111",
            "TagKey": "category",
            "TagValues": [
                "private"
            ]
        }
    },
    "MaxResults": 10
}
```
輸出：  

```
{
    "PrincipalResourcePermissions": [{
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-admin"
            },
            "Resource": {
                "LFTag": {
                    "CatalogId": "123456789111",
                    "TagKey": "category",
                    "TagValues": [
                        "*"
                    ]
                }
            },
            "Permissions": [
                "DESCRIBE"
            ],
            "PermissionsWithGrantOption": [
                "DESCRIBE"
            ]
        },
        {
            "Principal": {
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-admin"
            },
            "Resource": {
                "LFTag": {
                    "CatalogId": "123456789111",
                    "TagKey": "category",
                    "TagValues": [
                        "*"
                    ]
                }
            },
            "Permissions": [
                "ASSOCIATE"
            ],
            "PermissionsWithGrantOption": [
                "ASSOCIATE"
            ]
        }
    ],
    "NextToken": "EJwY21GMGFXOXVJanA3SW5Ocm1pc3Npb25zIjpmYWxzZX0="
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[管理 Lake Formation 許可權](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-permissions.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListPermissions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/list-permissions.html)。

### `list-resources`
<a name="lakeformation_ListResources_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-resources`。

**AWS CLI**  
**列出 Lake Formation 管理的資源**  
下列 `list-resources` 範例列出符合 Lake Formation 管理條件的資源。  

```
aws lakeformation list-resources \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "FilterConditionList": [{
        "Field": "ROLE_ARN",
        "ComparisonOperator": "CONTAINS",
        "StringValueList": [
            "123456789111"
        ]
    }],
    "MaxResults": 10
}
```
輸出：  

```
{
    "ResourceInfoList": [{
            "ResourceArn": "arn:aws:s3:::lf-data-lake-123456789111",
            "RoleArn": "arn:aws:iam::123456789111:role/LF-GlueServiceRole",
            "LastModified": "2022-07-21T02:12:46.669000+00:00"
        },
        {
            "ResourceArn": "arn:aws:s3:::lf-emr-test-123456789111",
            "RoleArn": "arn:aws:iam::123456789111:role/EMRLFS3Role",
            "LastModified": "2022-07-29T16:22:03.211000+00:00"
        }
    ]
}
```
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[管理 Lake Formation 許可權](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-permissions.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListResources](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/list-resources.html)。

### `list-transactions`
<a name="lakeformation_ListTransactions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-transactions`。

**AWS CLI**  
**列出所有交易詳細資訊**  
下列 `list-transactions` 範例會傳回有關交易及其狀態的中繼資料。  

```
aws lakeformation list-transactions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "StatusFilter": "ALL",
    "MaxResults": 3
}
```
輸出：  

```
{
    "Transactions": [{
            "TransactionId": "1234569f08804cb790d950d4d0fe485e",
            "TransactionStatus": "committed",
            "TransactionStartTime": "2022-08-10T14:32:29.220000+00:00",
            "TransactionEndTime": "2022-08-10T14:32:33.751000+00:00"
        },
        {
            "TransactionId": "12345972ca8347b89825e33c5774aec4",
            "TransactionStatus": "committed",
            "TransactionStartTime": "2022-08-10T14:29:04.046000+00:00",
            "TransactionEndTime": "2022-08-10T14:29:09.681000+00:00"
        },
        {
            "TransactionId": "12345daf6cb047dbba8ad9b0414613b2",
            "TransactionStatus": "committed",
            "TransactionStartTime": "2022-08-10T13:56:51.261000+00:00",
            "TransactionEndTime": "2022-08-10T13:56:51.547000+00:00"
        }
    ],
    "NextToken": "77X1ebypsI7os+X2lhHsZLGNCDK3nNGpwRdFpicSOHgcX1/QMoniUAKcpR3kj3ts3PVdMA=="
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListTransactions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/list-transactions.html)。

### `put-data-lake-settings`
<a name="lakeformation_PutDataLakeSettings_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `put-data-lake-settings`。

**AWS CLI**  
**設定 AWS Lake Formation 受管資料湖設定**  
下列 `put-data-lake-settings` 範例會設定資料湖管理員，和其他資料湖設定的清單。  

```
aws lakeformation put-data-lake-settings \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "DataLakeSettings": {
        "DataLakeAdmins": [{
                "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-admin"
            }
        ],
        "CreateDatabaseDefaultPermissions": [],
        "CreateTableDefaultPermissions": [],
        "TrustedResourceOwners": [],
        "AllowExternalDataFiltering": true,
        "ExternalDataFilteringAllowList": [{
            "DataLakePrincipalIdentifier ": "123456789111"
        }],
        "AuthorizedSessionTagValueList": ["Amazon EMR"]
    }
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[變更資料湖的預設安全設定](https://docs.aws.amazon.com/lake-formation/latest/dg/change-settings.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [PutDataLakeSettings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/put-data-lake-settings.html)。

### `register-resource`
<a name="lakeformation_RegisterResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `register-resource`。

**AWS CLI**  
**範例 1：使用服務連結角色註冊資料湖儲存**  
下列 `register-resource` 範例會使用服務連結角色，將資源註冊為由 Lake Formation 管理。  

```
aws lakeformation register-resource \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "ResourceArn": "arn:aws:s3:::lf-emr-athena-result-123",
    "UseServiceLinkedRole": true
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[將 Amazon S3 位置新增至您的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/register-data-lake.html)。  
**範例 2：使用自訂角色註冊資料湖儲存**  
下列 `register-resource` 範例會使用自訂角色，將資源註冊為由 Lake Formation 管理。  

```
aws lakeformation register-resource \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "ResourceArn": "arn:aws:s3:::lf-emr-athena-result-123",
    "UseServiceLinkedRole": false,
    "RoleArn": "arn:aws:iam::123456789111:role/LF-GlueServiceRole"
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[將 Amazon S3 位置新增至您的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/register-data-lake.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [RegisterResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/register-resource.html)。

### `remove-lf-tags-from-resource`
<a name="lakeformation_RemoveLfTagsFromResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `remove-lf-tags-from-resource`。

**AWS CLI**  
**從資源移除 LF 標籤**  
下列 `remove-lf-tags-from-resource` 範例會移除與資料表資源的 LF 標籤關聯。  

```
aws lakeformation remove-lf-tags-from-resource \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Resource": {
        "Table": {
            "CatalogId": "123456789111",
            "DatabaseName": "tpc",
            "Name": "dl_tpc_promotion"
        }
    },
    "LFTags": [{
        "CatalogId": "123456789111",
        "TagKey": "usergroup",
        "TagValues": [
            "developer"
        ]
    }]
}
```
輸出：  

```
{
    "Failures": []
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[將 LF 標籤指派給 Data Catalog 資源](https://docs.aws.amazon.com/lake-formation/latest/dg/TBAC-assigning-tags.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [RemoveLfTagsFromResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/remove-lf-tags-from-resource.html)。

### `revoke-permissions`
<a name="lakeformation_RevokePermissions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `revoke-permissions`。

**AWS CLI**  
**從主體撤銷資源的許可權**  
下列 `revoke-permissions` 範例會撤銷給定資料庫之特定資料表的主體存取權。  

```
aws lakeformation revoke-permissions \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "123456789111",
    "Principal": {
        "DataLakePrincipalIdentifier": "arn:aws:iam::123456789111:user/lf-developer"
    },
    "Resource": {
        "Table": {
            "CatalogId": "123456789111",
            "DatabaseName": "tpc",
            "Name": "dl_tpc_promotion"
        }
    },
    "Permissions": [
        "ALL"
    ],
    "PermissionsWithGrantOption": []
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[授予和撤銷 Data Catalog 資源的許可](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [RevokePermissions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/revoke-permissions.html)。

### `search-databases-by-lf-tags`
<a name="lakeformation_SearchDatabasesByLfTags_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `search-databases-by-lf-tags`。

**AWS CLI**  
**依 LFTags 搜尋資料庫資源**  
下列 `search-databases-by-lf-tags` 範例搜尋符合 LFTag 表達式的資料庫資源。  

```
aws lakeformation search-databases-by-lf-tags \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "MaxResults": 1,
    "CatalogId": "123456789111",
    "Expression": [{
        "TagKey": "usergroup",
        "TagValues": [
            "developer"
        ]
    }]
}
```
輸出：  

```
{
    "DatabaseList": [{
        "Database": {
            "CatalogId": "123456789111",
            "Name": "tpc"
        },
        "LFTags": [{
            "CatalogId": "123456789111",
            "TagKey": "usergroup",
            "TagValues": [
                "developer"
            ]
        }]
    }]
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[檢視獲受指派 LF 標籤的資源](https://docs.aws.amazon.com/lake-formation/latest/dg/TBAC-view-tag-resources.html)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [SearchDatabasesByLfTags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/search-databases-by-lf-tags.html)。

### `search-tables-by-lf-tags`
<a name="lakeformation_SearchTablesByLfTags_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `search-tables-by-lf-tags`。

**AWS CLI**  
**依 LFTags 搜尋資料表資源**  
下列 `search-tables-by-lf-tags` 範例搜尋符合 LFTag 表達式的資料表資源。  

```
aws lakeformation search-tables-by-lf-tags \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "MaxResults": 2,
    "CatalogId": "123456789111",
    "Expression": [{
        "TagKey": "usergroup",
        "TagValues": [
            "developer"
        ]
    }]
}
```
輸出：  

```
{
    "NextToken": "c2VhcmNoQWxsVGFnc0luVGFibGVzIjpmYWxzZX0=",
    "TableList": [{
        "Table": {
            "CatalogId": "123456789111",
            "DatabaseName": "tpc",
            "Name": "dl_tpc_item"
        },
        "LFTagOnDatabase": [{
            "CatalogId": "123456789111",
            "TagKey": "usergroup",
            "TagValues": [
                "developer"
            ]
        }],
        "LFTagsOnTable": [{
            "CatalogId": "123456789111",
            "TagKey": "usergroup",
            "TagValues": [
                "developer"
            ]
        }],
        "LFTagsOnColumns": [{
                "Name": "i_item_desc",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_container",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_wholesale_cost",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_manufact_id",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_brand_id",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_formulation",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_current_price",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_size",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_rec_start_date",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_manufact",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_item_sk",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_manager_id",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_item_id",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_class_id",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_class",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_category",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_category_id",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_brand",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_units",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_rec_end_date",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_color",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            },
            {
                "Name": "i_product_name",
                "LFTags": [{
                    "CatalogId": "123456789111",
                    "TagKey": "usergroup",
                    "TagValues": [
                        "developer"
                    ]
                }]
            }
        ]
    }]
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[檢視獲受指派 LF 標籤的資源](https://docs.aws.amazon.com/lake-formation/latest/dg/TBAC-view-tag-resources.html)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [SearchTablesByLfTags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/search-tables-by-lf-tags.html)。

### `start-query-planning`
<a name="lakeformation_StartQueryPlanning_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `start-query-planning`。

**AWS CLI**  
**處理查詢陳述式**  
下列 `start-query-planning` 範例會提交處理查詢陳述式的請求。  

```
aws lakeformation start-query-planning \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "QueryPlanningContext": {
        "CatalogId": "012345678901",
        "DatabaseName": "tpc"
    },
    "QueryString": "select * from dl_tpc_household_demographics_gov where hd_income_band_sk=9"
}
```
輸出：  

```
{
    "QueryId": "772a273f-4a62-4cda-8d98-69615ee8be9b"
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [StartQueryPlanning](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/start-query-planning.html)。

### `start-transaction`
<a name="lakeformation_StartTransaction_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `start-transaction`。

**AWS CLI**  
**開始新交易**  
下列 `start-transaction` 範例會啟動新的交易，並傳回其交易 ID。  

```
aws lakeformation start-transaction \
    --transaction-type = 'READ_AND_WRITE'
```
輸出：  

```
{
    "TransactionId": "b014d972ca8347b89825e33c5774aec4"
}
```
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [StartTransaction](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/start-transaction.html)。

### `update-lf-tag`
<a name="lakeformation_UpdateLfTag_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-lf-tag`。

**AWS CLI**  
**更新 LF 標籤定義**  
下列 `update-lf-tag` 範例會更新 LF-Tag 定義。  

```
aws lakeformation update-lf-tag \
    --catalog-id '123456789111' \
    --tag-key 'usergroup' \
    --tag-values-to-add '["admin"]'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[管理用於中繼資料存取控制的 LF 標籤](https://docs.aws.amazon.com/lake-formation/latest/dg/managing-tags.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateLfTag](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/update-lf-tag.html)。

### `update-table-objects`
<a name="lakeformation_UpdateTableObjects_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-table-objects`。

**AWS CLI**  
**修改管控資料表的物件**  
下列 `update-table-objects` 範例會將提供的 S3 物件新增至指定的管控資料表。  

```
aws lakeformation update-table-objects \
    --cli-input-json file://input.json
```
`input.json` 的內容：  

```
{
    "CatalogId": "012345678901",
    "DatabaseName": "tpc",
    "TableName": "dl_tpc_household_demographics_gov",
    "TransactionId": "12347a9f75424b9b915f6ff201d2a190",
    "WriteOperations": [{
        "AddObject": {
            "Uri": "s3://lf-data-lake-012345678901/target/dl_tpc_household_demographics_gov/run-unnamed-1-part-block-0-r-00000-snappy-ff26b17504414fe88b302cd795eabd00.parquet",
            "ETag": "1234ab1fc50a316b149b4e1f21a73800",
            "Size": 42200
        }
    }]
}
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS Lake Formation 開發人員指南*》中的[讀取和寫入交易中的資料湖](https://docs.aws.amazon.com/lake-formation/latest/dg/transaction-ops.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateTableObjects](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lakeformation/update-table-objects.html)。