RestApi class
Manages an API Gateway REST API. The REST API can be configured via importing an OpenAPI specification in the body argument (with other arguments serving as overrides) or via other provider resources to manage the resources (aws.apigateway.Resource resource), methods (aws.apigateway.Method resource), integrations (aws.apigateway.Integration resource), etc. of the REST API. Once the REST API is configured, the aws.apigateway.Deployment resource can be used along with the aws.apigateway.Stage resource to publish the REST API.
> Note: Amazon API Gateway Version 1 resources are used for creating and deploying REST APIs. To create and deploy WebSocket and HTTP APIs, use Amazon API Gateway Version 2 resources.
> WARN: When importing Open API Specifications with the body argument, by default the API Gateway REST API will be replaced with the Open API Specification thus removing any existing methods, resources, integrations, or endpoints. Endpoint mutations are asynchronous operations, and race conditions with DNS are possible. To overcome this limitation, use the putRestApiMode attribute and set it to merge.
Example Usage
Security Policy
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.apigateway.RestApi("example", {
endpointConfiguration: {
types: "REGIONAL",
},
name: "example",
securityPolicy: "SecurityPolicy_TLS13_1_2_PFS_PQ_2025_09",
endpointAccessMode: "BASIC",
});
import pulumi
import pulumi_aws as aws
example = aws.apigateway.RestApi("example",
endpoint_configuration={
"types": "REGIONAL",
},
name="example",
security_policy="SecurityPolicy_TLS13_1_2_PFS_PQ_2025_09",
endpoint_access_mode="BASIC")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.ApiGateway.RestApi("example", new()
{
EndpointConfiguration = new Aws.ApiGateway.Inputs.RestApiEndpointConfigurationArgs
{
Types = "REGIONAL",
},
Name = "example",
SecurityPolicy = "SecurityPolicy_TLS13_1_2_PFS_PQ_2025_09",
EndpointAccessMode = "BASIC",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/apigateway"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apigateway.NewRestApi(ctx, "example", &apigateway.RestApiArgs{
EndpointConfiguration: &apigateway.RestApiEndpointConfigurationArgs{
Types: pulumi.String("REGIONAL"),
},
Name: pulumi.String("example"),
SecurityPolicy: pulumi.String("SecurityPolicy_TLS13_1_2_PFS_PQ_2025_09"),
EndpointAccessMode: pulumi.String("BASIC"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_apigateway_restapi" "example" {
endpoint_configuration = {
types = "REGIONAL"
}
name = "example"
security_policy = "SecurityPolicy_TLS13_1_2_PFS_PQ_2025_09"
endpoint_access_mode = "BASIC"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.RestApi;
import com.pulumi.aws.apigateway.RestApiArgs;
import com.pulumi.aws.apigateway.inputs.RestApiEndpointConfigurationArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new RestApi("example", RestApiArgs.builder()
.endpointConfiguration(RestApiEndpointConfigurationArgs.builder()
.types("REGIONAL")
.build())
.name("example")
.securityPolicy("SecurityPolicy_TLS13_1_2_PFS_PQ_2025_09")
.endpointAccessMode("BASIC")
.build());
}
}
resources:
example:
type: aws:apigateway:RestApi
properties:
endpointConfiguration:
types: REGIONAL
name: example
securityPolicy: SecurityPolicy_TLS13_1_2_PFS_PQ_2025_09
endpointAccessMode: BASIC
Optional
accountId(String) AWS Account where this resource is managed.region(String) Region where this resource is managed.
Using pulumi import, import aws.apigateway.RestApi using the REST API ID. For example:
$ pulumi import aws:apigateway/restApi:RestApi example 12345abcde
> NOTE: Resource import does not currently support the body attribute.
Constructors
- RestApi(String name, {RestApiArgs? args, CustomResourceOptions? options})
-
Creates a new RestApi.
nameThe Pulumi resource name.argsArguments used to configure this RestApi. The set of arguments for RestApi.optionsResource options controlling this resource's behavior. - RestApi.reference(String urn)
- Creates a typed reference to an existing RestApi resource.
Properties
-
apiKeySource
↔ Output<
String> -
Source of the API key for requests. Valid values are
HEADER(default) andAUTHORIZER. If importing an OpenAPI specification via thebodyargument, this corresponds to thex-amazon-apigateway-api-key-sourceextension. If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.latefinal -
arn
↔ Output<
String> -
ARN
latefinal
-
binaryMediaTypes
↔ Output<
List< String> > -
List of binary media types supported by the REST API. By default, the REST API supports only UTF-8-encoded text payloads. If importing an OpenAPI specification via the
bodyargument, this corresponds to thex-amazon-apigateway-binary-media-typesextension. If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.latefinal -
body
↔ Output<
String?> -
OpenAPI specification that defines the set of routes and integrations to create as part of the REST API. This configuration, and any updates to it, will replace all REST API configuration except values overridden in this resource configuration and other resource updates applied after this resource but before any
aws.apigateway.Deploymentcreation. More information about REST API OpenAPI support can be found in the API Gateway Developer Guide.latefinal -
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
createdDate
↔ Output<
String> -
Creation date of the REST API
latefinal
-
description
↔ Output<
String> -
Description of the REST API. If importing an OpenAPI specification via the
bodyargument, this corresponds to theinfo.descriptionfield. If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.latefinal -
disableExecuteApiEndpoint
↔ Output<
bool> -
Whether clients can invoke your API by using the default execute-api endpoint. By default, clients can invoke your API with the default https://{api_id}.execute-api.{region}.amazonaws.com endpoint. To require that clients use a custom domain name to invoke your API, disable the default endpoint. Defaults to
false. If importing an OpenAPI specification via thebodyargument, this corresponds to thex-amazon-apigateway-endpoint-configurationextensiondisableExecuteApiEndpointproperty. If the argument value istrueand is different than the OpenAPI value, the argument value will override the OpenAPI value.latefinal -
endpointAccessMode
↔ Output<
String?> -
Endpoint access mode for the REST API. Valid values are
BASICandSTRICT. Only available for REST APIs that use asecurityPolicyvalue beginning withSecurityPolicy_and is required when one of those values is configured.latefinal -
endpointConfiguration
↔ Output<
RestApiEndpointConfiguration> -
Configuration block defining API endpoint configuration including endpoint type. Defined below.
latefinal
-
executionArn
↔ Output<
String> -
Execution ARN part to be used in
lambdaPermission'ssourceArnwhen allowing API Gateway to invoke a Lambda function, e.g.,arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j, which can be concatenated with allowed stage, method and resource path.latefinal -
failOnWarnings
↔ Output<
bool?> -
Whether to return an error for warnings while API Gateway is creating or updating the resource. Defaults to
false.latefinal - hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
minimumCompressionSize
↔ Output<
String> -
Minimum response size to compress for the REST API. String containing an integer value between
-1and10485760(10MB).-1will disable an existing compression configuration, and all other values will enable compression with the configured size. New resources can simply omit this argument to disable compression, rather than setting the value to-1. If importing an OpenAPI specification via thebodyargument, this corresponds to thex-amazon-apigateway-minimum-compression-sizeextension. If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.latefinal -
name
↔ Output<
String> -
Name of the REST API. If importing an OpenAPI specification via the
bodyargument, this corresponds to theinfo.titlefield. If the argument value is different than the OpenAPI value, the argument value will override the OpenAPI value.latefinal -
parameters
↔ Output<
Map< String, String> ?> -
Map of customizations for importing the specification in the
bodyargument. For example, to exclude DocumentationParts from an imported API, setignoreequal todocumentation. Additional documentation, including other parameters such asbasepath, can be found in the API Gateway Developer Guide.latefinal -
policy
↔ Output<
String> -
JSON formatted policy document that controls access to the API Gateway. For more information about building AWS IAM policy documents with Pulumi, see the AWS IAM Policy Document Guide. The provider will only perform drift detection of its value when present in a configuration. We recommend using the
aws.apigateway.RestApiPolicyresource instead. If importing an OpenAPI specification via thebodyargument, this corresponds to thex-amazon-apigateway-policyextension. If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.latefinal -
putRestApiMode
↔ Output<
String?> -
Mode of the PutRestApi operation when importing an OpenAPI specification via the
bodyargument (create or update operation). Valid values aremergeandoverwrite. If not configured, defaults tooverwrite(for backwards compatibility). This corresponds to thex-amazon-apigateway-put-integration-methodextension. If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.latefinal -
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
rootResourceId
↔ Output<
String> -
Resource ID of the REST API's root
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
securityPolicy
↔ Output<
String> -
TLS version + cipher suite for the REST API's default execute-api endpoint. Must be configured for drift detection. When set to a value beginning with
SecurityPolicy_,endpointAccessModemust also be configured. For a list of valid security policies, see CreateRestApi in the Amazon API Gateway API Reference.latefinal -
Key-value map of resource tags. If configured with a provider
defaultTagsconfiguration block present, tags with matching keys will overwrite those defined at the provider-level.latefinal -
Map of tags assigned to the resource, including those inherited from the provider
defaultTagsconfiguration block.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited