의 수정본에 응용 프로그램 사양 파일 추가 CodeDeploy - AWS CodeDeploy

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

의 수정본에 응용 프로그램 사양 파일 추가 CodeDeploy

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

Amazon ECS 배포를 위한 AppSpec 파일 추가

Amazon ECS 컴퓨팅 플랫폼에 배포하는 경우:

  • 이 AppSpec 파일은 배포에 사용되는 Amazon ECS 작업 정의, 트래픽을 라우팅하는 데 사용되는 컨테이너 이름 및 포트 매핑, 배포 수명 주기 이벤트 이후에 실행되는 선택적 Lambda 함수를 지정합니다.

  • 수정 버전은 파일과 동일합니다. AppSpec

  • JSON 또는 YAML을 사용하여 AppSpec 파일을 작성할 수 있습니다.

  • 파일은 텍스트 AppSpec 파일로 저장하거나 배포를 생성할 때 콘솔에 직접 입력할 수 있습니다. 자세한 정보는 Amazon ECS 컴퓨팅 플랫폼에 대한 배포 생성(콘솔)을 참조하세요.

AppSpec 파일 생성하기

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

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

  3. JSON 또는 YAML 검사기를 사용하여 파일의 유효성을 검사합니다. AppSpec AppSpec편집기를 사용하는 경우 배포 생성을 선택하면 파일의 유효성이 검사됩니다.

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

Amazon ECS 배포를 위한 YAML AppSpec 파일 템플릿 (지침 포함)

다음은 사용 가능한 모든 옵션이 포함된 Amazon ECS 배포용 AppSpec 파일의 YAML 템플릿입니다. hooks 섹션에서 사용할 수명 주기 이벤트에 대한 자세한 내용은 AppSpec Amazon 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 AppSpec 배포 템플릿용 JSON 파일

다음은 사용 가능한 모든 옵션이 포함된 Amazon ECS 배포용 AppSpec 파일용 JSON 템플릿입니다. 템플릿 지침은 이전 섹션의 YAML 버전에 있는 설명을 참조하세요. hooks 섹션에서 사용할 수명 주기 이벤트에 대한 자세한 내용은 AppSpec Amazon 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 파일 추가

AWS Lambda 컴퓨팅 플랫폼에 배포하는 경우:

  • 이 AppSpec 파일에는 배포 검증에 배포하고 사용할 Lambda 함수에 대한 지침이 들어 있습니다.

  • 수정 버전은 파일과 동일합니다. AppSpec

  • JSON 또는 YAML을 사용하여 AppSpec 파일을 작성할 수 있습니다.

  • 파일은 텍스트 AppSpec 파일로 저장하거나 배포를 생성할 때 콘솔 AppSpec 편집기에 직접 입력할 수 있습니다. 자세한 정보는 AWS Lambda 컴퓨팅 플랫폼 배포 생성(콘솔)을 참조하세요.

AppSpec 파일을 만들려면:

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

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

  3. JSON 또는 YAML 검사기를 사용하여 파일의 유효성을 검사합니다. AppSpec AppSpec편집기를 사용하는 경우 배포 생성을 선택하면 파일의 유효성이 검사됩니다.

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

지침이 포함된 AWS Lambda 배포용 YAML AppSpec 파일 템플릿

후크 섹션에서 사용할 수명 주기 이벤트에 대한 자세한 내용은 AppSpec AWS 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.

배포 템플릿용 JSON AppSpec 파일 AWS Lambda

다음 템플릿에서 MyFunction "“를 AWS Lambda 함수 이름으로 바꾸십시오. 선택적 Hooks 섹션에서 라이프사이클 이벤트를 BeforeAllowTraffic 또는 로 바꾸십시오 AfterAllowTraffic.

후크 섹션에서 사용할 수명 주기 이벤트에 대한 자세한 내용은 AppSpec AWS Lambda 배포를 위한 '후크' 섹션을(를) 참조하세요.

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

AppSpec EC2/온프레미스 배포용 파일 추가

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

각 수정 버전에는 파일이 하나만 포함되어야 합니다. AppSpec

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

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

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

  3. YAML 검사기를 사용하여 파일의 유효성을 확인하세요. AppSpec

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

  5. 다음 명령 중 하나를 실행하여 AppSpec 파일이 루트 디렉터리에 저장되었는지 확인합니다.

    • Linux, macOS, Unix의 경우:

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

      해당 AppSpec 파일이 발견되지 않으면 출력이 표시되지 않습니다.

    • Windows의 경우

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

      파일이 저장되어 있지 않으면 [ AppSpec 파일을 찾을 수 없음] 오류가 표시됩니다.

  6. Amazon S3 또는 에 수정 버전을 GitHub 푸시하십시오.

    지침은 Amazon CodeDeploy S3에 수정 버전 푸시 (EC2/온프레미스 배포만 해당)을 참조하세요.

AppSpec 지침이 포함된 EC2/온프레미스 배포용 파일 템플릿

참고

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: