CreateDeploymentAWS SDKOR와 함께 사용 CLI - AWS SDK코드 예제

AWS 문서 AWS SDK SDK 예제 GitHub 리포지토리에 더 많은 예제가 있습니다.

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

CreateDeploymentAWS SDKOR와 함께 사용 CLI

다음 코드 예제는 CreateDeployment의 사용 방법을 보여 줍니다.

작업 예제는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.

CLI
AWS CLI

a에 대해 구성된 리소스를 새 스테이지에 API 배포하려면

명령:

aws apigateway create-deployment --rest-api-id 1234123412 --stage-name dev --stage-description 'Development Stage' --description 'First deployment to the dev stage'

a에 대해 구성된 리소스를 기존 단계에 API 배포하려면

명령:

aws apigateway create-deployment --rest-api-id 1234123412 --stage-name dev --description 'Second deployment to the dev stage'

단계 변수를 사용하여 기존 단계에 구성된 리소스를 API 배포하려면

aws apigateway 생성-배포 — rest-api-id 1234123412 --stage-name dev --설명 '개발 단계로의 세 번째 배포' --변수 키='값', =' otherKey otherValue

  • 자세한 내용은 CreateDeployment명령 AWS CLI 참조를 참조하십시오API.

Java
SDK자바 2.x의 경우
참고

더 많은 내용이 있습니다. GitHub AWS 코드 예시 리포지토리에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요.

public static String createNewDeployment(ApiGatewayClient apiGateway, String restApiId, String stageName) { try { CreateDeploymentRequest request = CreateDeploymentRequest.builder() .restApiId(restApiId) .description("Created using the AWS API Gateway Java API") .stageName(stageName) .build(); CreateDeploymentResponse response = apiGateway.createDeployment(request); System.out.println("The id of the deployment is " + response.id()); return response.id(); } catch (ApiGatewayException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return ""; }
Python
SDK파이썬용 (보토3)
참고

더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요.

class ApiGatewayToService: """ Encapsulates Amazon API Gateway functions that are used to create a REST API that integrates with another AWS service. """ def __init__(self, apig_client): """ :param apig_client: A Boto3 API Gateway client. """ self.apig_client = apig_client self.api_id = None self.root_id = None self.stage = None def deploy_api(self, stage_name): """ Deploys a REST API. After a REST API is deployed, it can be called from any REST client, such as the Python Requests package or Postman. :param stage_name: The stage of the API to deploy, such as 'test'. :return: The base URL of the deployed REST API. """ try: self.apig_client.create_deployment( restApiId=self.api_id, stageName=stage_name ) self.stage = stage_name logger.info("Deployed stage %s.", stage_name) except ClientError: logger.exception("Couldn't deploy stage %s.", stage_name) raise else: return self.api_url() def api_url(self, resource=None): """ Builds the REST API URL from its parts. :param resource: The resource path to append to the base URL. :return: The REST URL to the specified resource. """ url = ( f"https://{self.api_id}.execute-api.{self.apig_client.meta.region_name}" f".amazonaws.com/{self.stage}" ) if resource is not None: url = f"{url}/{resource}" return url
  • 자세한 API AWS SDK내용은 Python (Boto3) API 참조를 참조하십시오 CreateDeployment.