Class RestApi


  • public class RestApi
    extends com.pulumi.resources.CustomResource
    Manages an API Gateway REST API. The REST API can be configured via [importing an OpenAPI specification](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-import-api.html) 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
     
     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());
     
         }
     }
     
     
    #### 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: ```sh $ pulumi import aws:apigateway/restApi:RestApi example 12345abcde ``` > **NOTE:** Resource import does not currently support the `body` attribute.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      RestApi​(java.lang.String name)  
      RestApi​(java.lang.String name, RestApiArgs args)  
      RestApi​(java.lang.String name, RestApiArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> apiKeySource()  
      com.pulumi.core.Output<java.lang.String> arn()  
      com.pulumi.core.Output<java.util.List<java.lang.String>> binaryMediaTypes()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> body()  
      com.pulumi.core.Output<java.lang.String> createdDate()  
      com.pulumi.core.Output<java.lang.String> description()  
      com.pulumi.core.Output<java.lang.Boolean> disableExecuteApiEndpoint()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> endpointAccessMode()  
      com.pulumi.core.Output<RestApiEndpointConfiguration> endpointConfiguration()  
      com.pulumi.core.Output<java.lang.String> executionArn()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> failOnWarnings()  
      static RestApi get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, RestApiState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> minimumCompressionSize()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> parameters()  
      com.pulumi.core.Output<java.lang.String> policy()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> putRestApiMode()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.lang.String> rootResourceId()  
      com.pulumi.core.Output<java.lang.String> securityPolicy()  
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> tags()  
      com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.String>> tagsAll()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RestApi

        public RestApi​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • RestApi

        public RestApi​(java.lang.String name,
                       @Nullable
                       RestApiArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • RestApi

        public RestApi​(java.lang.String name,
                       @Nullable
                       RestApiArgs args,
                       @Nullable
                       com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • apiKeySource

        public com.pulumi.core.Output<java.lang.String> apiKeySource()
        Returns:
        Source of the API key for requests. Valid values are `HEADER` (default) and `AUTHORIZER`. If importing an OpenAPI specification via the `body` argument, this corresponds to the [`x-amazon-apigateway-api-key-source` extension](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-api-key-source.html). If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.
      • arn

        public com.pulumi.core.Output<java.lang.String> arn()
        Returns:
        ARN
      • binaryMediaTypes

        public com.pulumi.core.Output<java.util.List<java.lang.String>> binaryMediaTypes()
        Returns:
        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 `body` argument, this corresponds to the [`x-amazon-apigateway-binary-media-types` extension](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-binary-media-types.html). If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.
      • body

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> body()
        Returns:
        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.Deployment` creation. More information about REST API OpenAPI support can be found in the [API Gateway Developer Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-import-api.html).
      • createdDate

        public com.pulumi.core.Output<java.lang.String> createdDate()
        Returns:
        Creation date of the REST API
      • description

        public com.pulumi.core.Output<java.lang.String> description()
        Returns:
        Description of the REST API. If importing an OpenAPI specification via the `body` argument, this corresponds to the `info.description` field. If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.
      • disableExecuteApiEndpoint

        public com.pulumi.core.Output<java.lang.Boolean> disableExecuteApiEndpoint()
        Returns:
        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 the `body` argument, this corresponds to the [`x-amazon-apigateway-endpoint-configuration` extension `disableExecuteApiEndpoint` property](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-endpoint-configuration.html). If the argument value is `true` and is different than the OpenAPI value, the argument value will override the OpenAPI value.
      • endpointAccessMode

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> endpointAccessMode()
        Returns:
        Endpoint access mode for the REST API. Valid values are `BASIC` and `STRICT`. Only available for REST APIs that use a `securityPolicy` value beginning with `SecurityPolicy_` and is required when one of those values is configured.
      • endpointConfiguration

        public com.pulumi.core.Output<RestApiEndpointConfiguration> endpointConfiguration()
        Returns:
        Configuration block defining API endpoint configuration including endpoint type. Defined below.
      • executionArn

        public com.pulumi.core.Output<java.lang.String> executionArn()
        Returns:
        Execution ARN part to be used in `lambdaPermission`'s `sourceArn` when 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.
      • failOnWarnings

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> failOnWarnings()
        Returns:
        Whether to return an error for warnings while API Gateway is creating or updating the resource. Defaults to `false`.
      • minimumCompressionSize

        public com.pulumi.core.Output<java.lang.String> minimumCompressionSize()
        Returns:
        Minimum response size to compress for the REST API. String containing an integer value between `-1` and `10485760` (10MB). `-1` will 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 the `body` argument, this corresponds to the [`x-amazon-apigateway-minimum-compression-size` extension](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-openapi-minimum-compression-size.html). If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        Name of the REST API. If importing an OpenAPI specification via the `body` argument, this corresponds to the `info.title` field. If the argument value is different than the OpenAPI value, the argument value will override the OpenAPI value.
      • parameters

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> parameters()
        Returns:
        Map of customizations for importing the specification in the `body` argument. For example, to exclude DocumentationParts from an imported API, set `ignore` equal to `documentation`. Additional documentation, including other parameters such as `basepath`, can be found in the [API Gateway Developer Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-import-api.html).
      • policy

        public com.pulumi.core.Output<java.lang.String> policy()
        Returns:
        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.RestApiPolicy` resource instead. If importing an OpenAPI specification via the `body` argument, this corresponds to the [`x-amazon-apigateway-policy` extension](https://docs.aws.amazon.com/apigateway/latest/openapi-extensions-policy.html). If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.
      • putRestApiMode

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> putRestApiMode()
        Returns:
        Mode of the PutRestApi operation when importing an OpenAPI specification via the `body` argument (create or update operation). Valid values are `merge` and `overwrite`. If not configured, defaults to `overwrite` (for backwards compatibility). This corresponds to the [`x-amazon-apigateway-put-integration-method` extension](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-put-integration-method.html). If the argument value is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • rootResourceId

        public com.pulumi.core.Output<java.lang.String> rootResourceId()
        Returns:
        Resource ID of the REST API's root
      • securityPolicy

        public com.pulumi.core.Output<java.lang.String> securityPolicy()
        Returns:
        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_`, `endpointAccessMode` must also be configured. For a list of valid security policies, see [CreateRestApi](https://docs.aws.amazon.com/apigateway/latest/api/API_CreateRestApi.html) in the Amazon API Gateway API Reference.
      • tags

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> tags()
        Returns:
        Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
      • tagsAll

        public com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.String>> tagsAll()
        Returns:
        Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
      • get

        public static RestApi get​(java.lang.String name,
                                  com.pulumi.core.Output<java.lang.String> id,
                                  @Nullable
                                  RestApiState state,
                                  @Nullable
                                  com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.