@pulumi/aws-native
Version:
The Pulumi AWS Cloud Control Provider enables you to build, deploy, and manage [any AWS resource that's supported by the AWS Cloud Control API](https://github.com/pulumi/pulumi-aws-native/blob/master/provider/cmd/pulumi-gen-aws-native/supported-types.txt)
585 lines (584 loc) • 26.5 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* The ``AWS::ApiGateway::RestApi`` resource creates a REST API. For more information, see [restapi:create](https://docs.aws.amazon.com/apigateway/latest/api/API_CreateRestApi.html) in the *Amazon API Gateway REST API Reference*.
* On January 1, 2016, the Swagger Specification was donated to the [OpenAPI initiative](https://docs.aws.amazon.com/https://www.openapis.org/), becoming the foundation of the OpenAPI Specification.
*
* ## Example Usage
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiName = config.require("apiName");
* const description = config.require("description");
* const version = config.require("version");
* const type = config.require("type");
* const property = config.require("property");
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: apiName});
* const documentationPart = new aws_native.apigateway.DocumentationPart("documentationPart", {
* location: {
* type: aws_native.apigateway.DocumentationPartLocationType[type],
* },
* restApiId: restApi.id,
* properties: property,
* });
* const documentationVersion = new aws_native.apigateway.DocumentationVersion("documentationVersion", {
* description: description,
* documentationVersion: version,
* restApiId: restApi.id,
* }, {
* dependsOn: [documentationPart],
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiName = config.require("apiName");
* const description = config.require("description");
* const version = config.require("version");
* const type = config.require("type");
* const property = config.require("property");
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: apiName});
* const documentationPart = new aws_native.apigateway.DocumentationPart("documentationPart", {
* location: {
* type: aws_native.apigateway.DocumentationPartLocationType[type],
* },
* restApiId: restApi.id,
* properties: property,
* });
* const documentationVersion = new aws_native.apigateway.DocumentationVersion("documentationVersion", {
* description: description,
* documentationVersion: version,
* restApiId: restApi.id,
* }, {
* dependsOn: [documentationPart],
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: "myRestApi"});
* const gatewayResponse = new aws_native.apigateway.GatewayResponse("gatewayResponse", {
* responseParameters: {
* "gatewayresponse.header.Access-Control-Allow-Origin": "'*'",
* "gatewayresponse.header.Access-Control-Allow-Headers": "'*'",
* },
* responseType: "MISSING_AUTHENTICATION_TOKEN",
* restApiId: restApi.id,
* statusCode: "404",
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: "myRestApi"});
* const gatewayResponse = new aws_native.apigateway.GatewayResponse("gatewayResponse", {
* responseParameters: {
* "gatewayresponse.header.Access-Control-Allow-Origin": "'*'",
* "gatewayresponse.header.Access-Control-Allow-Headers": "'*'",
* },
* responseType: "MISSING_AUTHENTICATION_TOKEN",
* restApiId: restApi.id,
* statusCode: "404",
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiName = config.require("apiName");
* const responseParameter1 = config.require("responseParameter1");
* const responseParameter2 = config.require("responseParameter2");
* const responseType = config.require("responseType");
* const statusCode = config.require("statusCode");
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: apiName});
* const gatewayResponse = new aws_native.apigateway.GatewayResponse("gatewayResponse", {
* responseParameters: {
* "gatewayresponse.header.k1": responseParameter1,
* "gatewayresponse.header.k2": responseParameter2,
* },
* responseType: responseType,
* restApiId: restApi.id,
* statusCode: statusCode,
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiName = config.require("apiName");
* const responseParameter1 = config.require("responseParameter1");
* const responseParameter2 = config.require("responseParameter2");
* const responseType = config.require("responseType");
* const statusCode = config.require("statusCode");
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: apiName});
* const gatewayResponse = new aws_native.apigateway.GatewayResponse("gatewayResponse", {
* responseParameters: {
* "gatewayresponse.header.k1": responseParameter1,
* "gatewayresponse.header.k2": responseParameter2,
* },
* responseType: responseType,
* restApiId: restApi.id,
* statusCode: statusCode,
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const contentHandling = config.require("contentHandling");
* const operationName = config.get("operationName") || "testoperationName";
* const restApiName = config.get("restApiName") || "testrestApiName";
* const validatorName = config.get("validatorName") || "testvalidatorName";
* const validateRequestBody = config.get("validateRequestBody") || "testvalidateRequestBody";
* const validateRequestParameters = config.get("validateRequestParameters") || true;
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: restApiName});
* const requestValidator = new aws_native.apigateway.RequestValidator("requestValidator", {
* name: validatorName,
* restApiId: restApi.id,
* validateRequestBody: validateRequestBody,
* validateRequestParameters: validateRequestParameters,
* });
* const method = new aws_native.apigateway.Method("method", {
* httpMethod: "POST",
* resourceId: restApi.rootResourceId,
* restApiId: restApi.id,
* authorizationType: "NONE",
* integration: {
* type: aws_native.apigateway.MethodIntegrationType.Mock,
* contentHandling: aws_native.apigateway.MethodIntegrationContentHandling[contentHandling],
* integrationResponses: [{
* contentHandling: aws_native.apigateway.MethodIntegrationResponseContentHandling[contentHandling],
* statusCode: "400",
* }],
* },
* requestValidatorId: requestValidator.id,
* operationName: operationName,
* });
* export const rootResourceId = restApi.rootResourceId;
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const contentHandling = config.require("contentHandling");
* const operationName = config.get("operationName") || "testoperationName";
* const restApiName = config.get("restApiName") || "testrestApiName";
* const validatorName = config.get("validatorName") || "testvalidatorName";
* const validateRequestBody = config.get("validateRequestBody") || "testvalidateRequestBody";
* const validateRequestParameters = config.get("validateRequestParameters") || true;
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: restApiName});
* const requestValidator = new aws_native.apigateway.RequestValidator("requestValidator", {
* name: validatorName,
* restApiId: restApi.id,
* validateRequestBody: validateRequestBody,
* validateRequestParameters: validateRequestParameters,
* });
* const method = new aws_native.apigateway.Method("method", {
* httpMethod: "POST",
* resourceId: restApi.rootResourceId,
* restApiId: restApi.id,
* authorizationType: "NONE",
* integration: {
* type: aws_native.apigateway.MethodIntegrationType.Mock,
* contentHandling: aws_native.apigateway.MethodIntegrationContentHandling[contentHandling],
* integrationResponses: [{
* contentHandling: aws_native.apigateway.MethodIntegrationResponseContentHandling[contentHandling],
* statusCode: "400",
* }],
* },
* requestValidatorId: requestValidator.id,
* operationName: operationName,
* });
* export const rootResourceId = restApi.rootResourceId;
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiName = config.require("apiName");
* const validatorName = config.require("validatorName");
* const validateRequestBody = config.require("validateRequestBody");
* const validateRequestParameters = config.require("validateRequestParameters");
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: apiName});
* const requestValidator = new aws_native.apigateway.RequestValidator("requestValidator", {
* name: validatorName,
* restApiId: restApi.id,
* validateRequestBody: validateRequestBody,
* validateRequestParameters: validateRequestParameters,
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiName = config.require("apiName");
* const validatorName = config.require("validatorName");
* const validateRequestBody = config.require("validateRequestBody");
* const validateRequestParameters = config.require("validateRequestParameters");
* const restApi = new aws_native.apigateway.RestApi("restApi", {name: apiName});
* const requestValidator = new aws_native.apigateway.RequestValidator("requestValidator", {
* name: validatorName,
* restApiId: restApi.id,
* validateRequestBody: validateRequestBody,
* validateRequestParameters: validateRequestParameters,
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiName = config.require("apiName");
* const type = config.require("type");
* const myRestApi = new aws_native.apigateway.RestApi("myRestApi", {
* endpointConfiguration: {
* types: [type],
* },
* name: apiName,
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiName = config.require("apiName");
* const type = config.require("type");
* const myRestApi = new aws_native.apigateway.RestApi("myRestApi", {
* endpointConfiguration: {
* types: [type],
* },
* name: apiName,
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const restApi = new aws_native.apigateway.RestApi("restApi", {
* body: {
* swagger: 2,
* info: {
* version: "0.0.1",
* title: "test",
* },
* basePath: "/pete",
* schemes: ["https"],
* definitions: {
* empty: {
* type: "object",
* },
* },
* },
* name: "myApi",
* parameters: {
* endpointConfigurationTypes: "REGIONAL",
* },
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const restApi = new aws_native.apigateway.RestApi("restApi", {
* body: {
* swagger: 2,
* info: {
* version: "0.0.1",
* title: "test",
* },
* basePath: "/pete",
* schemes: ["https"],
* definitions: {
* empty: {
* type: "object",
* },
* },
* },
* name: "myApi",
* parameters: {
* endpointConfigurationTypes: "REGIONAL",
* },
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiKeySourceType = config.require("apiKeySourceType");
* const apiName = config.require("apiName");
* const binaryMediaType1 = config.require("binaryMediaType1");
* const binaryMediaType2 = config.require("binaryMediaType2");
* const minimumCompressionSize = config.require("minimumCompressionSize");
* const myRestApi = new aws_native.apigateway.RestApi("myRestApi", {
* apiKeySourceType: apiKeySourceType,
* binaryMediaTypes: [
* binaryMediaType1,
* binaryMediaType2,
* ],
* minimumCompressionSize: minimumCompressionSize,
* name: apiName,
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const config = new pulumi.Config();
* const apiKeySourceType = config.require("apiKeySourceType");
* const apiName = config.require("apiName");
* const binaryMediaType1 = config.require("binaryMediaType1");
* const binaryMediaType2 = config.require("binaryMediaType2");
* const minimumCompressionSize = config.require("minimumCompressionSize");
* const myRestApi = new aws_native.apigateway.RestApi("myRestApi", {
* apiKeySourceType: apiKeySourceType,
* binaryMediaTypes: [
* binaryMediaType1,
* binaryMediaType2,
* ],
* minimumCompressionSize: minimumCompressionSize,
* name: apiName,
* });
*
* ```
*/
export declare class RestApi extends pulumi.CustomResource {
/**
* Get an existing RestApi resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name: string, id: pulumi.Input<pulumi.ID>, opts?: pulumi.CustomResourceOptions): RestApi;
/**
* Returns true if the given object is an instance of RestApi. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj: any): obj is RestApi;
/**
* The source of the API key for metering requests according to a usage plan. Valid values are: `HEADER` to read the API key from the `X-API-Key` header of a request. `AUTHORIZER` to read the API key from the `UsageIdentifierKey` from a custom authorizer.
*/
readonly apiKeySourceType: pulumi.Output<string | undefined>;
/**
* The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.
*/
readonly binaryMediaTypes: pulumi.Output<string[] | undefined>;
/**
* An OpenAPI specification that defines a set of RESTful APIs in JSON format. For YAML templates, you can also provide the specification in YAML format.
*
* Search the [CloudFormation User Guide](https://docs.aws.amazon.com/cloudformation/) for `AWS::ApiGateway::RestApi` for more information about the expected schema for this property.
*/
readonly body: pulumi.Output<any | undefined>;
/**
* The Amazon Simple Storage Service (Amazon S3) location that points to an OpenAPI file, which defines a set of RESTful APIs in JSON or YAML format.
*/
readonly bodyS3Location: pulumi.Output<outputs.apigateway.RestApiS3Location | undefined>;
/**
* The ID of the RestApi that you want to clone from.
*/
readonly cloneFrom: pulumi.Output<string | undefined>;
/**
* The description of the RestApi.
*/
readonly description: pulumi.Output<string | undefined>;
/**
* Specifies 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
*/
readonly disableExecuteApiEndpoint: pulumi.Output<boolean | undefined>;
/**
* A list of the endpoint types and IP address types of the API. Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using the ``Parameters`` property.
*/
readonly endpointConfiguration: pulumi.Output<outputs.apigateway.RestApiEndpointConfiguration | undefined>;
/**
* A query parameter to indicate whether to rollback the API update ( `true` ) or not ( `false` ) when a warning is encountered. The default value is `false` .
*/
readonly failOnWarnings: pulumi.Output<boolean | undefined>;
/**
* A nullable integer that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (with a null value) on an API. 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.
*/
readonly minimumCompressionSize: pulumi.Output<number | undefined>;
/**
* This property applies only when you use OpenAPI to define your REST API. The ``Mode`` determines how API Gateway handles resource updates.
* Valid values are ``overwrite`` or ``merge``.
* For ``overwrite``, the new API definition replaces the existing one. The existing API identifier remains unchanged.
* For ``merge``, the new API definition is merged with the existing API.
* If you don't specify this property, a default value is chosen. For REST APIs created before March 29, 2021, the default is ``overwrite``. For REST APIs created after March 29, 2021, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API.
* Use the default mode to define top-level ``RestApi`` properties in addition to using OpenAPI. Generally, it's preferred to use API Gateway's OpenAPI extensions to model these properties.
*/
readonly mode: pulumi.Output<string | undefined>;
/**
* The name of the RestApi. A name is required if the REST API is not based on an OpenAPI specification.
*/
readonly name: pulumi.Output<string | undefined>;
/**
* Custom header parameters as part of the request. For example, to exclude DocumentationParts from an imported API, set `ignore=documentation` as a `parameters` value, as in the AWS CLI command of `aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'` .
*/
readonly parameters: pulumi.Output<{
[key: string]: string;
} | undefined>;
/**
* A policy document that contains the permissions for the ``RestApi`` resource. To set the ARN for the policy, use the ``!Join`` intrinsic function with ``""`` as delimiter and values of ``"execute-api:/"`` and ``"*"``.
*
* Search the [CloudFormation User Guide](https://docs.aws.amazon.com/cloudformation/) for `AWS::ApiGateway::RestApi` for more information about the expected schema for this property.
*/
readonly policy: pulumi.Output<any | undefined>;
/**
* The string identifier of the associated RestApi.
*/
readonly restApiId: pulumi.Output<string>;
/**
* The root resource ID for a `RestApi` resource, such as `a0bc123d4e` .
*/
readonly rootResourceId: pulumi.Output<string>;
/**
* The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The tag key can be up to 128 characters and must not start with `aws:` . The tag value can be up to 256 characters.
*/
readonly tags: pulumi.Output<outputs.Tag[] | undefined>;
/**
* Create a RestApi resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args?: RestApiArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* The set of arguments for constructing a RestApi resource.
*/
export interface RestApiArgs {
/**
* The source of the API key for metering requests according to a usage plan. Valid values are: `HEADER` to read the API key from the `X-API-Key` header of a request. `AUTHORIZER` to read the API key from the `UsageIdentifierKey` from a custom authorizer.
*/
apiKeySourceType?: pulumi.Input<string>;
/**
* The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.
*/
binaryMediaTypes?: pulumi.Input<pulumi.Input<string>[]>;
/**
* An OpenAPI specification that defines a set of RESTful APIs in JSON format. For YAML templates, you can also provide the specification in YAML format.
*
* Search the [CloudFormation User Guide](https://docs.aws.amazon.com/cloudformation/) for `AWS::ApiGateway::RestApi` for more information about the expected schema for this property.
*/
body?: any;
/**
* The Amazon Simple Storage Service (Amazon S3) location that points to an OpenAPI file, which defines a set of RESTful APIs in JSON or YAML format.
*/
bodyS3Location?: pulumi.Input<inputs.apigateway.RestApiS3LocationArgs>;
/**
* The ID of the RestApi that you want to clone from.
*/
cloneFrom?: pulumi.Input<string>;
/**
* The description of the RestApi.
*/
description?: pulumi.Input<string>;
/**
* Specifies 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
*/
disableExecuteApiEndpoint?: pulumi.Input<boolean>;
/**
* A list of the endpoint types and IP address types of the API. Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using the ``Parameters`` property.
*/
endpointConfiguration?: pulumi.Input<inputs.apigateway.RestApiEndpointConfigurationArgs>;
/**
* A query parameter to indicate whether to rollback the API update ( `true` ) or not ( `false` ) when a warning is encountered. The default value is `false` .
*/
failOnWarnings?: pulumi.Input<boolean>;
/**
* A nullable integer that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (with a null value) on an API. 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.
*/
minimumCompressionSize?: pulumi.Input<number>;
/**
* This property applies only when you use OpenAPI to define your REST API. The ``Mode`` determines how API Gateway handles resource updates.
* Valid values are ``overwrite`` or ``merge``.
* For ``overwrite``, the new API definition replaces the existing one. The existing API identifier remains unchanged.
* For ``merge``, the new API definition is merged with the existing API.
* If you don't specify this property, a default value is chosen. For REST APIs created before March 29, 2021, the default is ``overwrite``. For REST APIs created after March 29, 2021, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API.
* Use the default mode to define top-level ``RestApi`` properties in addition to using OpenAPI. Generally, it's preferred to use API Gateway's OpenAPI extensions to model these properties.
*/
mode?: pulumi.Input<string>;
/**
* The name of the RestApi. A name is required if the REST API is not based on an OpenAPI specification.
*/
name?: pulumi.Input<string>;
/**
* Custom header parameters as part of the request. For example, to exclude DocumentationParts from an imported API, set `ignore=documentation` as a `parameters` value, as in the AWS CLI command of `aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'` .
*/
parameters?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* A policy document that contains the permissions for the ``RestApi`` resource. To set the ARN for the policy, use the ``!Join`` intrinsic function with ``""`` as delimiter and values of ``"execute-api:/"`` and ``"*"``.
*
* Search the [CloudFormation User Guide](https://docs.aws.amazon.com/cloudformation/) for `AWS::ApiGateway::RestApi` for more information about the expected schema for this property.
*/
policy?: any;
/**
* The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The tag key can be up to 128 characters and must not start with `aws:` . The tag value can be up to 256 characters.
*/
tags?: pulumi.Input<pulumi.Input<inputs.TagArgs>[]>;
}