UNPKG

3.91 kBTypeScriptView Raw
1import { Resource } from '@aws-cdk/core';
2import { Construct } from 'constructs';
3import { Method } from './method';
4import { IRestApi } from './restapi';
5export interface DeploymentProps {
6 /**
7 * The Rest API to deploy.
8 */
9 readonly api: IRestApi;
10 /**
11 * A description of the purpose of the API Gateway deployment.
12 *
13 * @default - No description.
14 */
15 readonly description?: string;
16 /**
17 * When an API Gateway model is updated, a new deployment will automatically be created.
18 * If this is true, the old API Gateway Deployment resource will not be deleted.
19 * This will allow manually reverting back to a previous deployment in case for example
20 *
21 * @default false
22 */
23 readonly retainDeployments?: boolean;
24}
25/**
26 * A Deployment of a REST API.
27 *
28 * An immutable representation of a RestApi resource that can be called by users
29 * using Stages. A deployment must be associated with a Stage for it to be
30 * callable over the Internet.
31 *
32 * Normally, you don't need to define deployments manually. The RestApi
33 * construct manages a Deployment resource that represents the latest model. It
34 * can be accessed through `restApi.latestDeployment` (unless `deploy: false` is
35 * set when defining the `RestApi`).
36 *
37 * If you manually define this resource, you will need to know that since
38 * deployments are immutable, as long as the resource's logical ID doesn't
39 * change, the deployment will represent the snapshot in time in which the
40 * resource was created. This means that if you modify the RestApi model (i.e.
41 * add methods or resources), these changes will not be reflected unless a new
42 * deployment resource is created.
43 *
44 * To achieve this behavior, the method `addToLogicalId(data)` can be used to
45 * augment the logical ID generated for the deployment resource such that it
46 * will include arbitrary data. This is done automatically for the
47 * `restApi.latestDeployment` deployment.
48 *
49 * Furthermore, since a deployment does not reference any of the REST API
50 * resources and methods, CloudFormation will likely provision it before these
51 * resources are created, which means that it will represent a "half-baked"
52 * model. Use the `node.addDependency(dep)` method to circumvent that. This is done
53 * automatically for the `restApi.latestDeployment` deployment.
54 */
55export declare class Deployment extends Resource {
56 /** @attribute */
57 readonly deploymentId: string;
58 readonly api: IRestApi;
59 private readonly resource;
60 constructor(scope: Construct, id: string, props: DeploymentProps);
61 /**
62 * Adds a component to the hash that determines this Deployment resource's
63 * logical ID.
64 *
65 * This should be called by constructs of the API Gateway model that want to
66 * invalidate the deployment when their settings change. The component will
67 * be resolve()ed during synthesis so tokens are welcome.
68 */
69 addToLogicalId(data: any): void;
70 /**
71 * Quoting from CloudFormation's docs:
72 *
73 * If you create an AWS::ApiGateway::RestApi resource and its methods (using
74 * AWS::ApiGateway::Method) in the same template as your deployment, the
75 * deployment must depend on the RestApi's methods. To create a dependency,
76 * add a DependsOn attribute to the deployment. If you don't, AWS
77 * CloudFormation creates the deployment right after it creates the RestApi
78 * resource that doesn't contain any methods, and AWS CloudFormation
79 * encounters the following error: The REST API doesn't contain any methods.
80 *
81 * @param method The method to add as a dependency of the deployment
82 * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-deployment.html
83 * @see https://github.com/aws/aws-cdk/pull/6165
84 * @internal
85 */
86 _addMethodDependency(method: Method): void;
87}