

# Lake Formation 자격 증명을 사용하도록 크롤러 구성
<a name="crawler-lf-integ"></a>

AWS Lake Formation 자격 증명을 사용하여 동일한 AWS 계정 또는 다른 AWS 계정 내의 기본 Amazon S3 위치가 있는 데이터 카탈로그 테이블 또는 Amazon S3 데이터 스토어에 액세스하도록 크롤러를 구성할 수 있습니다. 크롤러와 데이터 카탈로그 테이블이 동일한 계정에 있는 경우 기존 데이터 카탈로그 테이블을 크롤러의 대상으로 구성할 수 있습니다. 현재 데이터 카탈로그 테이블을 크롤러의 대상으로 사용할 때 단일 카탈로그 테이블이 있는 단일 카탈로그 대상만 허용됩니다.

**참고**  
데이터 카탈로그 테이블을 크롤러 대상으로 정의할 때 데이터 카탈로그 테이블의 기본 위치가 Amazon S3 위치인지 확인합니다. Lake Formation 자격 증명을 사용하는 크롤러는 기본 Amazon S3 위치가 있는 데이터 카탈로그 대상만 지원합니다.

## 크롤러와 등록된 Amazon S3 위치 또는 데이터 카탈로그 테이블이 동일한 계정에 있는 경우 필요한 설정(계정 내 크롤링)
<a name="in-account-crawling"></a>

크롤러가 Lake Formation 자격 증명을 사용하여 데이터 스토어 또는 데이터 카탈로그 테이블에 액세스할 수 있도록 하려면 Lake Formation에 데이터 위치를 등록해야 합니다. 또한 크롤러의 IAM 역할에는 Amazon S3 버킷이 등록된 대상에서 데이터를 읽을 수 있는 권한이 있어야 합니다.

AWS Management Console 또는 AWS Command Line Interface(AWS CLI)를 사용하여 다음 구성 단계를 완료할 수 있습니다.

------
#### [ AWS Management Console ]

1. 크롤러 소스에 액세스하도록 크롤러를 구성하기 전에 데이터 스토어 또는 데이터 카탈로그의 데이터 위치를 Lake Formation에 등록합니다. Lake Formation 콘솔([https://console.aws.amazon.com/lakeformation/](https://console.aws.amazon.com/lakeformation/))에서 크롤러가 정의된 AWS 계정에서 Amazon S3 위치를 데이터 레이크의 루트 위치로 등록합니다. 자세한 내용을 알아보려면 [Registering an Amazon S3 location](https://docs.aws.amazon.com/lake-formation/latest/dg/register-location.html)(Amazon S3 위치 등록)을 참조하세요.

1. 크롤러가 Lake Formation의 대상에서 데이터를 읽을 수 있도록 크롤러 실행에 사용되는 IAM 역할에 **Data location**(데이터 위치) 권한을 부여합니다. 자세한 내용을 알아보려면 [Granting data location permissions (same account)](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-location-permissions-local.html)(데이터 위치 권한 부여(동일한 계정))를 참조하세요.

1. 출력 데이터베이스로 지정된 데이터베이스에 크롤러 역할 액세스 권한(`Create` )을 부여합니다. 자세한 내용을 알아보려면 [Granting database permissions using the Lake Formation console and the named resource method](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-database-permissions.html)(Lake Formation 콘솔 및 명명된 리소스 메서드를 사용하여 데이터베이스 권한 부여)를 참조하세요.

1. IAM 콘솔([https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/))에서 크롤러에 대한 IAM 역할을 생성합니다. 역할에 `lakeformation:GetDataAccess` 정책을 추가합니다.

1. AWS Glue 콘솔([https://console.aws.amazon.com/glue/](https://console.aws.amazon.com/glue/))에서 크롤러를 구성하는 동안 **Use Lake Formation credentials for crawling Amazon S3 data source**(Amazon S3 데이터 소스 크롤링에 Lake Formation 자격 증명 사용) 옵션을 선택합니다.
**참고**  
accountId 필드는 계정 내 크롤링의 선택 사항입니다.

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

```
aws glue --profile demo create-crawler --debug --cli-input-json '{
    "Name": "prod-test-crawler",
    "Role": "arn:aws:iam::111122223333:role/service-role/AWSGlueServiceRole-prod-test-run-role",
    "DatabaseName": "prod-run-db",
    "Description": "",
    "Targets": {
    "S3Targets":[
                {
                 "Path": "s3://amzn-s3-demo-bucket"
                }
                ]
                },
   "SchemaChangePolicy": {
      "UpdateBehavior": "LOG",
      "DeleteBehavior": "LOG"
  },
  "RecrawlPolicy": {
    "RecrawlBehavior": "CRAWL_EVERYTHING"
  },
  "LineageConfiguration": {
    "CrawlerLineageSettings": "DISABLE"
  },
  "LakeFormationConfiguration": {
    "UseLakeFormationCredentials": true,
    "AccountId": "111122223333"
  },
  "Configuration": {
           "Version": 1.0,
           "CrawlerOutput": {
             "Partitions": { "AddOrUpdateBehavior": "InheritFromTable" },
             "Tables": {"AddOrUpdateBehavior": "MergeNewColumns" }
           },
           "Grouping": { "TableGroupingPolicy": "CombineCompatibleSchemas" }
         },
  "CrawlerSecurityConfiguration": "",
  "Tags": {
    "KeyName": ""
  }
}'
```

------

# 크롤러와 등록된 Amazon S3 위치가 다른 계정에 있는 경우 필요한 설정(크로스 계정 크롤링)
<a name="cross-account-crawling"></a>

크롤러가 Lake Formation 자격 증명을 사용하여 다른 계정의 데이터 스토어에 액세스할 수 있도록 하려면 먼저 Lake Formation에 Amazon S3 데이터 위치를 등록해야 합니다. 그리고 다음 단계에 따라 크롤러의 계정에 데이터 위치 권한을 부여합니다.

AWS Management Console 또는 AWS CLI를 사용하여 다음 단계를 완료할 수 있습니다.

------
#### [ AWS Management Console ]

1. Amazon S3 위치가 등록된 계정(계정 B)에서

   1. Lake Formation에 Amazon S3 경로를 등록합니다. 자세한 내용을 알아보려면 [Registering an Amazon S3 location](https://docs.aws.amazon.com/lake-formation/latest/dg/register-location.html)(Amazon S3 위치 등록)을 참조하세요.

   1.  크롤러가 실행될 계정(계정 A)에 **Data location**(데이터 위치) 권한을 부여합니다. 자세한 내용을 알아보려면 [Granting data location permissions](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-location-permissions-local.html)(데이터 위치 권한 부여)를 참조하세요.

   1. 기본 위치를 대상 Amazon S3 위치로 사용하여 Lake Formation에 빈 데이터베이스를 생성합니다. 자세한 내용을 알아보려면 [Creating a database](https://docs.aws.amazon.com/lake-formation/latest/dg/creating-database.html)(데이터베이스 생성)를 참조하세요.

   1. 계정 A(크롤러가 실행될 계정)에 이전 단계에서 생성한 데이터베이스에 대한 액세스 권한을 부여합니다. 자세한 내용을 알아보려면 [Granting database permissions](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-database-permissions.html)(데이터베이스 권한 부여)를 참조하세요.

1. 크롤러가 생성되어 실행될 계정(계정 A)에서

   1.  AWS RAM 콘솔을 사용하여 외부 계정(계정 B)에서 공유된 데이터베이스를 수락합니다. 자세한 내용을 알아보려면 [AWS Resource Access Manager에서 리소스 공유 초대 수락](https://docs.aws.amazon.com/lake-formation/latest/dg/accepting-ram-invite.html)을 참조하세요.

   1.  크롤러에 대한 IAM 역할을 생성합니다. 역할에 `lakeformation:GetDataAccess` 정책을 추가합니다.

   1.  Lake Formation 콘솔([https://console.aws.amazon.com/lakeformation/](https://console.aws.amazon.com/lakeformation/))에서 크롤러가 Lake Formation의 대상에서 데이터를 읽을 수 있도록 크롤러 실행에 사용되는 IAM 역할에 대상 Amazon S3 위치에 대한 **Data location**(데이터 위치) 권한을 부여합니다. 자세한 내용을 알아보려면 [Granting data location permissions](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-location-permissions-local.html)(데이터 위치 권한 부여)를 참조하세요.

   1.  공유 데이터베이스에 리소스 링크를 생성합니다. 자세한 내용을 알아보려면 [Create a resource link](https://docs.aws.amazon.com/lake-formation/latest/dg/create-resource-link-database.html)(리소스 링크 만들기)를 참조하세요.

   1.  공유 데이터베이스 및 (`Describe`) 리소스 링크에 대한 크롤러 역할 액세스 권한(`Create`)을 부여합니다. 리소스 링크는 크롤러의 출력에 지정됩니다.

   1.  AWS Glue 콘솔([https://console.aws.amazon.com/glue/](https://console.aws.amazon.com/glue/))에서 크롤러를 구성하는 동안 **Use Lake Formation credentials for crawling Amazon S3 data source**(Amazon S3 데이터 소스 크롤링에 Lake Formation 자격 증명 사용) 옵션을 선택합니다.

      크로스 계정 크롤링의 경우 대상 Amazon S3 위치가 Lake Formation에 등록된 AWS 계정 ID를 지정합니다. 계정 내 크롤링의 경우 accountId 필드는 선택 사항입니다.  
![\[IAM role selection and Lake Formation configuration options for AWS Glue 크롤러 security settings.\]](http://docs.aws.amazon.com/ko_kr/glue/latest/dg/images/cross-account-crawler.png)

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

```
aws glue --profile demo create-crawler --debug --cli-input-json '{
    "Name": "prod-test-crawler",
    "Role": "arn:aws:iam::111122223333:role/service-role/AWSGlueServiceRole-prod-test-run-role",
    "DatabaseName": "prod-run-db",
    "Description": "",
    "Targets": {
    "S3Targets":[
                {
                 "Path": "s3://amzn-s3-demo-bucket"
                }
                ]
                },
   "SchemaChangePolicy": {
      "UpdateBehavior": "LOG",
      "DeleteBehavior": "LOG"
  },
  "RecrawlPolicy": {
    "RecrawlBehavior": "CRAWL_EVERYTHING"
  },
  "LineageConfiguration": {
    "CrawlerLineageSettings": "DISABLE"
  },
  "LakeFormationConfiguration": {
    "UseLakeFormationCredentials": true,
    "AccountId": "111111111111"
  },
  "Configuration": {
           "Version": 1.0,
           "CrawlerOutput": {
             "Partitions": { "AddOrUpdateBehavior": "InheritFromTable" },
             "Tables": {"AddOrUpdateBehavior": "MergeNewColumns" }
           },
           "Grouping": { "TableGroupingPolicy": "CombineCompatibleSchemas" }
         },
  "CrawlerSecurityConfiguration": "",
  "Tags": {
    "KeyName": ""
  }
}'
```

------

**참고**  
Lake Formation 자격 증명을 사용하는 크롤러는 Amazon S3 및 데이터 카탈로그 대상에 대해서만 지원됩니다.
Lake Formation 자격 증명 벤딩을 사용하는 대상의 경우 기본 Amazon S3 위치가 동일한 버킷에 속해야 합니다. 예를 들어, 고객은 모든 대상 위치가 동일한 버킷(amzn-s3-demo-bucket1) 아래에 있는 한 여러 대상(s3://amzn-s3-demo-bucket1/folder1, s3://amzn-s3-demo-bucket1/folder2)을 사용할 수 있습니다. 서로 다른 버킷(s3://amzn-s3-demo-bucket1/folder1, s3://amzn-s3-demo-bucket2/folder2)을 지정하는 것은 허용되지 않습니다.
현재 데이터 카탈로그 대상 크롤러의 경우 단일 카탈로그 테이블이 있는 단일 카탈로그 대상만 허용됩니다.