AppSpec '파일' 섹션 (EC2/온프레미스 배포만 해당) - AWS CodeDeploy

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

AppSpec '파일' 섹션 (EC2/온프레미스 배포만 해당)

배포의 Install 이벤트 중에 인스턴스에 설치해야 하는 CodeDeploy 애플리케이션 수정 버전의 파일에 대한 정보를 제공합니다. 이 섹션은 배포 중 수정의 파일을 인스턴스의 위치로 복사하는 경우에만 필요합니다.

이 섹션의 구조는 다음과 같습니다.

files: - source: source-file-location-1 destination: destination-file-location-1 file_exists_behavior: DISALLOW|OVERWRITE|RETAIN

여러 개의 sourcedestination 페어를 설정할 수 있습니다.

source 명령은 인스턴스에 복사할 수정의 파일 또는 디렉터리를 식별합니다.

  • source가 파일을 나타내는 경우 지정한 파일만 인스턴스에 복사됩니다.

  • source가 디렉터리를 나타내는 경우 디렉터리 내의 모든 파일이 인스턴스에 복사됩니다.

  • source이(가) 슬래시 하나인 경우(Amazon Linux, RHEL 및 Ubuntu Server 인스턴스의 경우: "/", Windows Server 인스턴스의 경우: "\") 수정 버전의 모든 파일이 인스턴스에 복사됩니다.

source에 사용된 경로는 appspec.yml 파일에 상대적이며 수정 버전의 루트에 있어야 합니다. 수정 버전의 파일 구조에 대한 자세한 내용은 CodeDeploy의 개정 계획 단원을 참조하세요.

destination 명령은 인스턴스에서 파일이 복사되어야 하는 위치를 식별합니다. /root/destination/directory(Linux, RHEL, Ubuntu) 또는 c:\destination\folder(Windows)와 같은 정규화된 경로여야 합니다.

sourcedestination은 각각 문자열을 사용하여 지정됩니다.

file_exists_behavior 지침은 선택 사항이며, 배포 대상 위치에 이미 있지만 이전에 성공한 배포에는 포함되지 않은 파일을 CodeDeploy 처리하는 방법을 지정합니다. 이 설정은 다음 값 중 하나일 수 있습니다.

  • DISALLOW: 배포가 실패합니다. 이는 옵션을 지정하지 않은 경우의 기본 동작입니다.

  • OVERWRITE: 현재 배포 중인 애플리케이션 수정 버전의 파일 버전이 인스턴스에 이미 있는 버전을 대체합니다.

  • RETATE: 인스턴스에 이미 있는 파일의 버전이 유지되고 새 배포의 일부로 사용됩니다.

file_exists_behavior 설정을 사용하는 경우 다음 설정을 이해합니다.

  • 한 번만 지정할 수 있으며 files: 아래에 나열된 모든 파일 및 디렉터리에 적용됩니다.

  • --file-exists-behavior AWS CLI 옵션 및 fileExistsBehavior API 옵션(둘 다 선택 사항임)보다 우선 적용됩니다.

다음은 Amazon Linux, Ubuntu Server 또는 RHEL 인스턴스에 대한 files 섹션의 예입니다.

files: - source: Config/config.txt destination: /webapps/Config - source: source destination: /webapps/myApp

이 예에서는 설치 이벤트 중 다음 두 가지 작업이 수행됩니다.

  1. 수정의 Config/config.txt 파일을 인스턴스의 /webapps/Config/config.txt 경로에 복사합니다.

  2. 수정의 source 디렉터리에 있는 파일을 인스턴스의 /webapps/myApp 디렉터리로 모두 복사합니다.

'Files' 섹션의 예

다음 예제에서는 files 섹션을 지정하는 방법을 보여줍니다. 이러한 예에서는 Windows Server 파일 및 디렉터리(폴더) 구조를 설명하고 있지만 이러한 구조는Amazon Linux, Ubuntu Server 및 RHEL 인스턴스에 대해 쉽게 조정할 수 있습니다.

참고

EC2/온프레미스 배포만 files 섹션을 사용합니다. AWS Lambda 배포에는 적용되지 않습니다.

다음 예에서는 이러한 파일이 source의 루트에 번들로 나타난다고 가정합니다.

  • appspec.yml

  • my-file.txt

  • my-file-2.txt

  • my-file-3.txt

# 1) Copy only my-file.txt to the destination folder c:\temp. # files: - source: .\my-file.txt destination: c:\temp # # Result: # c:\temp\my-file.txt # # --------------------- # # 2) Copy only my-file-2.txt and my-file-3.txt to the destination folder c:\temp. # files: - source: my-file-2.txt destination: c:\temp - source: my-file-3.txt destination: c:\temp # # Result: # c:\temp\my-file-2.txt # c:\temp\my-file-3.txt # # --------------------- # # 3) Copy my-file.txt, my-file-2.txt, and my-file-3.txt (along with the appspec.yml file) to the destination folder c:\temp. # files: - source: \ destination: c:\temp # # Result: # c:\temp\appspec.yml # c:\temp\my-file.txt # c:\temp\my-file-2.txt # c:\temp\my-file-3.txt

다음 예에서는 appspec.ymlsource의 루트에 번들로 나타나고, 여기에는 파일 3개가 포함된 my-folder 폴더가 함께 있습니다.

  • appspec.yml

  • my-folder\my-file.txt

  • my-folder\my-file-2.txt

  • my-folder\my-file-3.txt

# 4) Copy the 3 files in my-folder (but do not copy my-folder itself) to the destination folder c:\temp. # files: - source: .\my-folder destination: c:\temp # # Result: # c:\temp\my-file.txt # c:\temp\my-file-2.txt # c:\temp\my-file-3.txt # # --------------------- # # 5) Copy my-folder and its 3 files to my-folder within the destination folder c:\temp. # files: - source: .\my-folder destination: c:\temp\my-folder # # Result: # c:\temp\my-folder\my-file.txt # c:\temp\my-folder\my-file-2.txt # c:\temp\my-folder\my-file-3.txt # # --------------------- # # 6) Copy the 3 files in my-folder to other-folder within the destination folder c:\temp. # files: - source: .\my-folder destination: c:\temp\other-folder # # Result: # c:\temp\other-folder\my-file.txt # c:\temp\other-folder\my-file-2.txt # c:\temp\other-folder\my-file-3.txt # # --------------------- # # 7) Copy only my-file-2.txt and my-file-3.txt to my-folder within the destination folder c:\temp. # files: - source: .\my-folder\my-file-2.txt destination: c:\temp\my-folder - source: .\my-folder\my-file-3.txt destination: c:\temp\my-folder # # Result: # c:\temp\my-folder\my-file-2.txt # c:\temp\my-folder\my-file-3.txt # # --------------------- # # 8) Copy only my-file-2.txt and my-file-3.txt to other-folder within the destination folder c:\temp. # files: - source: .\my-folder\my-file-2.txt destination: c:\temp\other-folder - source: .\my-folder\my-file-3.txt destination: c:\temp\other-folder # # Result: # c:\temp\other-folder\my-file-2.txt # c:\temp\other-folder\my-file-3.txt # # --------------------- # # 9) Copy my-folder and its 3 files (along with the appspec.yml file) to the destination folder c:\temp. If any of the files already exist on the instance, overwrite them. # files: - source: \ destination: c:\temp file_exists_behavior: OVERWRITE # # Result: # c:\temp\appspec.yml # c:\temp\my-folder\my-file.txt # c:\temp\my-folder\my-file-2.txt # c:\temp\my-folder\my-file-3.txt