Class Api


  • public class Api
    extends com.pulumi.resources.CustomResource
    Manages an Amazon API Gateway Version 2 API. > **Note:** Amazon API Gateway Version 2 resources are used for creating and deploying WebSocket and HTTP APIs. To create and deploy REST APIs, use Amazon API Gateway Version 1 resources. ## Example Usage ### Basic WebSocket API
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.apigatewayv2.Api;
     import com.pulumi.aws.apigatewayv2.ApiArgs;
     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 Api("example", ApiArgs.builder()
                 .name("example-websocket-api")
                 .protocolType("WEBSOCKET")
                 .routeSelectionExpression("$request.body.action")
                 .build());
     
         }
     }
     
     
    ### Basic HTTP API
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.apigatewayv2.Api;
     import com.pulumi.aws.apigatewayv2.ApiArgs;
     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 Api("example", ApiArgs.builder()
                 .name("example-http-api")
                 .protocolType("HTTP")
                 .build());
     
         }
     }
     
     
    > **Note:** If the `body` argument is provided, the OpenAPI specification will be used to configure the integrations and routes for the HTTP API, and the `aws.apigatewayv2.Integration` and `aws.apigatewayv2.Route` resources should not be managed as separate ones, as updates may cause manual resource updates to be overwritten. The `name`, `description`, `corsConfiguration`, `tags`, and `version` fields should be specified in the Terraform configuration and their values will override any values specified in the OpenAPI document. ## Import ### Identity Schema #### Required * `id` (String) API identifier. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import `aws.apigatewayv2.Api` using the API identifier. For example: ```sh $ pulumi import aws:apigatewayv2/api:Api example aabbccddee ```
    • 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
      Api​(java.lang.String name)  
      Api​(java.lang.String name, ApiArgs args)  
      Api​(java.lang.String name, ApiArgs 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> apiEndpoint()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> apiKeySelectionExpression()  
      com.pulumi.core.Output<java.lang.String> arn()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> body()  
      com.pulumi.core.Output<java.util.Optional<ApiCorsConfiguration>> corsConfiguration()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> credentialsArn()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> disableExecuteApiEndpoint()  
      com.pulumi.core.Output<java.lang.String> executionArn()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> failOnWarnings()  
      static Api get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, ApiState 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> ipAddressType()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.lang.String> protocolType()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> routeKey()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> routeSelectionExpression()  
      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()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> target()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> version()  
      • 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

      • Api

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

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

        public Api​(java.lang.String name,
                   ApiArgs 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

      • apiEndpoint

        public com.pulumi.core.Output<java.lang.String> apiEndpoint()
        Returns:
        URI of the API, of the form `https://{api-id}.execute-api.{region}.amazonaws.com` for HTTP APIs and `wss://{api-id}.execute-api.{region}.amazonaws.com` for WebSocket APIs.
      • apiKeySelectionExpression

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> apiKeySelectionExpression()
        Returns:
        [API key selection expression](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-apikey-selection-expressions). Valid values: `$context.authorizer.usageIdentifierKey`, `$request.header.x-api-key`. Defaults to `$request.header.x-api-key`. Applicable for WebSocket APIs.
      • arn

        public com.pulumi.core.Output<java.lang.String> arn()
        Returns:
        ARN of the API.
      • 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 HTTP APIs. Supported only for HTTP APIs.
      • corsConfiguration

        public com.pulumi.core.Output<java.util.Optional<ApiCorsConfiguration>> corsConfiguration()
        Returns:
        Cross-origin resource sharing (CORS) [configuration](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html). Applicable for HTTP APIs. See `corsConfiguration` Block below.
      • credentialsArn

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> credentialsArn()
        Returns:
        Part of _quick create_. Specifies any credentials required for the integration. Applicable for HTTP APIs.
      • description

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()
        Returns:
        Description of the API. Must be less than or equal to 1024 characters in length.
      • disableExecuteApiEndpoint

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> disableExecuteApiEndpoint()
        Returns:
        Whether clients can invoke the API by using the default `execute-api` endpoint. By default, clients can invoke the API with the default `{api_id}.execute-api.{region}.amazonaws.com endpoint`. To require that clients use a custom domain name to invoke the API, disable the default endpoint.
      • executionArn

        public com.pulumi.core.Output<java.lang.String> executionArn()
        Returns:
        ARN prefix to be used in an `aws.lambda.Permission`'s `sourceArn` attribute or in an `aws.iam.Policy` to authorize access to the [`@connections` API](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html). See the [Amazon API Gateway Developer Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-control-access-iam.html) for details.
      • failOnWarnings

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

        public com.pulumi.core.Output<java.lang.String> ipAddressType()
        Returns:
        IP address types that can invoke the API. Valid values: `ipv4`, `dualstack`. Use `ipv4` to allow only IPv4 addresses to invoke your API, or use `dualstack` to allow both IPv4 and IPv6 addresses to invoke your API. Defaults to `ipv4`.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        Name of the API. Must be less than or equal to 128 characters in length.
      • protocolType

        public com.pulumi.core.Output<java.lang.String> protocolType()
        Returns:
        API protocol. Valid values: `HTTP`, `WEBSOCKET`. The following arguments are optional:
      • 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.
      • routeKey

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> routeKey()
        Returns:
        Part of _quick create_. Specifies any [route key](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html). Applicable for HTTP APIs.
      • routeSelectionExpression

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> routeSelectionExpression()
        Returns:
        [Route selection expression](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-route-selection-expressions) for the API. Defaults to `$request.method $request.path`.
      • tags

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> tags()
        Returns:
        Map of tags to assign to the API. 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.
      • target

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> target()
        Returns:
        Part of _quick create_. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be `HTTP_PROXY` or `AWS_PROXY`, respectively. Applicable for HTTP APIs.
      • version

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> version()
        Returns:
        Version identifier for the API. Must be between 1 and 64 characters in length.
      • get

        public static Api get​(java.lang.String name,
                              com.pulumi.core.Output<java.lang.String> id,
                              @Nullable
                              ApiState 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.