

 Amazon Redshift는 패치 198부터 새 Python UDF 생성을 더 이상 지원하지 않습니다. 기존 Python UDF는 2026년 6월 30일까지 계속 작동합니다. 자세한 내용은 [블로그 게시물](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)을 참조하세요.

# Spark 커넥터를 사용한 인증
<a name="redshift-spark-connector-authentication"></a>

다음 다이어그램은 Amazon S3, Amazon Redshift, Spark 드라이버 및 Spark 실행기 간의 인증을 설명합니다.

![\[Spark 커넥터 인증 다이어그램입니다.\]](http://docs.aws.amazon.com/ko_kr/redshift/latest/mgmt/images/spark-connector-authentication.png)


## Redshift와 Spark 간의 인증
<a name="redshift-spark-authentication"></a>

 Amazon Redshift 제공 JDBC 드라이버 버전 2.x 드라이버를 사용해 로그인 자격 증명을 지정하여 Spark 커넥터로 Amazon Redshift에 연결할 수 있습니다. IAM을 사용하려면 [IAM 인증을 사용하도록 JDBC URL을 구성](https://docs.aws.amazon.com/redshift/latest/mgmt/generating-iam-credentials-configure-jdbc-odbc.html)하세요. Amazon EMR 또는 AWS Glue에서 Redshift 클러스터에 연결하려면 IAM 역할에 임시 IAM 자격 증명을 검색하는 데 필요한 권한이 있는지 확인하세요. 다음 목록은 IAM 역할이 자격 증명을 검색하고 Amazon S3 작업을 실행하는 데 필요한 모든 권한을 설명합니다.
+ [ Redshift:GetClusterCredentials](https://docs.aws.amazon.com/redshift/latest/APIReference/API_GetClusterCredentials.html)(프로비저닝된 Redshift 클러스터용)
+ [ Redshift:DescribeClusters](https://docs.aws.amazon.com/redshift/latest/APIReference/API_DescribeClusters.html)(프로비저닝된 Redshift 클러스터용)
+ [ Redshift:GetWorkgroup](https://docs.aws.amazon.com/redshift-serverless/latest/APIReference/API_GetWorkgroup.html)(Amazon Redshift Serverless 작업 그룹)
+ [ Redshift:GetCredentials](https://docs.aws.amazon.com/redshift-serverless/latest/APIReference/API_GetCredentials.html)(Amazon Redshift Serverless 작업 그룹)
+ [ s3:ListBucket](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html)
+ [ s3:GetBucket](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_GetBucket.html)
+ [ s3:GetObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html)
+ [ s3:PutObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html)
+ [ s3:GetBucketLifecycleConfiguration](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycleConfiguration.html)

 GetClusterCredentials에 대한 자세한 내용은 [GetClusterCredentials에 대한 IAM 정책](https://docs.aws.amazon.com/redshift/latest/mgmt/redshift-iam-access-control-identity-based.html#redshift-policy-resources.getclustercredentials-resources)을 참조하세요.

또한 `COPY` 및 `UNLOAD` 작업 중에 Amazon Redshift가 IAM 역할을 맡을 수 있는지 확인해야 합니다.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "redshift.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}
```

------

최신 JDBC 드라이버를 사용하는 경우 드라이버는 Amazon Redshift 자체 서명 인증서에서 ACM 인증서로의 전환을 자동으로 관리합니다. 하지만 [JDBC URL에 SSL 옵션을 지정](https://docs.aws.amazon.com/redshift/latest/mgmt/jdbc20-configuration-options.html#jdbc20-ssl-option)해야 합니다.

 다음은 Amazon Redshift에 연결하기 위해 JDBC 드라이버 URL 및 `aws_iam_role`을 지정하는 방법의 예입니다.

```
df.write \
  .format("io.github.spark_redshift_community.spark.redshift ") \
  .option("url", "jdbc:redshift:iam://<the-rest-of-the-connection-string>") \
  .option("dbtable", "<your-table-name>") \
  .option("tempdir", "s3a://<your-bucket>/<your-directory-path>") \
  .option("aws_iam_role", "<your-aws-role-arn>") \
  .mode("error") \
  .save()
```

## Amazon S3와 Spark 간의 인증
<a name="spark-s3-authentication"></a>

 IAM 역할을 사용하여 Spark와 Amazon S3 간에 인증하는 경우 다음 방법 중 하나를 사용하세요.
+ Java용 AWS SDK는 DefaultAWSCredentialsProviderChain 클래스에 의해 구현된 기본 자격 증명 공급자 체인을 사용하여 자동으로 AWS 자격 증명을 찾으려고 시도합니다. 자세한 내용은 [기본 자격 증명 공급자 체인 사용](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default)을 참조하세요.
+ [Hadoop 구성 속성](https://github.com/apache/hadoop/blob/trunk/hadoop-tools/hadoop-aws/src/site/markdown/tools/hadoop-aws/index.md)을 통해 AWS 키를 지정할 수 있습니다. 예를 들어 `tempdir` 구성이 `s3n://` 파일 시스템을 가리키는 경우 Hadoop XML 구성 파일에서 `fs.s3n.awsAccessKeyId` 및 `fs.s3n.awsSecretAccessKey` 속성을 설정하거나 `sc.hadoopConfiguration.set()`을 호출하여 Spark의 전역 Hadoop 구성을 변경합니다.

예를 들어 s3n 파일 시스템을 사용하는 경우 다음을 추가합니다.

```
sc.hadoopConfiguration.set("fs.s3n.awsAccessKeyId", "YOUR_KEY_ID")
sc.hadoopConfiguration.set("fs.s3n.awsSecretAccessKey", "YOUR_SECRET_ACCESS_KEY")
```

s3a 파일 시스템을 사용하는 경우 다음을 추가합니다.

```
sc.hadoopConfiguration.set("fs.s3a.access.key", "YOUR_KEY_ID")
sc.hadoopConfiguration.set("fs.s3a.secret.key", "YOUR_SECRET_ACCESS_KEY")
```

Python을 사용하는 경우 다음 작업을 사용합니다.

```
sc._jsc.hadoopConfiguration().set("fs.s3n.awsAccessKeyId", "YOUR_KEY_ID")
sc._jsc.hadoopConfiguration().set("fs.s3n.awsSecretAccessKey", "YOUR_SECRET_ACCESS_KEY")
```
+ `tempdir` URL에서 인증 키를 인코딩합니다. 예를 들어 URI `s3n://ACCESSKEY:SECRETKEY@bucket/path/to/temp/dir`은 키 쌍(`ACCESSKEY`, `SECRETKEY`)을 인코딩합니다.

## Redshift와 Amazon S3 간의 인증
<a name="redshift-s3-authentication"></a>

 쿼리에서 COPY 및 UNLOAD 명령을 사용하는 경우 사용자 대신 쿼리를 실행할 수 있도록 Amazon Redshift에 대한 Amazon S3 액세스 권한도 부여해야 합니다. 이렇게 하려면 먼저 [다른 AWS 서비스에 액세스할 수 있도록 Amazon Redshift에 권한을 부여](https://docs.aws.amazon.com/redshift/latest/mgmt/authorizing-redshift-service.html)한 다음 [IAM 역할을 사용하여 COPY 및 UNLOAD 작업에 권한을 부여](https://docs.aws.amazon.com/redshift/latest/mgmt/copy-unload-iam-role.html)합니다.

가장 좋은 방법은 권한 정책을 IAM 역할에 연결한 다음 필요에 따라 사용자 및 그룹에 할당하는 것입니다. 자세한 내용은 [Amazon Redshift의 Identity and Access Management](https://docs.aws.amazon.com/redshift/latest/mgmt/redshift-iam-authentication-access-control.html)를 참조하세요.

## 와의 통합AWS Secrets Manager
<a name="redshift-secrets-manager-authentication"></a>

AWS Secrets Manager에 저장된 시크릿에서 Redshift 사용자 이름 및 암호 보안 인증 정보를 검색할 수 있습니다. Redshift 보안 인증을 자동으로 제공하려면 `secret.id` 파라미터를 사용하세요. Redshift 보안 인증 시크릿을 만드는 방법에 대한 자세한 내용은 [AWS Secrets Manager 데이터베이스 보안 암호 생성](https://docs.aws.amazon.com/secretsmanager/latest/userguide/create_database_secret.html)을 참조하세요.

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/redshift/latest/mgmt/redshift-spark-connector-authentication.html)

**참고**  
 인정 조항: 이 문서에는 [Apache 2.0 라이선스](https://www.apache.org/licenses/LICENSE-2.0)에 따라 라이선스가 부여된 [Apache Software Foundation](http://www.apache.org/)에서 개발한 샘플 코드 및 언어가 포함되어 있습니다.