

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# AWS SAM정책 템플릿
<a name="serverless-policy-templates"></a>

 AWS Serverless Application Model (AWS SAM)를 사용하면 정책 템플릿 목록에서 선택하여 Lambda 함수 및 AWS Step Functions 상태 시스템의 권한 범위를 애플리케이션에서 사용하는 리소스로 지정할 수 있습니다.

AWS SAM 정책 템플릿을 AWS Serverless Application Repository 사용하는의 애플리케이션은에서 애플리케이션을 배포하기 위해 특별한 고객 승인이 필요하지 않습니다 AWS Serverless Application Repository.

새 정책 템플릿 추가를 요청하려면 다음을 수행합니다.

1.  AWS SAM GitHub 프로젝트의 `develop`브랜치에 있는 policy\$1templates.json 소스 파일에 대해 풀 요청을 제출합니다. 소스 파일은 GitHub 웹사이트의 [policy\$1templates.json](https://github.com/aws/serverless-application-model/blob/develop/samtranslator/policy_templates_data/policy_templates.json)에서 찾을 수 있습니다.

1.  AWS SAM GitHub 프로젝트에서 풀 요청의 이유와 요청에 대한 링크가 포함된 문제를 제출합니다. 이 링크를 사용하여 새 문제를 제출합니다. [AWS Serverless Application Model: 문제](https://github.com/aws/serverless-application-model/issues/new).

## 구문
<a name="serverless-policy-template-syntax"></a>

템플릿 파일에서 지정하는 모든 정책 AWS SAM 템플릿에 대해 항상 정책 템플릿의 자리 표시자 값이 포함된 객체를 지정해야 합니다. 정책 템플릿에 자리 표시자 값이 필요하지 않은 경우 빈 객체를 지정해야 합니다.

### YAML
<a name="serverless-policy-template-syntax.yaml"></a>

```
MyFunction:
  Type: AWS::Serverless::Function
  Properties:
    Policies:
      - PolicyTemplateName1:        # Policy template with placeholder value
          Key1: Value1
      - PolicyTemplateName2: {}     # Policy template with no placeholder value
```

**참고**  
일반 IAM 정책을 설정했거나 Lambda를 통해 정책을 관리한 경우 빈 객체를 사용하지 않고 정책 템플릿을 설정할 수 있습니다.

## 예제
<a name="serverless-policy-template-examples"></a>

### 예 1: 자리 표시자 값이 있는 정책 템플릿
<a name="policy-template-example-1"></a>

다음 예는 [SQSPollerPolicy](serverless-policy-template-list.md#sqs-poller-policy) 정책 템플릿에서 `QueueName`를 리소스로 예상한다는 것을 보여줍니다. AWS SAM 템플릿은 동일한 애플리케이션에서 생성하거나 애플리케이션에 대한 파라미터로 요청할 수 있는 "`MyQueue`" Amazon SQS 대기열의 이름을 검색합니다.

```
 1. MyFunction:
 2.   Type: 'AWS::Serverless::Function'
 3.   Properties:
 4.     CodeUri: ${codeuri}
 5.     Handler: hello.handler
 6.     Runtime: python2.7
 7.     Policies:
 8.       - SQSPollerPolicy:
 9.           QueueName:
10.             !GetAtt MyQueue.QueueName
```

### 예 2: 자리 표시자 값이 없는 정책 템플릿
<a name="policy-template-example-2"></a>

다음 예에는 자리 표시자 값이 없는 [CloudWatchPutMetricPolicy](serverless-policy-template-list.md#cloudwatch-put-metric-policy) 정책 템플릿이 포함되어 있습니다.

**참고**  
자리 표시자 값이 없더라도 빈 객체를 지정해야 합니다. 그렇지 않으면 오류가 발생합니다.

```
1. MyFunction:
2.   Type: 'AWS::Serverless::Function'
3.   Properties:
4.     CodeUri: ${codeuri}
5.     Handler: hello.handler
6.     Runtime: python2.7
7.     Policies:
8.       - CloudWatchPutMetricPolicy: {}
```

### 예 3: 자리 표시자 값과 일반 IAM 정책이 포함된 정책 템플릿
<a name="policy-template-example-3"></a>

다음 예제에는 AmazonSQSFullAcess 정책 및 [DynamoDBCrudPolicy](serverless-policy-template-list.md#dynamo-db-crud-policy) 정책 템플릿이 포함되어 있습니다. AmazonSQSFullAccess 정책은 정책이 아닌 IAM 정책 AWS SAM 이므로 정책이에 직접 전달되므로 빈 객체를 지정할 필요가 없습니다 CloudFormation.

```
 1. MyFunction:
 2.   Type: 'AWS::Serverless::Function'
 3.   Properties:
 4.     CodeUri: ${codeuri}
 5.     Handler: hello.handler
 6.     Runtime: python2.7
 7.     Policies:
 8.       - AmazonSQSFullAccess // IAM policy could be set without passing an empty object
 9.       - DynamoDBCrudPolicy: // SAM specific policy, has a defined structure
10.            TableName: 
11.              !Ref SampleTable
```

## 정책 템플릿 테이블
<a name="serverless-policy-template-table"></a>

다음은 사용 가능한 정책 템플릿의 테이블입니다.


****  

| 정책 템플릿 | 설명 | 
| --- | --- | 
| [AcmGetCertificatePolicy](serverless-policy-template-list.md#acm-get-certificate-policy) | 인증서를 읽을 수 있는 권한을 부여합니다 AWS Certificate Manager. | 
| [AMIDescribePolicy](serverless-policy-template-list.md#ami-describe-policy) | Amazon Machine Image(AMI)를 설명할 수 있는 권한을 부여합니다. | 
| [AthenaQueryPolicy](serverless-policy-template-list.md#athena-query-policy) | Athena 쿼리를 실행할 권한을 부여합니다. | 
| [AWSSecretsManagerGetSecretValuePolicy](serverless-policy-template-list.md#secrets-manager-get-secret-value-policy) | 지정된 AWS Secrets Manager 보안 암호의 보안 암호 값을 가져올 수 있는 권한을 부여합니다. | 
| [AWSSecretsManagerRotationPolicy](serverless-policy-template-list.md#secrets-manager-rotation-policy) |  AWS Secrets Manager에서 보안 암호를 교체할 수 있는 권한을 부여합니다. | 
| [CloudFormationDescribeStacksPolicy](serverless-policy-template-list.md#cloud-formation-describe-stacks-policy) |  CloudFormation 스택을 설명할 수 있는 권한을 부여합니다. | 
| [CloudWatchDashboardPolicy](serverless-policy-template-list.md#cloudwatch-dashboard-policy) | CloudWatch 대시보드에서 작동할 지표를 배치할 권한을 부여합니다. | 
| [CloudWatchDescribeAlarmHistoryPolicy](serverless-policy-template-list.md#cloudwatch-describe-alarm-history-policy) | CloudWatch 경보 기록을 설명할 수 있는 권한을 부여합니다. | 
| [CloudWatchPutMetricPolicy](serverless-policy-template-list.md#cloudwatch-put-metric-policy) | CloudWatch에 지표를 전송할 수 있는 권한을 부여합니다. | 
| [CodeCommitCrudPolicy](serverless-policy-template-list.md#codecommit-crud-policy) | 특정 CodeCommit 리포지토리 내에서 객체를 생성/읽기/업데이트/삭제할 수 있는 권한을 부여합니다. | 
| [CodeCommitReadPolicy](serverless-policy-template-list.md#codecommit-read-policy) | 특정 CodeCommit 리포지토리 내에서 객체를 읽을 수 있는 권한을 부여합니다. | 
| [CodePipelineLambdaExecutionPolicy](serverless-policy-template-list.md#code-pipeline-lambda-execution-policy) | CodePipeline에서 간접 호출한 Lambda 함수가 작업 상태를 보고하도록 권한을 부여합니다. | 
| [CodePipelineReadOnlyPolicy](serverless-policy-template-list.md#code-pipeline-readonly-policy) | CodePipeline 파이프라인의 세부 정보를 가져올 수 있는 읽기 권한을 부여합니다. | 
| [ComprehendBasicAccessPolicy](serverless-policy-template-list.md#comprehend-basic-access-policy) | 엔터티, 핵심 문구, 언어 및 감정을 탐지할 수 있는 권한을 부여합니다. | 
| [CostExplorerReadOnlyPolicy](serverless-policy-template-list.md#cost-explorer-readonly-policy) | 청구 내역에 대한 읽기 전용 Cost Explorer API에 읽기 전용 권한을 부여합니다. | 
| [DynamoDBBackupFullAccessPolicy](serverless-policy-template-list.md#ddb-back-full-policy) | 테이블에 대한 DynamoDB 온디맨드 백업에 읽기 및 쓰기 권한을 부여합니다. | 
| [DynamoDBCrudPolicy](serverless-policy-template-list.md#dynamo-db-crud-policy) | Amazon DynamoDB 테이블에 생성, 읽기, 업데이트 및 삭제 권한을 부여합니다. | 
| [DynamoDBReadPolicy](serverless-policy-template-list.md#dynamo-db-read-policy) | DynamoDB 테이블에 읽기 전용 권한 부여 | 
| [DynamoDBReconfigurePolicy](serverless-policy-template-list.md#dynamo-db-reconfigure-policy) | DynamoDB 테이블을 재구성할 수 있는 권한을 부여합니다. | 
| [DynamoDBRestoreFromBackupPolicy](serverless-policy-template-list.md#ddb-restore-from-backup-policy) | 백업에서 테이블을 복원할 수 있는 권한을 부여합니다. | 
| [DynamoDBStreamReadPolicy](serverless-policy-template-list.md#dynamo-db-stream-read-policy) | DynamoDB 스트림과 레코드를 설명하고 읽을 수 있는 권한을 부여합니다. | 
| [DynamoDBWritePolicy](serverless-policy-template-list.md#dynamo-db-write-policy) | DynamoDB 테이블에 쓰기 전용 권한 부여 | 
| [EC2CopyImagePolicy](serverless-policy-template-list.md#ec2-copy-image-policy) | Amazon EC2 이미지를 복사할 수 있는 권한을 부여합니다. | 
| [EC2DescribePolicy](serverless-policy-template-list.md#ec2-describe-policy) | Amazon Elastic Compute Cloud(Amazon EC2) 인스턴스를 설명할 수 있는 권한을 부여합니다. | 
| [EcsRunTaskPolicy](serverless-policy-template-list.md#ecs-run-task-policy) | 태스크 정의에 대해 새 태스크를 시작할 수 있는 권한을 부여합니다. | 
| [EFSWriteAccessPolicy](serverless-policy-template-list.md#efs-write-access-policy) | 쓰기 액세스 권한이 있는 Amazon EFS 파일 시스템을 마운트할 수 있는 권한을 부여합니다. | 
| [EKSDescribePolicy](serverless-policy-template-list.md#eks-describe-policy) | Amazon EKS 클러스터를 설명하거나 나열할 수 있는 권한을 부여합니다. | 
| [ElasticMapReduceAddJobFlowStepsPolicy](serverless-policy-template-list.md#elastic-map-reduce-add-job-flows-policy) | 실행 중인 클러스터에 새 단계를 추가할 수 있는 권한을 부여합니다. | 
| [ElasticMapReduceCancelStepsPolicy](serverless-policy-template-list.md#elastic-map-reduce-cancel-steps-policy) | 실행 중인 클러스터에서 대기 중 단계를 취소할 수 있는 권한을 부여합니다. | 
| [ElasticMapReduceModifyInstanceFleetPolicy](serverless-policy-template-list.md#elastic-map-reduce-modify-instance-fleet-policy) | 클러스터 내 인스턴스 플릿의 세부 정보를 나열하고 용량을 수정할 수 있는 권한을 부여합니다. | 
| [ElasticMapReduceModifyInstanceGroupsPolicy](serverless-policy-template-list.md#elastic-map-reduce-modify-instance-groups-policy) | 클러스터 내 인스턴스 그룹의 세부 정보를 나열하고 설정을 수정할 수 있는 권한을 부여합니다. | 
| [ElasticMapReduceSetTerminationProtectionPolicy](serverless-policy-template-list.md#elastic-map-reduce-set-termination-protection-policy) | 클러스터에 대한 종료 보호를 설정할 수 있는 권한을 부여합니다. | 
| [ElasticMapReduceTerminateJobFlowsPolicy](serverless-policy-template-list.md#elastic-map-reduce-terminate-job-flows-policy) | 클러스터를 종료할 수 있는 권한을 부여합니다. | 
| [ElasticsearchHttpPostPolicy](serverless-policy-template-list.md#elastic-search-http-post-policy) | Amazon OpenSearch Service에 POST 권한을 부여합니다. | 
| [EventBridgePutEventsPolicy](serverless-policy-template-list.md#eventbridge-put-events-policy) | EventBridge로 이벤트를 보낼 수 있는 권한을 부여합니다. | 
| [FilterLogEventsPolicy](serverless-policy-template-list.md#filter-log-events-policy) | 지정된 로그 그룹에서 CloudWatch Logs 이벤트를 필터링할 수 있는 권한을 부여합니다. | 
| [FirehoseCrudPolicy](serverless-policy-template-list.md#firehose-crud-policy) | Firehose 전송 스트림을 생성, 쓰기, 업데이트 및 삭제할 수 있는 권한을 부여합니다. | 
| [FirehoseWritePolicy](serverless-policy-template-list.md#firehose-write-policy) | Firehose 전송 스트림에 쓸 수 있는 권한을 부여합니다. | 
| [KinesisCrudPolicy](serverless-policy-template-list.md#kinesis-crud-policy) | Amazon Kinesis 스트림을 생성, 게시 및 삭제할 수 있는 권한을 부여합니다. | 
| [KinesisStreamReadPolicy](serverless-policy-template-list.md#kinesis-stream-read-policy) | Amazon Kinesis 스트림을 나열하고 읽을 수 있는 권한을 부여합니다. | 
| [KMSDecryptPolicy](serverless-policy-template-list.md#kms-decrypt-policy) |  AWS Key Management Service (AWS KMS) 키를 사용하여 복호화할 수 있는 권한을 부여합니다. | 
| [KMSEncryptPolicy](serverless-policy-template-list.md#kms-encrypt-policy) |  AWS Key Management Service (AWS KMS) 키로 암호화할 수 있는 권한을 부여합니다. | 
| [LambdaInvokePolicy](serverless-policy-template-list.md#lambda-invoke-policy) |  AWS Lambda 함수, 별칭 또는 버전을 호출할 수 있는 권한을 부여합니다. | 
| [MobileAnalyticsWriteOnlyAccessPolicy](serverless-policy-template-list.md#mobile-analytics-write-only-access-policy) | 모든 애플리케이션 리소스에 이벤트 데이터를 넣을 수 있는 쓰기 전용 권한을 부여합니다. | 
| [OrganizationsListAccountsPolicy](serverless-policy-template-list.md#organizations-list-accounts-policy) | 하위 계정 이름 및 ID를 나열할 수 있는 읽기 전용 권한을 부여합니다. | 
| [PinpointEndpointAccessPolicy](serverless-policy-template-list.md#pinpoint-endpoint-access-policy) | Amazon Pinpoint 애플리케이션의 엔드포인트를 가져오고 업데이트할 수 있는 권한을 부여합니다. | 
| [PollyFullAccessPolicy](serverless-policy-template-list.md#polly-full-access-policy) | Amazon Polly 어휘 리소스에 대한 전체 액세스 권한을 부여합니다. | 
| [RekognitionDetectOnlyPolicy](serverless-policy-template-list.md#rekognition-detect-only-policy) | 얼굴, 레이블, 텍스트를 감지할 수 있는 권한을 부여합니다. | 
| [RekognitionFacesManagementPolicy](serverless-policy-template-list.md#rekognition-face-management-policy) | Amazon Rekognition 컬렉션에서 얼굴을 추가, 삭제 및 검색할 수 있는 권한을 부여합니다. | 
| [RekognitionFacesPolicy](serverless-policy-template-list.md#rekognition-faces-policy) | 얼굴과 레이블을 비교하고 감지할 수 있는 권한을 부여합니다. | 
| [RekognitionLabelsPolicy](serverless-policy-template-list.md#rekognition-labels-policy) | 객체 및 중재 레이블을 탐지할 수 있는 권한을 부여합니다. | 
| [RekognitionNoDataAccessPolicy](serverless-policy-template-list.md#rekognition-no-data-access-policy) | 얼굴과 레이블을 비교하고 감지할 수 있는 권한을 부여합니다. | 
| [RekognitionReadPolicy](serverless-policy-template-list.md#rekognition-read-policy) | 얼굴을 나열하고 검색할 수 있는 권한을 부여합니다. | 
| [RekognitionWriteOnlyAccessPolicy](serverless-policy-template-list.md#rekognition-write-only-access-policy) | 얼굴을 모으고 인덱싱할 수 있는 권한을 부여합니다. | 
| [Route53ChangeResourceRecordSetsPolicy](serverless-policy-template-list.md#route53-change-resource-record-sets-policy) | Route 53에서 리소스 레코드 세트를 변경할 수 있는 권한을 부여합니다. | 
| [S3CrudPolicy](serverless-policy-template-list.md#s3-crud-policy) | Amazon S3 버킷의 객체에 대해 작업을 수행할 수 있는 생성, 읽기, 업데이트 및 삭제 권한을 부여합니다. | 
| [S3FullAccessPolicy](serverless-policy-template-list.md#s3-full-access-policy) | Amazon S3 버킷의 객체에 대해 작업을 수행할 수 있는 전체 액세스 권한을 부여합니다. | 
| [S3ReadPolicy](serverless-policy-template-list.md#s3-read-policy) | Amazon Simple Storage Service(S3) 버킷에 있는 객체를 읽을 수 있는 읽기 전용 권한을 부여합니다. | 
| [S3WritePolicy](serverless-policy-template-list.md#s3-write-policy) | Amazon S3 버킷에 객체를 쓸 수 있는 쓰기 권한을 부여합니다. | 
| [SageMakerCreateEndpointConfigPolicy](serverless-policy-template-list.md#sagemaker-create-endpoint-config-policy) | SageMaker AI에서 엔드포인트 구성을 생성할 수 있는 권한을 부여합니다. | 
| [SageMakerCreateEndpointPolicy](serverless-policy-template-list.md#sagemaker-create-endpoint-policy) | SageMaker AI에서 엔드포인트를 생성할 수 있는 권한을 부여합니다. | 
| [ServerlessRepoReadWriteAccessPolicy](serverless-policy-template-list.md#serverlessrepo-read-write-access-policy) |  AWS Serverless Application Repository 서비스에서 애플리케이션을 생성하고 나열할 수 있는 권한을 부여합니다. | 
| [SESBulkTemplatedCrudPolicy](serverless-policy-template-list.md#ses-bulk-templated-crud-policy) | 이메일, 템플릿 이메일, 템플릿 대량 이메일을 보내고 자격 증명을 확인할 수 있는 권한을 부여합니다. | 
| [SESBulkTemplatedCrudPolicy\$1v2](serverless-policy-template-list.md#ses-bulk-templated-crud-policy-v2) | Amazon SES 이메일, 템플릿 기반 이메일, 템플릿 형식의 대량 이메일을 보내고 ID를 확인할 수 있는 권한을 부여합니다. | 
| [SESCrudPolicy](serverless-policy-template-list.md#ses-crud-policy) | 이메일을 보내고 ID를 확인할 수 있는 권한을 부여합니다. | 
| [SESEmailTemplateCrudPolicy](serverless-policy-template-list.md#ses-email-template-crud-policy) | Amazon SES 이메일 템플릿을 만들고, 가져오고, 나열하고, 업데이트하고, 삭제할 수 있는 권한을 부여합니다. | 
| [SESSendBouncePolicy](serverless-policy-template-list.md#ses-send-bounce-policy) | Amazon Simple Email Service(Amazon SES) ID에 대한 SendBounce 권한을 부여합니다. | 
| [SNSCrudPolicy](serverless-policy-template-list.md#sns-crud-policy) | Amazon SNS 주제를 만들고, 게시하고, 구독할 수 있는 권한을 부여합니다. | 
| [SNSPublishMessagePolicy](serverless-policy-template-list.md#sqs-publish-message-policy) | Amazon Simple Notification Service(Amazon SNS) 주제에 이벤트 메시지 게시 | 
| [SQSPollerPolicy](serverless-policy-template-list.md#sqs-poller-policy) | Amazon Simple Queue Service(Amazon SQS) 대기열을 폴링할 수 있는 권한을 부여합니다. | 
| [SQSSendMessagePolicy](serverless-policy-template-list.md#sqs-send-message-policy) | Amazon SQS 대기열에 메시지를 보낼 수 있는 권한을 부여합니다. | 
| [SSMParameterReadPolicy](serverless-policy-template-list.md#ssm-parameter-read-policy) | Amazon EC2 Systems Manager(SSM) 파라미터 스토어의 파라미터에 액세스하여 이 계정에 보안 암호를 로드할 수 있는 권한을 부여합니다. 파라미터 이름에 슬래시 접두사가 없을 때 사용합니다. | 
| [SSMParameterWithSlashPrefixReadPolicy](serverless-policy-template-list.md#ssm-parameter-slash-read-policy) | Amazon EC2 Systems Manager(SSM) 파라미터 스토어의 파라미터에 액세스하여 이 계정에 보안 암호를 로드할 수 있는 권한을 부여합니다. 파라미터 이름에 슬래시 접두사가 있는 경우 사용합니다. | 
| [StepFunctionsExecutionPolicy](serverless-policy-template-list.md#stepfunctions-execution-policy) | Step Functions 상태 머신 실행을 시작하기 위해 권한을 제공합니다. | 
| [TextractDetectAnalyzePolicy](serverless-policy-template-list.md#textract-detect-analyze-policy) | Amazon Textract를 사용하여 문서를 탐지하고 분석할 수 있는 액세스 권한을 제공합니다. | 
| [TextractGetResultPolicy](serverless-policy-template-list.md#textract-get-result-policy) | Amazon Textract에서 문서를 탐지하고 분석할 수 있는 액세스 권한을 제공합니다. | 
| [TextractPolicy](serverless-policy-template-list.md#textract-policy) | Amazon Textract에 대한 모든 액세스 권한을 부여합니다. | 
| [VPCAccessPolicy](serverless-policy-template-list.md#vpc-access-policy) | 탄력적 네트워크 인터페이스를 생성, 삭제, 설명 및 분리할 수 있는 액세스 권한을 제공합니다. | 

## 문제 해결
<a name="serverless-policy-template-troubleshooting"></a>

### SAM CLI error: "Must specify valid parameter values for policy template '<policy-template-name>'"
<a name="serverless-policy-template-troubleshooting-"></a>

`sam build`를 실행하면 다음 오류가 표시됩니다.

```
"Must specify valid parameter values for policy template '<policy-template-name>'"
```

즉, 자리 표시자 값이 없는 정책 템플릿을 선언할 때 빈 객체를 전달하지 않았습니다.

이 문제를 해결하려면 다음 [CloudWatchPutMetricPolicy](serverless-policy-template-list.md#cloudwatch-put-metric-policy) 예제와 같이 정책을 선언합니다.

```
1. MyFunction:
2.   Policies:
3.     - CloudWatchPutMetricPolicy: {}
```