RestApiPut class

Resource for updating an AWS API Gateway REST API with a new API description.

> NOTE: When importing an OpenAPI specification using the body argument, the info.title field updates the name of the aws.apigateway.RestApi. If the imported title differs from the configured name, Terraform will report the difference.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.apigateway.RestApiPut("example", {
    body: JSON.stringify({
        swagger: "2.0",
        info: {
            title: "Example API",
            version: "v1",
        },
        schemes: ["https"],
        paths: {
            "/example": {
                get: {
                    responses: {
                        "200": {
                            description: "OK",
                        },
                    },
                    "x-amazon-apigateway-integration": {
                        httpMethod: "GET",
                        type: "HTTP",
                        responses: {
                            "default": {
                                statusCode: 200,
                            },
                        },
                        uri: "https://api.example.com/",
                    },
                },
            },
        },
    }),
    failOnWarnings: true,
    restApiId: exampleAwsApiGatewayRestApi.id,
});
import pulumi
import json
import pulumi_aws as aws

example = aws.apigateway.RestApiPut("example",
    body=json.dumps({
        "swagger": "2.0",
        "info": {
            "title": "Example API",
            "version": "v1",
        },
        "schemes": ["https"],
        "paths": {
            "/example": {
                "get": {
                    "responses": {
                        "200": {
                            "description": "OK",
                        },
                    },
                    "x-amazon-apigateway-integration": {
                        "httpMethod": "GET",
                        "type": "HTTP",
                        "responses": {
                            "default": {
                                "statusCode": 200,
                            },
                        },
                        "uri": "https://api.example.com/",
                    },
                },
            },
        },
    }),
    fail_on_warnings=True,
    rest_api_id=example_aws_api_gateway_rest_api["id"])
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.ApiGateway.RestApiPut("example", new()
    {
        Body = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["swagger"] = "2.0",
            ["info"] = new Dictionary<string, object?>
            {
                ["title"] = "Example API",
                ["version"] = "v1",
            },
            ["schemes"] = new[]
            {
                "https",
            },
            ["paths"] = new Dictionary<string, object?>
            {
                ["/example"] = new Dictionary<string, object?>
                {
                    ["get"] = new Dictionary<string, object?>
                    {
                        ["responses"] = new Dictionary<string, object?>
                        {
                            ["200"] = new Dictionary<string, object?>
                            {
                                ["description"] = "OK",
                            },
                        },
                        ["x-amazon-apigateway-integration"] = new Dictionary<string, object?>
                        {
                            ["httpMethod"] = "GET",
                            ["type"] = "HTTP",
                            ["responses"] = new Dictionary<string, object?>
                            {
                                ["default"] = new Dictionary<string, object?>
                                {
                                    ["statusCode"] = 200,
                                },
                            },
                            ["uri"] = "https://api.example.com/",
                        },
                    },
                },
            },
        }),
        FailOnWarnings = true,
        RestApiId = exampleAwsApiGatewayRestApi.Id,
    });

});
package main

import (
	"encoding/json"

	"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 {
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"swagger": "2.0",
			"info": map[string]string{
				"title":   "Example API",
				"version": "v1",
			},
			"schemes": []string{
				"https",
			},
			"paths": map[string]map[string]map[string]interface{}{
				"/example": map[string]map[string]interface{}{
					"get": map[string]interface{}{
						"responses": map[string]map[string]string{
							"200": map[string]string{
								"description": "OK",
							},
						},
						"x-amazon-apigateway-integration": map[string]interface{}{
							"httpMethod": "GET",
							"type":       "HTTP",
							"responses": map[string]map[string]int{
								"default": map[string]int{
									"statusCode": 200,
								},
							},
							"uri": "https://api.example.com/",
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = apigateway.NewRestApiPut(ctx, "example", &apigateway.RestApiPutArgs{
			Body:           pulumi.String(json0),
			FailOnWarnings: pulumi.Bool(true),
			RestApiId:      pulumi.Any(exampleAwsApiGatewayRestApi.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_apigateway_restapiput" "example" {
  body = jsonencode({
    "swagger" = "2.0"
    "info" = {
      "title"   = "Example API"
      "version" = "v1"
    }
    "schemes" = ["https"]
    "paths" = {
      "/example" = {
        "get" = {
          "responses" = {
            "200" = {
              "description" = "OK"
            }
          }
          "x-amazon-apigateway-integration" = {
            "httpMethod" = "GET"
            "type"       = "HTTP"
            "responses" = {
              "default" = {
                "statusCode" = 200
              }
            }
            "uri" = "https://api.example.com/"
          }
        }
      }
    }
  })
  fail_on_warnings = true
  rest_api_id      = exampleAwsApiGatewayRestApi.id
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.RestApiPut;
import com.pulumi.aws.apigateway.RestApiPutArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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 RestApiPut("example", RestApiPutArgs.builder()
            .body(serializeJson(
                jsonObject(
                    jsonProperty("swagger", "2.0"),
                    jsonProperty("info", jsonObject(
                        jsonProperty("title", "Example API"),
                        jsonProperty("version", "v1")
                    )),
                    jsonProperty("schemes", jsonArray("https")),
                    jsonProperty("paths", jsonObject(
                        jsonProperty("/example", jsonObject(
                            jsonProperty("get", jsonObject(
                                jsonProperty("responses", jsonObject(
                                    jsonProperty("200", jsonObject(
                                        jsonProperty("description", "OK")
                                    ))
                                )),
                                jsonProperty("x-amazon-apigateway-integration", jsonObject(
                                    jsonProperty("httpMethod", "GET"),
                                    jsonProperty("type", "HTTP"),
                                    jsonProperty("responses", jsonObject(
                                        jsonProperty("default", jsonObject(
                                            jsonProperty("statusCode", 200)
                                        ))
                                    )),
                                    jsonProperty("uri", "https://api.example.com/")
                                ))
                            ))
                        ))
                    ))
                )))
            .failOnWarnings(true)
            .restApiId(exampleAwsApiGatewayRestApi.id())
            .build());

    }
}
resources:
  example:
    type: aws:apigateway:RestApiPut
    properties:
      body:
        fn::toJSON:
          swagger: '2.0'
          info:
            title: Example API
            version: v1
          schemes:
            - https
          paths:
            /example:
              get:
                responses:
                  '200':
                    description: OK
                x-amazon-apigateway-integration:
                  httpMethod: GET
                  type: HTTP
                  responses:
                    default:
                      statusCode: 200
                  uri: https://api.example.com/
      failOnWarnings: true
      restApiId: ${exampleAwsApiGatewayRestApi.id}

Import

Using pulumi import, import API Gateway REST API Put using the restApiId. For example:

$ pulumi import aws:apigateway/restApiPut:RestApiPut example import-id-12345678

Constructors

RestApiPut(String name, {RestApiPutArgs? args, CustomResourceOptions? options})
Creates a new RestApiPut. name The Pulumi resource name. args Arguments used to configure this RestApiPut. The set of arguments for RestApiPut. options Resource options controlling this resource's behavior.
RestApiPut.reference(String urn)
Creates a typed reference to an existing RestApiPut resource.

Properties

body ↔ Output<String>
PUT request body containing external API definitions. Currently, only OpenAPI definition JSON/YAML files are supported. The maximum size of the API definition file is 6MB.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
failOnWarnings ↔ Output<bool>
Whether to rollback the API update when a warning is encountered. The default value is 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
parameters ↔ Output<Map<String, String>?>
Map of customizations for importing the specification in the body argument. For example, to exclude DocumentationParts from an imported API, use ignore = "documentation". Additional documentation, including other parameters such as basepath, can be found in the API Gateway Developer Guide.
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
restApiId ↔ Output<String>
Identifier of the associated REST API.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
timeouts ↔ Output<RestApiPutTimeouts?>
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
triggers ↔ Output<Map<String, String>?>
Map of arbitrary keys and values that, when changed, will trigger a redeployment. To force a redeployment without changing these keys/values, use the -replace option with pulumi preview or pulumi up.
latefinal
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

Static Methods

get(String name, Input<String> id, {RestApiPutState? state, CustomResourceOptions? options}) → RestApiPut
Gets an existing RestApiPut resource's state with the given name and id.