

# 블루프린트 개발을 위한 사전 조건
<a name="developing-blueprints-prereq"></a>

블루프린트를 개발하려면 AWS Glue 사용과 Apache Spark ETL 작업 또는 Python 셸 작업을 위한 스크립트 작성에 익숙해야 합니다. 또한 다음 설정 태스크를 완료해야 합니다.
+ 블루프린트 레이아웃 스크립트에 사용할 4개의 AWS Python 라이브러리를 다운로드합니다.
+ AWS SDK를 설정합니다.
+ AWS CLI를 설정합니다.

## Python 라이브러리 다운로드
<a name="prereqs-get-libes"></a>

GitHub에서 다음 라이브러리를 다운로드하고 프로젝트에 설치합니다.
+ [https://github.com/awslabs/aws-glue-blueprint-libs/tree/master/awsglue/blueprint/base\$1resource.py](https://github.com/awslabs/aws-glue-blueprint-libs/tree/master/awsglue/blueprint/base_resource.py)
+ [https://github.com/awslabs/aws-glue-blueprint-libs/tree/master/awsglue/blueprint/workflow.py](https://github.com/awslabs/aws-glue-blueprint-libs/tree/master/awsglue/blueprint/workflow.py)
+ [https://github.com/awslabs/aws-glue-blueprint-libs/tree/master/awsglue/blueprint/crawler.py](https://github.com/awslabs/aws-glue-blueprint-libs/tree/master/awsglue/blueprint/crawler.py)
+ [https://github.com/awslabs/aws-glue-blueprint-libs/tree/master/awsglue/blueprint/job.py](https://github.com/awslabs/aws-glue-blueprint-libs/tree/master/awsglue/blueprint/job.py)

## AWS Java SDK 설정
<a name="prereqs-java-preview-sdk"></a>

AWS Java SDK의 경우 블루프린트용 API가 `jar` 포함된 파일을 추가해야 합니다.

1. 아직 설정하지 않은 경우 AWS SDK for Java를 설정합니다.
   + Java 1.x의 경우 *AWS SDK for Java Developer Guide*의 [Set up the AWS SDK for Java](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-install.html) 지침을 따르세요.
   + Java 2.x의 경우 *AWS SDK for Java 2.x Developer Guide*의 [Setting up the AWS SDK for Java 2.x](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/setup.html) 지침을 따르세요.

1. 블루프린트용 API에 대한 액세스 권한이 있는 클라이언트 `jar` 파일을 다운로드합니다.
   + Java 1.x의 경우: s3://awsglue-custom-blueprints-preview-artifacts/awsglue-java-sdk-preview/AWSGlueJavaClient-1.11.x.jar
   + Java 2.x의 경우: s3://awsglue-custom-blueprints-preview-artifacts/awsglue-java-sdk-v2-preview/AwsJavaSdk-Glue-2.0.jar

1. AWS Java SDK에서 제공하는 AWS Glue 클라이언트를 재정의하려면 Java 클래스 경로 앞에 클라이언트 `jar`를 추가합니다.

   ```
   export CLASSPATH=<path-to-preview-client-jar>:$CLASSPATH
   ```

1. (선택 사항) 다음 Java 애플리케이션으로 SDK를 테스트합니다. 애플리케이션이 빈 목록을 출력해야 합니다.

   `accessKey` 및 `secretKey`를 자격 증명으로 바꾸고 `us-east-1`을 리전으로 바꿉니다.

   ```
   import com.amazonaws.auth.AWSCredentials;
   import com.amazonaws.auth.AWSCredentialsProvider;
   import com.amazonaws.auth.AWSStaticCredentialsProvider;
   import com.amazonaws.auth.BasicAWSCredentials;
   import com.amazonaws.services.glue.AWSGlue;
   import com.amazonaws.services.glue.AWSGlueClientBuilder;
   import com.amazonaws.services.glue.model.ListBlueprintsRequest;
   
   public class App{
       public static void main(String[] args) {
           AWSCredentials credentials = new BasicAWSCredentials("accessKey", "secretKey");
           AWSCredentialsProvider provider = new AWSStaticCredentialsProvider(credentials);
           AWSGlue glue = AWSGlueClientBuilder.standard().withCredentials(provider)
                   .withRegion("us-east-1").build();
           ListBlueprintsRequest request = new ListBlueprintsRequest().withMaxResults(2);
           System.out.println(glue.listBlueprints(request));
       }
   }
   ```

## AWS Python SDK 설정
<a name="prereqs-python-preview-sdk"></a>

다음 단계에서는 컴퓨터에 Python 버전 2.7 이상 또는 버전 3.9 이상이 설치되어 있다고 가정합니다.

1. 다음 boto3 휠 파일을 다운로드합니다. 열거나 저장하라는 메시지가 표시되면 s3://awsglue-custom-blueprints-preview-artifacts/aws-python-sdk-preview/boto3-1.17.31-py2.py3-none-any.whl 파일을 저장합니다.

1. botocore 휠 파일인 s3://awsglue-custom-blueprints-preview-artifacts/aws-python-sdk-preview/botocore-1.20.31-py2.py3-none-any.whl을 다운로드합니다.

1. Python 버전을 확인합니다.

   ```
   python --version
   ```

1. Python 버전에 따라 다음 명령을 입력합니다(Linux의 경우).
   + Python 2.7 이상용입니다.

     ```
     python3 -m pip install --user virtualenv
     source env/bin/activate
     ```
   + Python 3.9 이상용입니다.

     ```
     python3 -m venv python-sdk-test
     source python-sdk-test/bin/activate
     ```

1. botocore 휠 파일을 설치합니다.

   ```
   python3 -m pip install <download-directory>/botocore-1.20.31-py2.py3-none-any.whl
   ```

1. boto3 휠 파일을 설치합니다.

   ```
   python3 -m pip install <download-directory>/boto3-1.17.31-py2.py3-none-any.whl
   ```

1. `~/.aws/credentials` 및 `~/.aws/config` 파일에서 자격 증명과 기본 리전을 구성합니다. 자세한 내용은 *AWS Command Line Interface User Guide*의 [Configuring the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)를 참조하세요.

1. (선택 사항) 설정을 테스트합니다. 다음 명령은 빈 목록을 반환합니다.

   `us-east-1`을 해당 리전으로 바꿉니다.

   ```
   $ python
   >>> import boto3
   >>> glue = boto3.client('glue', 'us-east-1')
   >>> glue.list_blueprints()
   ```

## 미리 보기 AWS CLI 설정
<a name="prereqs-setup-cli"></a>

1. 아직 수행하지 않았다면 컴퓨터에 AWS Command Line Interface(AWS CLI)를 설치 및/또는 업데이트합니다. 이를 수행하는 가장 쉬운 방법은 Python 설치 프로그램 유틸리티인 `pip`를 사용하는 것입니다.

   ```
   pip install awscli --upgrade --user
   ```

   AWS CLI에 대한 전체 설치 지침은 [AWS Command Line Interface 설치](https://docs.aws.amazon.com/cli/latest/userguide/installing.html)에서 찾을 수 있습니다.

1. s3://awsglue-custom-blueprints-preview-artifacts/awscli-preview-build/awscli-1.19.31-py2.py3-none-any.whl에서 AWS CLI 휠 파일을 다운로드합니다.

1. AWS CLI 휠 파일을 설치합니다.

   ```
   python3 -m pip install awscli-1.19.31-py2.py3-none-any.whl
   ```

1. `aws configure` 명령을 실행합니다. AWS 자격 증명(액세스 키 및 보안 암호 키 포함) 및 AWS 리전을 구성합니다. AWS CLI 구성에 대한 자세한 내용은 [AWS CLI 구성](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)에서 찾을 수 있습니다.

1. AWS CLI를 테스트합니다. 다음 명령은 빈 목록을 반환합니다.

   `us-east-1`을 해당 리전으로 바꿉니다.

   ```
   aws glue list-blueprints --region us-east-1
   ```