StepFunctionsRestApi L2 construct
Defines an API Gateway REST API with a Synchrounous Express State Machine as a proxy integration.
Example
declare const machine: stepfunctions.IStateMachine;
new apigateway.StepFunctionsRestApi(this, 'StepFunctionsRestApi', {
stateMachine: machine,
useDefaultMethodResponses: false,
});
# machine: stepfunctions.IStateMachine
apigateway.StepFunctionsRestApi(self, "StepFunctionsRestApi",
state_machine=machine,
use_default_method_responses=False
)
IStateMachine machine;
StepFunctionsRestApi.Builder.create(this, "StepFunctionsRestApi")
.stateMachine(machine)
.useDefaultMethodResponses(false)
.build();
// Install: dotnet add package Amazon.CDK.Lib
IStateMachine machine;
new StepFunctionsRestApi(this, "StepFunctionsRestApi", new StepFunctionsRestApiProps {
StateMachine = machine,
UseDefaultMethodResponses = false
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var machine IStateMachine
apigateway.NewStepFunctionsRestApi(this, jsii.String("StepFunctionsRestApi"), &StepFunctionsRestApiProps{
StateMachine: machine,
UseDefaultMethodResponses: jsii.Boolean(false),
})
Initializer
new StepFunctionsRestApi(scope: Construct, id: string, props: StepFunctionsRestApiProps)
StepFunctionsRestApi(scope: Construct, id: str, props: StepFunctionsRestApiProps)
new StepFunctionsRestApi(Construct scope, String id, StepFunctionsRestApiProps props)
new StepFunctionsRestApi(Construct scope, string id, StepFunctionsRestApiProps props)
NewStepFunctionsRestApi(Scope Construct, Id *string, Props StepFunctionsRestApiProps)
Construct Props
apiKeySourceTypeApiKeySourceTypeapi_key_source_typeApiKeySourceTypeapiKeySourceTypeApiKeySourceTypeApiKeySourceTypeApiKeySourceTypeApiKeySourceTypeApiKeySourceType= Metering is disabled.#The execution input will include a new key authorizer:
{ "body": {}, "authorizer": { "key": "value" } }
binaryMediaTypesstring[]binary_media_typestyping.List[str]binaryMediaTypesList<String>BinaryMediaTypesstring[]BinaryMediaTypes*[]*string= RestApi supports only UTF-8-enco…#default
Default: RestApi supports only UTF-8-encoded text payloads.
cloudWatchRolebooleancloud_watch_roleboolcloudWatchRoleBooleanCloudWatchRoleboolCloudWatchRole*bool= false if `@aws-cdk/aws-apigatewa…#default
Default: false if @aws-cdk/aws-apigateway:disableCloudWatchRole is enabled, true otherwise
cloudWatchRoleRemovalPolicyRemovalPolicycloud_watch_role_removal_policyRemovalPolicycloudWatchRoleRemovalPolicyRemovalPolicyCloudWatchRoleRemovalPolicyRemovalPolicyCloudWatchRoleRemovalPolicyRemovalPolicy= RemovalPolicy.RETAIN#Requires cloudWatchRole to be enabled.
defaultCorsPreflightOptionsCorsOptionsdefault_cors_preflight_optionsCorsOptionsdefaultCorsPreflightOptionsCorsOptionsDefaultCorsPreflightOptionsCorsOptionsDefaultCorsPreflightOptionsCorsOptions= CORS is disabled#You can add CORS at the resource-level using addCorsPreflight.
defaultIntegrationIntegrationdefault_integrationIntegrationdefaultIntegrationIntegrationDefaultIntegrationIntegrationDefaultIntegrationIntegration= Inherited from parent.#defaultMethodOptionsMethodOptionsdefault_method_optionsMethodOptionsdefaultMethodOptionsMethodOptionsDefaultMethodOptionsMethodOptionsDefaultMethodOptionsMethodOptions= Inherited from parent.#notes
Since API Gateway deployments are immutable, When this option is enabled (by default), an AWS::ApiGateway::Deployment resource will automatically created with a logical ID that hashes the API model (methods, resources and options). This means that when the model changes, the logical ID of this CloudFormation resource will change, and a new deployment will be created.
If this is set, latestDeployment will refer to the Deployment object and deploymentStage will refer to a Stage that points to this deployment. To customize the stage options, use the deployOptions property.
A CloudFormation Output will also be defined with the root URL endpoint of this REST API.
deployOptionsStageOptionsdeploy_optionsStageOptionsdeployOptionsStageOptionsDeployOptionsStageOptionsDeployOptionsStageOptions= Based on defaults of `StageOptio…#If deploy is disabled, this value cannot be set.
default
Default: Based on defaults of StageOptions.
descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= 'Automatically created by the Re…#default
Default: 'Automatically created by the RestApi construct'
disableExecuteApiEndpointbooleandisable_execute_api_endpointbooldisableExecuteApiEndpointBooleanDisableExecuteApiEndpointboolDisableExecuteApiEndpoint*bool= false#To require that clients use a custom domain name to invoke the API, disable the default endpoint.
domainNameDomainNameOptionsdomain_nameDomainNameOptionsdomainNameDomainNameOptionsDomainNameDomainNameOptionsDomainNameDomainNameOptions= no domain name is defined, use `…#default
Default: no domain name is defined, use addDomainName or directly define a DomainName.
endpointConfigurationEndpointConfigurationendpoint_configurationEndpointConfigurationendpointConfigurationEndpointConfigurationEndpointConfigurationEndpointConfigurationEndpointConfigurationEndpointConfiguration= EndpointType.EDGE#endpointExportNamestringendpoint_export_namestrendpointExportNameStringEndpointExportNamestringEndpointExportName*string= when no export name is given, ou…#default
Default: when no export name is given, output will be created without export
endpointTypesEndpointType[]endpoint_typestyping.List[EndpointType]endpointTypesList<EndpointType>EndpointTypesEndpointType[]EndpointTypes*[]EndpointType= EndpointType.EDGE#Use this property when creating an API.
failOnWarningsbooleanfail_on_warningsboolfailOnWarningsBooleanFailOnWarningsboolFailOnWarnings*bool= false#The execution input will include a new key headers:
{ "body": {}, "headers": { "header1": "value", "header2": "value" } }
minCompressionSizeSizemin_compression_sizeSizeminCompressionSizeSizeMinCompressionSizeSizeMinCompressionSizeSize= Compression is disabled.#When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size.
minimumCompressionSizenumberminimum_compression_sizeint | floatminimumCompressionSizeNumberMinimumCompressionSizedoubleMinimumCompressionSize*float64= Compression is disabled.deprecated#When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size.
parameters{ [key: string]: string }parameterstyping.Mapping[str, str]parametersMap<String, String>ParametersIDictionary<string, string>Parameters*map[string]*string= No parameters.#The execution input will include a new key path:
{ "body": {}, "path": { "resourceName": "resourceValue" } }
policyPolicyDocumentpolicyPolicyDocumentpolicyPolicyDocumentPolicyPolicyDocumentPolicyPolicyDocument= No policy.#The execution input will include a new key queryString:
{ "body": {}, "querystring": { "key": "value" } }
requestContextRequestContextrequest_contextRequestContextrequestContextRequestContextRequestContextRequestContextRequestContextRequestContext= all parameters within request co…#The execution input will include a new key requestContext:
{ "body": {}, "requestContext": { "key": "value" } }
default
Default: all parameters within request context will be set as false
restApiNamestringrest_api_namestrrestApiNameStringRestApiNamestringRestApiName*string= ID of the RestApi construct.#retainDeploymentsbooleanretain_deploymentsboolretainDeploymentsBooleanRetainDeploymentsboolRetainDeployments*bool= false#This allows manually reverting stages to point to old deployments via the AWS Console.
stateMachineIStateMachinestate_machineIStateMachinestateMachineIStateMachineStateMachineIStateMachineStateMachineIStateMachinerequired#This stateMachine will be used as the default integration for all methods in this API, unless specified otherwise in addMethod.
useDefaultMethodResponsesbooleanuse_default_method_responsesbooluseDefaultMethodResponsesBooleanUseDefaultMethodResponsesboolUseDefaultMethodResponses*bool= true#Properties
deploymentStageStagedeployment_stageStagedeploymentStageStageDeploymentStageStageDeploymentStageStagerequired#If deploy is disabled, you will need to explicitly assign this value in order to set up integrations.
domainNameDomainNamedomain_nameDomainNamedomainNameDomainNameDomainNameDomainNameDomainNameDomainName#envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#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.
latestDeploymentDeploymentlatest_deploymentDeploymentlatestDeploymentDeploymentLatestDeploymentDeploymentLatestDeploymentDeployment#This resource will be automatically updated every time the REST API model changes. This will be undefined if deploy is false.
methodsMethod[]methodstyping.List[Method]methodsList<Method>MethodsMethod[]Methods*[]Methodrequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#Note that this is different from restApiId.
restApiRefRestApiReferencerest_api_refRestApiReferencerestApiRefRestApiReferenceRestApiRefRestApiReferenceRestApiRefRestApiReferencerequired#restApiRootResourceIdstringrest_api_root_resource_idstrrestApiRootResourceIdStringRestApiRootResourceIdstringRestApiRootResourceId*stringrequired#Resources and Methods are added to this resource.
Methods
addApiKey(id: string, options?: ApiKeyOptions): IApiKeydef add_api_key(self, id: str, options: typing.Optional[ApiKeyOptions] = None) -> IApiKeypublic IApiKey addApiKey(String id, ApiKeyOptions options)public IApiKey AddApiKey(string id, ApiKeyOptions? options = null)func AddApiKey(Id *string, Options ApiKeyOptions) IApiKey#addDomainName(id: string, options: DomainNameOptions): DomainNamedef add_domain_name(self, id: str, options: DomainNameOptions) -> DomainNamepublic DomainName addDomainName(String id, DomainNameOptions options)public DomainName AddDomainName(string id, DomainNameOptions options)func AddDomainName(Id *string, Options DomainNameOptions) DomainName#2 parameters
Parameters
ididididId— The construct id.optionsoptionsoptionsoptionsOptions— custom domain options.
addGatewayResponse(id: string, options: GatewayResponseOptions): GatewayResponsedef add_gateway_response(self, id: str, options: GatewayResponseOptions) -> GatewayResponsepublic GatewayResponse addGatewayResponse(String id, GatewayResponseOptions options)public GatewayResponse AddGatewayResponse(string id, GatewayResponseOptions options)func AddGatewayResponse(Id *string, Options GatewayResponseOptions) GatewayResponse#addModel(id: string, props: ModelOptions): Modeldef add_model(self, id: str, props: ModelOptions) -> Modelpublic Model addModel(String id, ModelOptions props)public Model AddModel(string id, ModelOptions props)func AddModel(Id *string, Props ModelOptions) Model#addRequestValidator(id: string, props: RequestValidatorOptions): RequestValidatordef add_request_validator(self, id: str, props: RequestValidatorOptions) -> RequestValidatorpublic RequestValidator addRequestValidator(String id, RequestValidatorOptions props)public RequestValidator AddRequestValidator(string id, RequestValidatorOptions props)func AddRequestValidator(Id *string, Props RequestValidatorOptions) RequestValidator#addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResultdef add_to_resource_policy(self, statement: PolicyStatement) -> AddToResourcePolicyResultpublic AddToResourcePolicyResult addToResourcePolicy(PolicyStatement statement)public AddToResourcePolicyResult AddToResourcePolicy(PolicyStatement statement)func AddToResourcePolicy(Statement PolicyStatement) AddToResourcePolicyResult#A resource policy will be automatically created upon the first call to addToResourcePolicy.
Note that this does not work with imported rest api.
1 parameter
Parameters
statementstatementstatementstatementStatement— The policy statement to add.
addUsagePlan(id: string, props?: UsagePlanProps): UsagePlandef add_usage_plan(self, id: str, props: typing.Optional[UsagePlanProps] = None) -> UsagePlanpublic UsagePlan addUsagePlan(String id, UsagePlanProps props)public UsagePlan AddUsagePlan(string id, UsagePlanProps? props = null)func AddUsagePlan(Id *string, Props UsagePlanProps) UsagePlan#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).
arnForExecuteApi(method?: string, path?: string, stage?: string): stringdef arn_for_execute_api(self, method: typing.Optional[str] = None, path: typing.Optional[str] = None, stage: typing.Optional[str] = None) -> strpublic String arnForExecuteApi(String method, String path, String stage)public string ArnForExecuteApi(string? method = null, string? path = null, string? stage = null)func ArnForExecuteApi(Method *string, Path *string, Stage *string) *string#fromRestApiAttributes(scope: Construct, id: string, attrs: RestApiAttributes): IRestApi@staticmethod def from_rest_api_attributes(scope: Construct, id: str, attrs: RestApiAttributes) -> IRestApipublic static IRestApi fromRestApiAttributes(Construct scope, String id, RestApiAttributes attrs)public static IRestApi FromRestApiAttributes(Construct scope, string id, RestApiAttributes attrs)func FromRestApiAttributes(Scope Construct, Id *string, Attrs RestApiAttributes) IRestApistatic#fromRestApiId(scope: Construct, id: string, restApiId: string): IRestApi@staticmethod def from_rest_api_id(scope: Construct, id: str, rest_api_id: str) -> IRestApipublic static IRestApi fromRestApiId(Construct scope, String id, String restApiId)public static IRestApi FromRestApiId(Construct scope, string id, string restApiId)func FromRestApiId(Scope Construct, Id *string, RestApiId *string) IRestApistatic#grantInvokeFromVpcEndpointsOnly(vpcEndpoints: IVpcEndpoint[]): voiddef grant_invoke_from_vpc_endpoints_only(self, vpc_endpoints: typing.List[IVpcEndpoint]) -> Nonepublic void grantInvokeFromVpcEndpointsOnly(List<IVpcEndpoint> vpcEndpoints)public void GrantInvokeFromVpcEndpointsOnly(IVpcEndpoint[] vpcEndpoints)func GrantInvokeFromVpcEndpointsOnly(VpcEndpoints *[]IVpcEndpoint)#1 parameter
Parameters
vpcEndpointsvpc_endpointsvpcEndpointsvpcEndpointsVpcEndpoints— the interface VPC endpoints to grant access to.
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#isRestApi(x: any): boolean@staticmethod def is_rest_api(x: Any) -> boolpublic static Boolean isRestApi(Object x)public static bool IsRestApi(object x)func IsRestApi(X interface{}) *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#metricCacheHitCount(props?: MetricOptions): Metricdef metric_cache_hit_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricCacheHitCount(MetricOptions props)public Metric MetricCacheHitCount(MetricOptions? props = null)func MetricCacheHitCount(Props MetricOptions) Metric#Default: sum over 5 minutes
metricCacheMissCount(props?: MetricOptions): Metricdef metric_cache_miss_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricCacheMissCount(MetricOptions props)public Metric MetricCacheMissCount(MetricOptions? props = null)func MetricCacheMissCount(Props MetricOptions) Metric#Default: sum over 5 minutes
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#Default: sum over 5 minutes
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#Default: sample count over 5 minutes
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#Default: average over 5 minutes.
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.
Default: average over 5 minutes.
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#Default: sum over 5 minutes
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#urlForPath(path?: string): stringdef url_for_path(self, path: typing.Optional[str] = None) -> strpublic String urlForPath(String path)public string UrlForPath(string? path = null)func UrlForPath(Path *string) *string#Fails if deploymentStage is not set either by deploy or explicitly.
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.