Class Deployment
- All Implemented Interfaces:
IConstruct
,IDependable
,IResource
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
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.
Example:
// production stage LogGroup prdLogGroup = new LogGroup(this, "PrdLogs"); RestApi api = RestApi.Builder.create(this, "books") .deployOptions(StageOptions.builder() .accessLogDestination(new LogGroupLogDestination(prdLogGroup)) .accessLogFormat(AccessLogFormat.jsonWithStandardFields()) .build()) .build(); Deployment deployment = Deployment.Builder.create(this, "Deployment").api(api).build(); // development stage LogGroup devLogGroup = new LogGroup(this, "DevLogs"); Stage.Builder.create(this, "dev") .deployment(deployment) .accessLogDestination(new LogGroupLogDestination(devLogGroup)) .accessLogFormat(AccessLogFormat.jsonWithStandardFields(JsonWithStandardFieldProps.builder() .caller(false) .httpMethod(true) .ip(true) .protocol(true) .requestTime(true) .resourcePath(true) .responseLength(true) .status(true) .user(true) .build())) .build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
Deployment
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Deployment
(software.amazon.jsii.JsiiObjectRef objRef) Deployment
(software.constructs.Construct scope, String id, DeploymentProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToLogicalId
(Object data) Adds a component to the hash that determines this Deployment resource's logical ID.getApi()
Methods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResource
Methods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
Methods inherited from class software.constructs.Construct
toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.awscdk.core.IConstruct
getNode
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Deployment
protected Deployment(software.amazon.jsii.JsiiObjectRef objRef) -
Deployment
protected Deployment(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Deployment
@Stability(Stable) public Deployment(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull DeploymentProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
addToLogicalId
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.
- Parameters:
data
- This parameter is required.
-
getApi
-
getDeploymentId
-