

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

# CodeDeploy의 애플리케이션 개정 작업
<a name="application-revisions"></a>

CodeDeploy에서 개정에는 CodeDeploy가 인스턴스에 배포할 소스 파일 또는 CodeDeploy가 인스턴스에서 실행할 스크립트 버전이 포함됩니다.

개정을 계획하고 개정에 AppSpec 파일을 추가한 다음 개정을 Amazon S3 또는 GitHub에 푸시합니다. 개정을 푸시하고 나면 이제 버전을 배포할 수 있습니다.

**Topics**
+ [개정 계획](application-revisions-plan.md)
+ [AppSpec 파일 추가](application-revisions-appspec-file.md)
+ [리포지토리 유형 선택](application-revisions-repository-type.md)
+ [개정 푸시](application-revisions-push.md)
+ [애플리케이션 개정 세부 정보 보기](application-revisions-view-details.md)
+ [애플리케이션 개정 등록](application-revisions-register.md)

# CodeDeploy의 개정 계획
<a name="application-revisions-plan"></a>

계획을 세우면 개정판을 훨씬 쉽게 배포할 수 있습니다.

AWS Lambda 또는 Amazon ECS 컴퓨팅 플랫폼에 배포하는 경우 개정판은 AppSpec 파일과 동일합니다. 다음 정보는 적용되지 않습니다. 자세한 내용은 [CodeDeploy에 대한 개정에 애플리케이션 사양 파일 추가](application-revisions-appspec-file.md)을(를) 참조하세요.

EC2/온프레미스 컴퓨팅 플랫폼에 배포하려면 먼저 개발 시스템에 빈 루트 디렉토리(폴더)를 생성합니다. 여기서 인스턴스에 배포될 소스 파일(예: 텍스트 및 이진 파일, 실행 파일, 패키지 등) 또는 인스턴스에서 실행될 스크립트를 저장합니다.

예: Linux, macOS, Unix의 경우 `/tmp/` 루트 폴더 또는 Windows의 경우 `c:\temp` 루트 폴더

```
/tmp/ or c:\temp (root folder)
  |--content (subfolder)
  |    |--myTextFile.txt
  |    |--mySourceFile.rb
  |    |--myExecutableFile.exe
  |    |--myInstallerFile.msi
  |    |--myPackage.rpm
  |    |--myImageFile.png
  |--scripts (subfolder)
  |    |--myShellScript.sh
  |    |--myBatchScript.bat 
  |    |--myPowerShellScript.ps1 
  |--appspec.yml
```

루트 폴더에는 다음과 같이 애플리케이션 사양 파일(AppSpec 파일)도 포함되어야 합니다. 자세한 내용은 [CodeDeploy에 대한 개정에 애플리케이션 사양 파일 추가](application-revisions-appspec-file.md) 섹션을 참조하세요.

# CodeDeploy에 대한 개정에 애플리케이션 사양 파일 추가
<a name="application-revisions-appspec-file"></a>

이 주제에서는 AppSpec 파일을 배포에 추가하는 방법을 살펴봅니다. 또한 AWS Lambda 및 EC2/온프레미스 배포를 위한 AppSpec 파일을 생성하는 템플릿도 포함되어 있습니다.

**Topics**
+ [Amazon ECS 배포용 AppSpec 파일 추가](#add-appspec-file-ecs)
+ [AWS Lambda 배포를 위한 AppSpec 파일 추가](#add-appspec-file-lambda)
+ [EC2 온프레미스 배포용 AppSpec 파일 추가](#add-appspec-file-server)

## Amazon ECS 배포용 AppSpec 파일 추가
<a name="add-appspec-file-ecs"></a>

Amazon ECS 컴퓨팅 플랫폼에 배포하는 경우:
+ AppSpec 파일은 배포에 사용되는 Amazon ECS 작업 정의, 트래픽을 라우팅하는 데 사용되는 포트 매핑과 컨테이너 이름, 배포 수명 주기 이벤트 후 실행되는 Lambda 함수 옵션을 지정합니다.
+ 개정은 AppSpec 파일과 동일합니다.
+ APSpec 파일은 JSON 또는 YAML을 사용하여 작성할 수 있습니다.
+ AppSpec 파일은 텍스트 파일로 저장하거나 배포를 만들 때 콘솔에 직접 입력할 수 있습니다. 자세한 내용은 [Amazon ECS 컴퓨팅 플랫폼에 대한 배포 생성(콘솔)](deployments-create-console-ecs.md) 단원을 참조하세요.

**AppSpec 파일을 만들려면**

1. JSON 또는 YAML 템플릿을 텍스트 편집기에 복사하거나 콘솔의 AppSpec 편집기에 복사합니다.

1. 필요에 따라 템플릿을 수정합니다.

1. JSON 또는 YAML 유효성 검사기를 사용하여 AppSpec 파일을 검증합니다. AppSpec 편집기를 사용하는 경우 **배포 만들기**를 선택할 때 파일이 검증됩니다.

1. 텍스트 편집기를 사용하는 경우 파일을 저장합니다. 를 사용하여 배포 AWS CLI 를 생성하는 경우 AppSpec 파일이 하드 드라이브 또는 Amazon S3 버킷에 있는 경우 해당 파일을 참조하세요. 콘솔을 사용하는 경우 AppSpec 파일을 Amazon S3로 푸시해야 합니다.

### 지침이 포함된 Amazon ECS 배포용 YAML AppSpec 파일 템플릿
<a name="app-spec-template-yaml-ecs"></a>

다음은 사용 가능한 모든 옵션이 포함된 Amazon ECS 배포용 AppSpec 파일의 YAML 템플릿입니다. `hooks` 섹션에서 사용할 수명 주기 이벤트에 대한 자세한 내용은 [Amazon ECS 배포를 위한 AppSpec 'hooks' 섹션](reference-appspec-file-structure-hooks.md#appspec-hooks-ecs)을(를) 참조하세요.

```
# This is an appspec.yml template file for use with an Amazon ECS deployment in CodeDeploy.
# The lines in this template that start with the hashtag are 
#   comments that can be safely left in the file or 
#   ignored.
# For help completing this file, see the "AppSpec File Reference" in the  
#   "CodeDeploy User Guide" at
#   https://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html
version: 0.0
# In the Resources section, you must specify the following: the Amazon ECS service, task definition name, 
# and the name and port of the load balancer to route traffic,
# target version, and (optional) the current version of your AWS Lambda function. 
Resources:
  - TargetService:
      Type: AWS::ECS::Service
      Properties:
        TaskDefinition: "" # Specify the ARN of your task definition (arn:aws:ecs:region:account-id:task-definition/task-definition-family-name:task-definition-revision-number)
        LoadBalancerInfo: 
          ContainerName: "" # Specify the name of your Amazon ECS application's container
          ContainerPort: "" # Specify the port for your container where traffic reroutes 
# Optional properties
        PlatformVersion: "" # Specify the version of your Amazon ECS Service
        NetworkConfiguration:
          AwsvpcConfiguration:
            Subnets: ["",""] # Specify one or more comma-separated subnets in your Amazon ECS service
            SecurityGroups: ["",""] # Specify one or more comma-separated security groups in your Amazon ECS service
            AssignPublicIp: "" # Specify "ENABLED" or "DISABLED"             
# (Optional) In the Hooks section, specify a validation Lambda function to run during 
# a lifecycle event. 
Hooks:
# Hooks for Amazon ECS deployments are:
    - BeforeInstall: "" # Specify a Lambda function name or ARN
    - AfterInstall: "" # Specify a Lambda function name or ARN
    - AfterAllowTestTraffic: "" # Specify a Lambda function name or ARN
    - BeforeAllowTraffic: "" # Specify a Lambda function name or ARN
    - AfterAllowTraffic: "" # Specify a Lambda function name or ARN
```

### Amazon ECS 배포용 JSON AppSpec 파일 템플릿
<a name="app-spec-template-json-ecs"></a>

다음은 사용 가능한 모든 옵션이 포함된 Amazon ECS 배포용 AppSpec 파일의 JSON 템플릿입니다. 템플릿 지침은 이전 섹션의 YAML 버전에 있는 설명을 참조하세요. `hooks` 섹션에서 사용할 수명 주기 이벤트에 대한 자세한 내용은 [Amazon ECS 배포를 위한 AppSpec 'hooks' 섹션](reference-appspec-file-structure-hooks.md#appspec-hooks-ecs)을(를) 참조하세요.

```
{
	"version": 0.0,
	"Resources": [
		{
			"TargetService": {
				"Type": "AWS::ECS::Service",
				"Properties": {
    			"TaskDefinition": "",
    			"LoadBalancerInfo": {
    				"ContainerName": "",
    				"ContainerPort":
    			},
    			"PlatformVersion": "",
    			"NetworkConfiguration": {
    				"AwsvpcConfiguration": {
    					"Subnets": [
    						"",
    						""
    					],
    					"SecurityGroups": [
    						"",
    						""
    					],
    					"AssignPublicIp": ""
    				}
    			}
  			}				
			}
		}
	],
	"Hooks": [
		{
			"BeforeInstall": ""
		},
		{
			"AfterInstall": ""
		},
		{
			"AfterAllowTestTraffic": ""
		},
		{
			"BeforeAllowTraffic": ""
		},
		{
			"AfterAllowTraffic": ""
		}
	]
}
```

## AWS Lambda 배포를 위한 AppSpec 파일 추가
<a name="add-appspec-file-lambda"></a>

 AWS Lambda 컴퓨팅 플랫폼에 배포하는 경우:
+ AppSpec 파일에는 배포되고 배포 유효성 검사에 사용할 Lambda 함수에 대한 지침이 포함되어 있습니다.
+ 개정은 AppSpec 파일과 동일합니다.
+ APSpec 파일은 JSON 또는 YAML을 사용하여 작성할 수 있습니다.
+ AppSpec 파일을 텍스트 파일로 저장할 수도 있고 배포 생성 시 콘솔 AppSpec 편집기에 직접 입력할 수도 있습니다. 자세한 내용은 [AWS Lambda 컴퓨팅 플랫폼 배포 생성(콘솔)](deployments-create-console-lambda.md) 단원을 참조하세요.

AppSpec 파일을 만들려면:

1. JSON 또는 YAML 템플릿을 텍스트 편집기에 복사하거나 콘솔의 AppSpec 편집기에 복사합니다.

1. 필요에 따라 템플릿을 수정합니다.

1. JSON 또는 YAML 유효성 검사기를 사용하여 AppSpec 파일을 검증합니다. AppSpec 편집기를 사용하는 경우 **배포 만들기**를 선택할 때 파일이 검증됩니다.

1. 텍스트 편집기를 사용하는 경우 파일을 저장합니다. 를 사용하여 배포 AWS CLI 를 생성하는 경우 AppSpec 파일이 하드 드라이브 또는 Amazon S3 버킷에 있는 경우 해당 파일을 참조하세요. 콘솔을 사용하는 경우 AppSpec 파일을 Amazon S3로 푸시해야 합니다.



### 지침이 포함된 AWS Lambda 배포용 YAML AppSpec 파일 템플릿
<a name="app-spec-template-yaml-lambda"></a>

후크 섹션에서 사용할 수명 주기 이벤트에 대한 자세한 내용은 [AWS Lambda 배포를 위한 AppSpec 'hooks' 섹션](reference-appspec-file-structure-hooks.md#appspec-hooks-lambda)을(를) 참조하세요.

```
# This is an appspec.yml template file for use with an AWS Lambda deployment in CodeDeploy.
# The lines in this template starting with the hashtag symbol are 
#   instructional comments and can be safely left in the file or 
#   ignored.
# For help completing this file, see the "AppSpec File Reference" in the  
#   "CodeDeploy User Guide" at
#   https://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html
version: 0.0
# In the Resources section specify the name, alias, 
# target version, and (optional) the current version of your AWS Lambda function. 
Resources:
  - MyFunction: # Replace "MyFunction" with the name of your Lambda function 
      Type: AWS::Lambda::Function
      Properties:
        Name: "" # Specify the name of your Lambda function
        Alias: "" # Specify the alias for your Lambda function
        CurrentVersion: "" # Specify the current version of your Lambda function
        TargetVersion: "" # Specify the version of your Lambda function to deploy
# (Optional) In the Hooks section, specify a validation Lambda function to run during 
# a lifecycle event. Replace "LifeCycleEvent" with BeforeAllowTraffic
# or AfterAllowTraffic. 
Hooks:
    - LifeCycleEvent: "" # Specify a Lambda validation function between double-quotes.
```

### AWS Lambda 배포 템플릿용 JSON AppSpec 파일
<a name="app-spec-template-json-lambda"></a>

다음 템플릿에서 “MyFunction”을 AWS Lambda 함수 이름으로 바꿉니다. 후크 옵션 섹션에서 수명 주기 이벤트를 BeforeAllowTraffic 또는 AfterAllowTraffic으로 바꿉니다.

후크 섹션에서 사용할 수명 주기 이벤트에 대한 자세한 내용은 [AWS Lambda 배포를 위한 AppSpec 'hooks' 섹션](reference-appspec-file-structure-hooks.md#appspec-hooks-lambda)을(를) 참조하세요.

```
{
 	"version": 0.0,
 	"Resources": [{
 		"MyFunction": {
 			"Type": "AWS::Lambda::Function",
 			"Properties": {
 				"Name": "",
 				"Alias": "",
 				"CurrentVersion": "",
 				"TargetVersion": ""
 			}
 		}
 	}],
 	"Hooks": [{
 			"LifeCycleEvent": ""
 		}
 	]
 }
```

## EC2 온프레미스 배포용 AppSpec 파일 추가
<a name="add-appspec-file-server"></a>

AppSpec 파일이 없으면 CodeDeploy는 애플리케이션 개정의 소스 파일을 대상에 매핑하거나 EC2/온프레미스 컴퓨팅 플랫폼에 배포하기 위한 스크립트를 실행할 수 없습니다.

각 개정에는 AppSpec 파일을 하나만 포함해야 합니다.

개정에 AppSpec 파일을 추가하려면:

1. 템플릿을 텍스트 편집기에 복사합니다.

1. 필요에 따라 템플릿을 수정합니다.

1. YAML 유효성 검사기를 사용하여 AppSpec 파일을 검증합니다.

1. 파일을 개정의 루트 디렉터리에 `appspec.yml`로 저장합니다.

1. AppSpec 파일을 루트 디렉터리에 저장했는지 확인하려면 다음 명령 중 하나를 실행합니다.
   + Linux, macOS 또는 Unix의 경우:

     ```
     find /path/to/root/directory -name appspec.yml
     ```

     AppSpec 파일을 찾을 수 없으면 출력이 없습니다.
   + Windows의 경우:

     ```
     dir path\to\root\directory\appspec.yml
     ```

     AppSpec 파일이 저장되지 않은 경우 **파일을 찾을 수 없음** 오류가 표시됩니다.

1. 개정을 Amazon S3 또는 GitHub에 푸시합니다.

   지침은 [Amazon S3에 CodeDeploy의 개정 푸시(EC2 온프레미스 배포 전용)](application-revisions-push.md) 단원을 참조하세요.

### 지침이 포함된 EC2 온프레미스 배포용 AppSpec 파일 템플릿
<a name="app-spec-template-server"></a>

**참고**  
 Windows Server 인스턴스에 배포하는 기능은 `runas` 요소를 지원하지 않습니다. Windows Server 인스턴스를 배포하고 있다면 이 요소를 AppSpec 파일에 포함하지 마세요.

```
# This is an appspec.yml template file for use with an EC2/On-Premises deployment in CodeDeploy.
# The lines in this template starting with the hashtag symbol are 
#   instructional comments and can be safely left in the file or 
#   ignored.
# For help completing this file, see the "AppSpec File Reference" in the  
#   "CodeDeploy User Guide" at
#   https://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html
version: 0.0
# Specify "os: linux" if this revision targets Amazon Linux, 
#   Red Hat Enterprise Linux (RHEL), or Ubuntu Server  
#   instances.
# Specify "os: windows" if this revision targets Windows Server instances.
# (You cannot specify both "os: linux" and "os: windows".)
os: linux 
# os: windows
# During the Install deployment lifecycle event (which occurs between the 
#   BeforeInstall and AfterInstall events), copy the specified files 
#   in "source" starting from the root of the revision's file bundle 
#   to "destination" on the Amazon EC2 instance.
# Specify multiple "source" and "destination" pairs if you want to copy 
#   from multiple sources or to multiple destinations.
# If you are not copying any files to the Amazon EC2 instance, then remove the
#   "files" section altogether. A blank or incomplete "files" section
#   may cause associated deployments to fail.
files:
  - source: 
    destination:
  - source:
    destination:
# For deployments to Amazon Linux, Ubuntu Server, or RHEL instances,
#   you can specify a "permissions" 
#   section here that describes special permissions to apply to the files 
#   in the "files" section as they are being copied over to 
#   the Amazon EC2 instance.
#   For more information, see the documentation.
# If you are deploying to Windows Server instances,
#   then remove the 
#   "permissions" section altogether. A blank or incomplete "permissions"
#   section may cause associated deployments to fail.
permissions:
  - object:
    pattern:
    except:
    owner:
    group:
    mode: 
    acls:
      -
    context:
      user:
      type:
      range:
    type:
      -
# If you are not running any commands on the Amazon EC2 instance, then remove 
#   the "hooks" section altogether. A blank or incomplete "hooks" section
#   may cause associated deployments to fail.
hooks:
# For each deployment lifecycle event, specify multiple "location" entries 
#   if you want to run multiple scripts during that event.
# You can specify "timeout" as the number of seconds to wait until failing the deployment 
#   if the specified scripts do not run within the specified time limit for the 
#   specified event. For example, 900 seconds is 15 minutes. If not specified, 
#   the default is 1800 seconds (30 minutes).
#   Note that the maximum amount of time that all scripts must finish executing 
#   for each individual deployment lifecycle event is 3600 seconds (1 hour). 
#   Otherwise, the deployment will stop and CodeDeploy will consider the deployment
#   to have failed to the Amazon EC2 instance. Make sure that the total number of seconds 
#   that are specified in "timeout" for all scripts in each individual deployment 
#   lifecycle event does not exceed a combined 3600 seconds (1 hour).
# For deployments to Amazon Linux, Ubuntu Server, or RHEL instances,
#   you can specify "runas" in an event to
#   run as the specified user. For more information, see the documentation.
#   If you are deploying to Windows Server instances,
#   remove "runas" altogether.
# If you do not want to run any commands during a particular deployment
#   lifecycle event, remove that event declaration altogether. Blank or 
#   incomplete event declarations may cause associated deployments to fail.
# During the ApplicationStop deployment lifecycle event, run the commands 
#   in the script specified in "location" starting from the root of the 
#   revision's file bundle.
  ApplicationStop:
    - location: 
      timeout:
      runas:
    - location: 
      timeout:
      runas: 
# During the BeforeInstall deployment lifecycle event, run the commands 
#   in the script specified in "location".
  BeforeInstall:
    - location: 
      timeout:
      runas: 
    - location: 
      timeout:
      runas:
# During the AfterInstall deployment lifecycle event, run the commands 
#   in the script specified in "location".
  AfterInstall:
    - location:     
      timeout: 
      runas:
    - location: 
      timeout:
      runas:
# During the ApplicationStart deployment lifecycle event, run the commands 
#   in the script specified in "location".
  ApplicationStart:
    - location:     
      timeout: 
      runas:
    - location: 
      timeout:
      runas:
# During the ValidateService deployment lifecycle event, run the commands 
#   in the script specified in "location".
  ValidateService:
    - location:     
      timeout: 
      runas:
    - location: 
      timeout:
      runas:
```

# CodeDeploy 리포지토리 유형 선택
<a name="application-revisions-repository-type"></a>

CodeDeploy에서 필요한 파일의 저장소를 *리포지토리*라고 합니다. 리포지토리 사용은 해당 배포에서 어떤 컴퓨팅 플랫폼을 사용하는지에 따라 다릅니다.
+ **EC2/온프레미스**: 하나 이상의 인스턴스에 애플리케이션 코드를 배포하려면 코드를 아카이브 파일로 번들링하여 배포 프로세스 중에 액세스할 수 있는 리포지토리에 배치해야 합니다. 배포형 콘텐츠와 AppSpec 파일을 아카이브 파일로 번들링한 다음 CodeDeploy에서 지원하는 리포지토리 유형 중 하나로 업로드합니다.
+ **AWS Lambda** 및 **Amazon ECS**: 배포에는 AppSpec 파일이 필요하며, 이러한 파일은 배포 과정에서 다음 방법 중 하나를 사용하여 액세스할 수 있습니다.
  +  Amazon S3 버킷에서 액세스.
  +  콘솔의 AppSpec 편집기에 직접 입력된 텍스트에서 액세스. 자세한 내용은 [AWS Lambda 컴퓨팅 플랫폼 배포 생성(콘솔)](deployments-create-console-lambda.md) 및 [Amazon ECS 컴퓨팅 플랫폼에 대한 배포 생성(콘솔)](deployments-create-console-ecs.md) 단원을 참조하세요.
  +  AWS CLI을(를) 사용하는 경우 하드 드라이브나 네트워크 드라이브에 있는 AppSpec 파일을 참조할 수 있습니다. 자세한 내용은 [AWS Lambda 컴퓨팅 플랫폼 배포 생성(CLI)](deployments-create-lambda-cli.md) 및 [Amazon ECS 컴퓨팅 플랫폼에 대한 배포 생성(CLI)](deployments-create-ecs-cli.md) 단원을 참조하세요.

CodeDeploy는 현재 다음 리포지토리 유형을 지원합니다.


|  |  |  | 
| --- |--- |--- |
| 리포지토리 유형 | 리포지토리 세부 정보 | 지원되는 컴퓨팅 플랫폼 | 
| Amazon S3() | [Amazon Simple Storage Service](https://docs.aws.amazon.com/AmazonS3/latest/userguide/)(Amazon S3)는 안전하고 확장 가능한 객체 스토리지를 위한 AWS 솔루션입니다. Amazon S3는 데이터를 버킷 내에 객체로 저장합니다. 객체는 파일과 해당 파일을 설명하는 메타데이터(선택 사항)로 구성됩니다.Amazon S3에 객체를 저장하려면 파일을 버킷에 업로드합니다. 파일을 업로드하면 객체에 대해 권한 및 메타데이터를 설정할 수 있습니다.자세히 알아보기: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/codedeploy/latest/userguide/application-revisions-repository-type.html) | 다음 컴퓨팅 플랫폼을 사용하는 배포는 Amazon S3 버킷에 개정을 저장할 수 있습니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/codedeploy/latest/userguide/application-revisions-repository-type.html) | 
| GitHub | [GitHub](http://www.github.com) 리포지토리에 애플리케이션 개정을 저장할 수 있습니다. GitHub 리포지토리의 소스 코드가 변경될 때마다 GitHub 리포지토리에서 배포를 트리거할 수 있습니다.자세히 알아보기:[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/codedeploy/latest/userguide/application-revisions-repository-type.html) | EC2/온프레미스 배포만 GitHub 리포지토리에 개정을 저장할 수 있습니다. | 
| Bitbucket |  [Bitbucket 파이프라인](https://bitbucket.org/product/features/pipelines)에서 [CodeDeploy 파이프](https://bitbucket.org/product/features/pipelines/integrations?p=atlassian/aws-code-deploy)를 사용하여 EC2 인스턴스의 배포 그룹에 코드를 배포할 수 있습니다. Bitbucket 파이프라인은 [Bitbucket 배포](https://confluence.atlassian.com/bitbucket/bitbucket-deployments-940695276.html)를 포함한 지속적인 통합 및 지속적인 배포(CI/CD) 기능을 제공합니다. CodeDeploy 파이프는 먼저 사용자가 지정한 S3 버킷에 Artifact를 푸시한 다음 버킷에서 코드 Artifact를 배포합니다. 자세히 알아보기:  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/codedeploy/latest/userguide/application-revisions-repository-type.html)  | EC2/온프레미스 배포만 BitBucket 리포지토리에 개정을 저장할 수 있습니다. | 

**참고**  
AWS Lambda 배포는 Amazon S3 리포지토리에만 수행할 수 있습니다.

# Amazon S3에 CodeDeploy의 개정 푸시(EC2 온프레미스 배포 전용)
<a name="application-revisions-push"></a>

[CodeDeploy의 개정 계획](application-revisions-plan.md)에서 설명한 대로 개정을 계획하고 [CodeDeploy에 대한 개정에 애플리케이션 사양 파일 추가](application-revisions-appspec-file.md)에 설명한 대로 개정에 AppSpec 파일을 추가하면 구성 요소 파일을 번들로 묶고 개정을 Amazon S3로 푸시할 준비가 되었습니다. Amazon EC2 인스턴스에 배포하는 경우 개정을 푸시한 후 CodeDeploy를 사용하여 Amazon S3 에서 인스턴스로 개정을 배포할 수 있습니다.

**참고**  
CodeDeploy를 사용하여 GitHub에 푸시된 개정을 배포할 수도 있습니다. 자세한 내용은 GitHub 문서를 참조하세요.

 AWS CLI을(를) 설정하기 위해 [CodeDeploy 시작하기](getting-started-codedeploy.md)의 지침을 이미 따른 것으로 가정합니다. 이는 특히 추후에 설명되는 **push** 명령을 호출하는 데 중요합니다.

Amazon S3 버킷이 있는지 확인합니다. [버킷 생성](https://docs.aws.amazon.com/AmazonS3/latest/userguide/CreatingABucket.html)의 지침을 따릅니다.

Amazon EC2 인스턴스에 배포하는 경우 대상 Amazon S3 버킷을 생성하거나 대상 인스턴스와 동일한 리전에 있어야 합니다. 예를 들어 미국 동부(버지니아 북부) 리전에 있는 일부 인스턴스와 미국 서부(오레곤) 리전에 있는 다른 인스턴스에 개정을 배포하려면 미국 동부(버지니아 북부) 리전에 하나의 버킷과 개정 사본이 있어야 하고 미국 서부(오레곤) 리전에 또 다른 버킷과 동일 개정 사본이 있어야 합니다. 이 시나리오에서는 리전 및 버킷 모두에서 개정이 동일하더라도 미국 동부(버지니아 북부) 리전과 미국 서부(오레곤) 리전에 하나씩 두 개의 개별 배포를 만들어야 합니다.

또한 Amazon S3 버킷으로 업로드할 수 있는 권한이 있어야 합니다. Amazon S3 버킷 정책을 통해 이러한 권한을 지정할 수 있습니다. 예를 들어 다음 Amazon S3 버킷 정책에서 와일드카드 문자(\$1)를 사용하면 AWS 계정이 라는 Amazon S3 버킷의 모든 디렉터리에 파일을 `111122223333` 업로드할 수 있습니다`amzn-s3-demo-bucket`.

```
{
    "Statement": [
        {
            "Action": [
                "s3:PutObject"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
            "Principal": {
                "AWS": [
                    "111122223333"
                ]
            }
        }
    ]
}
```

 AWS 계정 ID를 보려면 [AWS 계정 ID 찾기를 참조하세요](https://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html#FindingYourAWSId).

Amazon S3 버킷 정책을 생성하고 연결하는 방법은 [버킷 정책 예제](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html)를 참조하세요.

**push** 명령을 호출하는 사용자는 최소한 각 대상 Amazon S3 버킷에 개정을 업로드할 수 있는 권한이 있어야 합니다. 예를 들어 다음 정책은 사용자가 `amzn-s3-demo-bucket`이라는 Amazon S3 버킷의 어디에나 개정을 업로드할 수 있도록 허용합니다.

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*"
        }
    ]
}
```

------

IAM 정책을 생성하고 연결하는 방법을 알아보려면 [정책 작업](https://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingPolicies.html#AddingPermissions_Console) 단원을 참조하세요.

## 를 사용하여 개정 푸시 AWS CLI
<a name="push-with-cli"></a>

**참고**  
 `push` 명령은 애플리케이션 Artifact와 AppSpec 파일을 개정으로 번들링합니다. 이 개정의 파일 형식은 압축된 ZIP 파일입니다. 명령은 각각 JSON 형식 또는 YAML 형식 AppSpec 파일인 개정을 예상하기 때문에 AWS Lambda 또는 Amazon ECS 배포와 함께 사용할 수 없습니다.

**push** 명령을 호출하여 배포에 대한 개정을 번들링하고 푸시합니다. 해당 파라미터는 다음과 같습니다.
+  **--application-name**: (문자열) 필수. 애플리케이션 개정과 연관된 CodeDeploy 애플리케이션의 이름.
+  **--s3-location**: (문자열) 필수. Amazon S3에 업로드할 애플리케이션 개정의 위치에 대한 정보. Amazon S3 버킷과 키를 지정해야 합니다. 키는 개정의 이름입니다. CodeDeploy는 업로드되기 전에 콘텐츠를 압축합니다. `s3://amzn-s3-demo-bucket/your-key.zip` 형식을 사용합니다.
+  **--ignore-hidden-files** 또는 **--no-ignore-hidden-files**: (부울) 선택 사항. `--no-ignore-hidden-files` 플래그(기본값)를 사용하여 숨겨진 파일을 번들링하고 Amazon S3로 업로드합니다. `--ignore-hidden-files` 플래그를 사용하여 숨겨진 파일을 번들링하지 않고 Amazon S3로 업로드합니다.
+  **--source** (문자열) 선택 사항. 배포할 콘텐츠와, 압축하여 Amazon S3로 업로드될 개발 시스템 상의 AppSpec 파일의 위치. 이 위치는 현재 디렉터리를 기준으로 한 상대 경로로 지정됩니다. 상대 경로가 지정되지 않았거나 경로에 단일 마침표(‘.’)를 사용하는 경우 현재 디렉터리가 사용됩니다.
+  **--description** (문자열) 선택 사항. 애플리케이션 개정을 요약하는 설명. 지정하지 않으면 기본 문자열 'Uploaded by AWS CLI 'time' UTC'가 사용됩니다. 여기서 'time'은 협정 세계시(UTC)의 현재 시스템 시간입니다.

를 사용하여 Amazon EC2 배포에 대한 개정을 푸시 AWS CLI 할 수 있습니다. 예를 들어 푸시 명령은 다음과 같습니다.

Linux, macOS 또는 Unix:

```
aws deploy push \
  --application-name WordPress_App \
  --description "This is a revision for the application WordPress_App" \
  --ignore-hidden-files \
  --s3-location s3://amzn-s3-demo-bucket/WordPressApp.zip \
  --source .
```

 Windows: 

```
aws deploy push --application-name WordPress_App --description "This is a revision for the application WordPress_App" --ignore-hidden-files --s3-location s3://amzn-s3-demo-bucket/WordPressApp.zip --source .
```

 이 명령은 다음 작업을 수행합니다.
+  번들링된 파일을 `WordPress_App`이라는 애플리케이션과 연결합니다.
+  개정에 설명을 첨부합니다.
+  숨겨진 파일을 무시합니다.
+  개정을 `WordPressApp.zip`으로 지정하고 `amzn-s3-demo-bucket`이라는 버킷으로 푸시합니다.
+  루트 디렉토리의 모든 파일을 개정으로 번들링합니다.

푸시에 성공하면 AWS CLI 또는 CodeDeploy 콘솔을 사용하여 Amazon S3에서 개정을 배포할 수 있습니다. 를 사용하여이 개정을 배포하려면 AWS CLI: 

 Linux, macOS 또는 Unix: 

```
aws deploy create-deployment \
  --application-name WordPress_App \ 
  --deployment-config-name your-deployment-config-name \ 
  --deployment-group-name your-deployment-group-name \ 
  --s3-location bucket=amzn-s3-demo-bucket,key=WordPressApp.zip,bundleType=zip
```

 Windows: 

```
aws deploy create-deployment --application-name WordPress_App --deployment-config-name your-deployment-config-name --deployment-group-name your-deployment-group-name --s3-location bucket=amzn-s3-demo-bucket,key=WordPressApp.zip,bundleType=zip
```

 자세한 내용은 [CodeDeploy에서 배포 만들기](deployments-create.md) 섹션을 참조하세요 

# CodeDeploy를 사용하여 애플리케이션 개정 세부 정보 보기
<a name="application-revisions-view-details"></a>

CodeDeploy 콘솔 AWS CLI, 또는 CodeDeploy APIs를 사용하여 지정된 애플리케이션의 AWS 계정에 등록된 모든 애플리케이션 개정에 대한 세부 정보를 볼 수 있습니다.

개정 등록에 대한 자세한 내용은 [CodeDeploy를 사용하여 Amazon S3에 애플리케이션 개정을 등록합니다.](application-revisions-register.md) 단원을 참조하세요.

**Topics**
+ [애플리케이션 개정 세부 정보 보기(콘솔)](#application-revisions-view-details-console)
+ [애플리케이션 개정 세부 정보 보기(CLI)](#application-revisions-view-details-cli)

## 애플리케이션 개정 세부 정보 보기(콘솔)
<a name="application-revisions-view-details-console"></a>

애플리케이션 개정 세부 정보를 보려면:

1. 에 로그인 AWS Management Console 하고 [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy) CodeDeploy 콘솔을 엽니다.
**참고**  
[CodeDeploy 시작하기](getting-started-codedeploy.md)에서 설정한 사용자와 동일한 사용자로 로그인합니다.

1. 탐색 창에서 **배포**를 확장하고 **애플리케이션**을 선택합니다.
**참고**  
항목이 표시되지 않으면 올바른 리전이 선택되어 있는지 확인합니다. 탐색 모음의 리전 선택기에서 *AWS 일반 참조*의 [리전 및 엔드포인트](https://docs.aws.amazon.com/general/latest/gr/rande.html#codedeploy_region)에 나열된 리전 중 하나를 선택합니다. CodeDeploy는 이러한 지역에서만 지원됩니다.

1. 보려는 개정이 있는 애플리케이션의 이름을 선택합니다.

1. **애플리케이션 세부 정보** 페이지에서 **개정** 탭을 클릭하고 애플리케이션에 대해 등록된 개정 목록을 검토합니다. 개정을 선택한 다음 **세부 정보 보기**를 선택합니다.

## 애플리케이션 개정 세부 정보 보기(CLI)
<a name="application-revisions-view-details-cli"></a>

 AWS CLI 를 사용하여 애플리케이션 개정을 보려면 ****get-application-revision**** 명령 또는 ****list-application-revisions**** 명령을 호출합니다.

**참고**  
 GitHub에 대한 참조는 EC2/온프레미스 배포에 대한 배포에만 적용됩니다. AWS Lambda 배포에 대한 개정은 GitHub에서 작동하지 않습니다.

단일 애플리케이션 개정에 대한 세부 정보를 보려면 [get-application-revision](https://docs.aws.amazon.com/cli/latest/reference/deploy/get-application-revision.html) 명령을 호출하고 다음을 지정합니다.
+ 애플리케이션 이름. 애플리케이션 이름을 가져오려면 [list-applications](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-applications.html) 명령을 호출합니다.
+ GitHub에 저장된 개정의 경우, 리포지토리에 푸시된 애플리케이션 개정을 참조하는 커밋의 ID와 GitHub 리포지토리 이름.
+ Amazon S3에 저장된 개정의 경우, 개정이 포함된 Amazon S3 버킷 이름, 업로드된 아카이브 파일의 이름 및 파일 유형, (선택적으로) 아카이브 파일의 Amazon S3 버전 식별자 및 ETag. [register-application-revision](https://docs.aws.amazon.com/cli/latest/reference/deploy/register-application-revision.html) 호출 중에 버전 식별자, ETag 또는 둘 다 지정된 경우 여기에 지정해야 합니다.

단일 애플리케이션 개정에 대한 세부 정보를 보려면 [list-application-revisions](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-application-revisions.html) 명령을 호출하고 다음을 지정합니다.
+ 애플리케이션 이름. 애플리케이션 이름을 가져오려면 [list-applications](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-applications.html) 명령을 호출합니다.
+ (선택 사항) Amazon S3 애플리케이션 개정에 대한 세부 정보만 보려면 개정이 포함된 Amazon S3 버킷 이름.
+ (선택 사항) Amazon S3 애플리케이션 개정에 대한 세부 정보만 보려면 Amazon S3 애플리케이션 개정으로 검색을 제한하는 접두사 문자열. (지정하지 않으면 CodeDeploy에서 일치하는 모든 Amazon S3 애플리케이션 개정을 나열합니다.)
+ (선택 사항) 각 개정이 배포 그룹의 대상 개정인지 여부에 따라 개정 세부 정보를 나열할지 여부를 지정합니다. (지정하지 않으면 CodeDeploy에서 일치하는 모든 개정을 나열합니다.)
+ (선택 사항) 개정 세부 정보 목록을 정렬할 열 이름과 순서. (지정하지 않으면 CodeDeploy에서 결과를 임의의 순서로 나열합니다.)

모든 개정 또는 Amazon S3에 저장된 개정만 나열할 수 있습니다. GitHub에 저장된 개정만 나열할 수는 없습니다.

# CodeDeploy를 사용하여 Amazon S3에 애플리케이션 개정을 등록합니다.
<a name="application-revisions-register"></a>

이미 [push](https://docs.aws.amazon.com/cli/latest/reference/deploy/push.html) 명령을 호출하여 애플리케이션 개정을 Amazon S3으로 푸시하는 경우 개정을 등록할 필요가 없습니다. 그러나 다른 방법을 통해 Amazon S3에 개정을 업로드하고 해당 개정을 CodeDeploy 콘솔에 또는 AWS CLI을(를) 통해 표시하려면 먼저 이러한 단계에 따라 개정을 등록하세요.

애플리케이션 개정을 GitHub 리포지토리로 푸시하고 개정을 CodeDeploy 콘솔 또는를 통해 표시하려면 다음 단계도 따라야 AWS CLI합니다.

 AWS CLI 또는 CodeDeploy APIs만 사용하여 Amazon S3 또는 GitHub에 애플리케이션 개정을 등록할 수 있습니다.

**Topics**
+ [CodeDeploy(CLI)를 사용하여 Amazon S3에 개정을 등록합니다.](#application-revisions-register-s3)
+ [CodeDeploy(CLI)를 사용하여 GitHub에 개정 등록](#application-revisions-register-github)

## CodeDeploy(CLI)를 사용하여 Amazon S3에 개정을 등록합니다.
<a name="application-revisions-register-s3"></a>

1. Amazon S3에 개정을 업로드합니다.

1. [register-application-revision](https://docs.aws.amazon.com/cli/latest/reference/deploy/register-application-revision.html) 명령을 호출해 다음을 지정합니다.
   + 애플리케이션 이름. 애플리케이션 이름 목록을 보려면 [list-applications](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-applications.html) 명령을 호출합니다.
   + 등록할 개정에 대한 정보:
     + 개정이 포함된 Amazon S3 버킷의 이름.
     + 업로드된 개정의 이름 및 파일 유형. AWS Lambda 배포의 경우 개정은 JSON 또는 YAML로 작성된 AppSpec 파일입니다. EC2/온프레미스 배포의 경우 개정에는 CodeDeploy가 인스턴스에 배포할 소스 파일 버전 또는 인스턴스에서 실행할 스크립트가 포함되어 있습니다.
**참고**  
tar 및 압축된 tar 아카이브 파일 형식(.tar 및 .tar.gz)은 Windows Server 인스턴스에서 지원되지 않습니다.
     + (선택 사항) 개정의 Amazon S3 버전 식별자. (버전 식별자를 지정하지 않으면 CodeDeploy에서는 가장 최신 버전을 사용합니다.)
     + (선택 사항) 개정의 ETag. (ETag를 지정하지 않으면 CodeDeploy가 객체 검증을 건너뜁니다.)
   + (선택 사항) 개정과 연관시킬 설명.

다음 구문을 **register-application-revision** 호출의 일부로 사용하여 Amazon S3에 있는 개정에 대한 정보를 명령줄에서 지정할 수 있습니다(`version` 및 `eTag`는 선택 사항).

EC2/온프레미스 배포에 대한 개정 파일의 경우:

```
--s3-location bucket=string,key=string,bundleType=tar|tgz|zip,version=string,eTag=string
```

 AWS Lambda 배포를 위한 개정 파일의 경우:

```
--s3-location bucket=string,key=string,bundleType=JSON|YAML,version=string,eTag=string
```

## CodeDeploy(CLI)를 사용하여 GitHub에 개정 등록
<a name="application-revisions-register-github"></a>

**참고**  
AWS Lambda 배포는 GitHub에서 작동하지 않습니다.

1. GitHub 리포지토리에 개정을 업로드합니다.

1. [register-application-revision](https://docs.aws.amazon.com/cli/latest/reference/deploy/register-application-revision.html) 명령을 호출해 다음을 지정합니다.
   + 애플리케이션 이름. 애플리케이션 이름 목록을 보려면 [list-applications](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-applications.html) 명령을 호출합니다.
   + 등록할 개정에 대한 정보:
     + 개정이 포함되어 있는 리포지토리의 GitHub 사용자 또는 그룹 이름, 슬래시(`/`), 리포지토리 이름(해당 순으로 입력)
     + 리포지토리에서 개정을 참조하는 커밋 ID.
   + (선택 사항) 개정과 연관시킬 설명.

다음 구문을 **register-application-revision** 호출의 일부로 사용하여 GitHub에 있는 개정에 대한 정보를 명령줄에서 지정할 수 있습니다.

```
--github-location repository=string,commitId=string
```