HttpStage L2 construct
Represents a stage where an instance of the API is deployed.
Example
import * as apigw from 'aws-cdk-lib/aws-apigateway';
import * as logs from 'aws-cdk-lib/aws-logs';
declare const api: apigwv2.HttpApi;
declare const logGroup: logs.LogGroup;
const stage = new apigwv2.HttpStage(this, 'Stage', {
httpApi: api,
accessLogSettings: {
destination: new apigwv2.LogGroupLogDestination(logGroup),
format: apigw.AccessLogFormat.clf(),
},
});
import aws_cdk.aws_apigateway as apigw
import aws_cdk.aws_logs as logs
# api: apigwv2.HttpApi
# log_group: logs.LogGroup
stage = apigwv2.HttpStage(self, "Stage",
http_api=api,
access_log_settings={
"destination": apigwv2.LogGroupLogDestination(log_group),
"format": apigw.AccessLogFormat.clf()
}
)
import software.amazon.awscdk.services.apigateway.*;
import software.amazon.awscdk.services.logs.*;
HttpApi api;
LogGroup logGroup;
HttpStage stage = HttpStage.Builder.create(this, "Stage")
.httpApi(api)
.accessLogSettings(Map.of(
"destination", new LogGroupLogDestination(logGroup),
"format", AccessLogFormat.clf()))
.build();
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.APIGateway;
using Amazon.CDK.AWS.Logs;
HttpApi api;
LogGroup logGroup;
var stage = new HttpStage(this, "Stage", new HttpStageProps {
HttpApi = api,
AccessLogSettings = new Dictionary<string, object> {
{ "destination", new LogGroupLogDestination(logGroup) },
{ "format", AccessLogFormat.Clf() }
}
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import apigw "github.com/aws/aws-cdk-go/awscdk"
import logs "github.com/aws/aws-cdk-go/awscdk"
var api HttpApi
var logGroup LogGroup
stage := apigwv2.NewHttpStage(this, jsii.String("Stage"), &HttpStageProps{
HttpApi: api,
AccessLogSettings: map[string]interface{}{
"destination": apigwv2.NewLogGroupLogDestination(logGroup),
"format": apigw.AccessLogFormat_clf(),
},
})
Initializer
new HttpStage(scope: Construct, id: string, props: HttpStageProps)
HttpStage(scope: Construct, id: str, props: HttpStageProps)
new HttpStage(Construct scope, String id, HttpStageProps props)
new HttpStage(Construct scope, string id, HttpStageProps props)
NewHttpStage(Scope Construct, Id *string, Props HttpStageProps)
Construct Props
accessLogSettingsoptionalIAccessLogSettingsaccess_log_settingsoptionalIAccessLogSettingsaccessLogSettingsoptionalIAccessLogSettingsAccessLogSettingsoptionalIAccessLogSettingsAccessLogSettingsoptionalIAccessLogSettings#Default: No access logging
autoDeployoptionalbooleanauto_deployoptionalboolautoDeployoptionalBooleanAutoDeployoptionalboolAutoDeployoptional*bool= false#descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#Default: no description
detailedMetricsEnabledoptionalbooleandetailed_metrics_enabledoptionalbooldetailedMetricsEnabledoptionalBooleanDetailedMetricsEnabledoptionalboolDetailedMetricsEnabledoptional*bool= false#domainMappingoptionalDomainMappingOptionsdomain_mappingoptionalDomainMappingOptionsdomainMappingoptionalDomainMappingOptionsDomainMappingoptionalDomainMappingOptionsDomainMappingoptionalDomainMappingOptions#Default: no custom domain and api mapping configuration
httpApiIHttpApiRefhttp_apiIHttpApiRefhttpApiIHttpApiRefHttpApiIHttpApiRefHttpApiIHttpApiRefrequired#stageNameoptionalstringstage_nameoptionalstrstageNameoptionalStringStageNameoptionalstringStageNameoptional*string#Default: '$default' the default stage of the API. This stage will have the URL at the root of the API endpoint.
See StageName class for more details.
stageVariablesoptional{ [key: string]: string }stage_variablesoptionaltyping.Mapping[str, str]stageVariablesoptionalMap<String, String>StageVariablesoptionalIDictionary<string, string>StageVariablesoptional*map[string]*string#Default: No stage variables
notes
The allowed characters for variable names and the required pattern for variable values are specified here: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-apigateway-stage.html#cfn-apigateway-stage-variables
throttleoptionalThrottleSettingsthrottleoptionalThrottleSettingsthrottleoptionalThrottleSettingsThrottleoptionalThrottleSettingsThrottleoptionalThrottleSettings#Default: no throttling configuration
Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironment#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
Will always return true, but is necessary to prevent accidental structural equality in TypeScript.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#its primary identifier.
stageRefStageReferencestage_refStageReferencestageRefStageReferenceStageRefStageReferenceStageRefStageReference#Methods
addStageVariable(name: string, value: string): voiddef add_stage_variable(self, name: str, value: str) -> Nonepublic void addStageVariable(String name, String value)public void AddStageVariable(string name, string value)func AddStageVariable(Name *string, Value *string)#applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).
defaultAccessLogFormat(): AccessLogFormatdef default_access_log_format(self, ) -> AccessLogFormatpublic AccessLogFormat defaultAccessLogFormat()public AccessLogFormat DefaultAccessLogFormat()func DefaultAccessLogFormat() AccessLogFormat#fromHttpStageAttributes(scope: Construct, id: string, attrs: HttpStageAttributes): IHttpStage@staticmethod def from_http_stage_attributes(scope: Construct, id: str, attrs: HttpStageAttributes) -> IHttpStagepublic static IHttpStage fromHttpStageAttributes(Construct scope, String id, HttpStageAttributes attrs)public static IHttpStage FromHttpStageAttributes(Construct scope, string id, HttpStageAttributes attrs)func FromHttpStageAttributes(Scope Construct, Id *string, Attrs HttpStageAttributes) IHttpStagestatic#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric#metricClientError(props?: MetricOptions): Metricdef metric_client_error(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricClientError(MetricOptions props)public Metric MetricClientError(MetricOptions? props = null)func MetricClientError(Props MetricOptions) Metric#metricCount(props?: MetricOptions): Metricdef metric_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricCount(MetricOptions props)public Metric MetricCount(MetricOptions? props = null)func MetricCount(Props MetricOptions) Metric#metricDataProcessed(props?: MetricOptions): Metricdef metric_data_processed(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricDataProcessed(MetricOptions props)public Metric MetricDataProcessed(MetricOptions? props = null)func MetricDataProcessed(Props MetricOptions) Metric#metricIntegrationLatency(props?: MetricOptions): Metricdef metric_integration_latency(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricIntegrationLatency(MetricOptions props)public Metric MetricIntegrationLatency(MetricOptions? props = null)func MetricIntegrationLatency(Props MetricOptions) Metric#metricLatency(props?: MetricOptions): Metricdef metric_latency(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricLatency(MetricOptions props)public Metric MetricLatency(MetricOptions? props = null)func MetricLatency(Props MetricOptions) Metric#The latency includes the integration latency and other API Gateway overhead.
metricServerError(props?: MetricOptions): Metricdef metric_server_error(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricServerError(MetricOptions props)public Metric MetricServerError(MetricOptions? props = null)func MetricServerError(Props MetricOptions) Metric#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.