Class Deployment

All Implemented Interfaces:
IResource,, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-24T02:42:33.089Z") @Stability(Stable) public class Deployment extends Resource
A Deployment of a REST API.

An immutable representation of a RestApi resource that can be called by users using Stages. A deployment must be associated with a Stage for it to be callable over the Internet.

Normally, you don't need to define deployments manually. The RestApi construct manages a Deployment resource that represents the latest model. It can be accessed through restApi.latestDeployment (unless deploy: false is set when defining the RestApi).

If you manually define this resource, you will need to know that since deployments are immutable, as long as the resource's logical ID doesn't change, the deployment will represent the snapshot in time in which the resource was created. This means that if you modify the RestApi model (i.e. add methods or resources), these changes will not be reflected unless a new deployment resource is created.

To achieve this behavior, the method addToLogicalId(data) can be used to augment the logical ID generated for the deployment resource such that it will include arbitrary data. This is done automatically for the restApi.latestDeployment deployment.

Furthermore, since a deployment does not reference any of the REST API resources and methods, CloudFormation will likely provision it before these resources are created, which means that it will represent a "half-baked" model. Use the node.addDependency(dep) method to circumvent that. This is done automatically for the restApi.latestDeployment deployment.


 // production stage
 LogGroup prodLogGroup = new LogGroup(this, "PrdLogs");
 RestApi api = RestApi.Builder.create(this, "books")
                 .accessLogDestination(new LogGroupLogDestination(prodLogGroup))
 Deployment deployment = Deployment.Builder.create(this, "Deployment").api(api).build();
 // development stage
 LogGroup devLogGroup = new LogGroup(this, "DevLogs");
 Stage.Builder.create(this, "dev")
         .accessLogDestination(new LogGroupLogDestination(devLogGroup))
  • Constructor Details

    • Deployment

      protected Deployment( objRef)
    • Deployment

      protected Deployment( initializationMode)
    • Deployment

      @Stability(Stable) public Deployment(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull DeploymentProps props)
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • addToLogicalId

      @Stability(Stable) public void addToLogicalId(@NotNull Object data)
      Adds a component to the hash that determines this Deployment resource's logical ID.

      This should be called by constructs of the API Gateway model that want to invalidate the deployment when their settings change. The component will be resolve()ed during synthesis so tokens are welcome.

      data - This parameter is required.
    • getApi

      @Stability(Stable) @NotNull public IRestApi getApi()
    • getDeploymentId

      @Stability(Stable) @NotNull public String getDeploymentId()
    • getStageName

      @Stability(Stable) @Nullable public String getStageName()
      The stage of the API gateway deployment.