MethodSettings

class MethodSettings : KotlinCustomResource

/* Manages API Gateway Stage Method Settings. For example, CloudWatch logging and metrics.

NOTE: We recommend using this resource in conjunction with the aws.apigateway.Stage resource instead of a stage managed by the aws.apigateway.Deployment resource optional stage_name argument. Stages managed by the aws.apigateway.Deployment resource are recreated on redeployment and this resource will require a second apply to recreate the method settings.

Example Usage

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.Deployment;
import com.pulumi.aws.apigateway.DeploymentArgs;
import com.pulumi.aws.apigateway.Stage;
import com.pulumi.aws.apigateway.StageArgs;
import com.pulumi.aws.apigateway.MethodSettings;
import com.pulumi.aws.apigateway.MethodSettingsArgs;
import com.pulumi.aws.apigateway.inputs.MethodSettingsSettingsArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
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 exampleRestApi = new RestApi("exampleRestApi", RestApiArgs.builder()
.body(serializeJson(
jsonObject(
jsonProperty("openapi", "3.0.1"),
jsonProperty("info", jsonObject(
jsonProperty("title", "example"),
jsonProperty("version", "1.0")
)),
jsonProperty("paths", jsonObject(
jsonProperty("/path1", jsonObject(
jsonProperty("get", jsonObject(
jsonProperty("x-amazon-apigateway-integration", jsonObject(
jsonProperty("httpMethod", "GET"),
jsonProperty("payloadFormatVersion", "1.0"),
jsonProperty("type", "HTTP_PROXY"),
jsonProperty("uri", "https://ip-ranges.amazonaws.com/ip-ranges.json")
))
))
))
))
)))
.build());
var exampleDeployment = new Deployment("exampleDeployment", DeploymentArgs.builder()
.restApi(exampleRestApi.id())
.triggers(Map.of("redeployment", exampleRestApi.body().applyValue(body -> serializeJson(
body)).applyValue(toJSON -> computeSHA1(toJSON))))
.build());
var exampleStage = new Stage("exampleStage", StageArgs.builder()
.deployment(exampleDeployment.id())
.restApi(exampleRestApi.id())
.stageName("example")
.build());
var all = new MethodSettings("all", MethodSettingsArgs.builder()
.restApi(exampleRestApi.id())
.stageName(exampleStage.stageName())
.methodPath("*/*")
.settings(MethodSettingsSettingsArgs.builder()
.metricsEnabled(true)
.loggingLevel("ERROR")
.build())
.build());
var pathSpecific = new MethodSettings("pathSpecific", MethodSettingsArgs.builder()
.restApi(exampleRestApi.id())
.stageName(exampleStage.stageName())
.methodPath("path1/GET")
.settings(MethodSettingsSettingsArgs.builder()
.metricsEnabled(true)
.loggingLevel("INFO")
.build())
.build());
}
}

Import

aws_api_gateway_method_settings can be imported using REST-API-ID/STAGE-NAME/METHOD-PATH, e.g.,

$ pulumi import aws:apigateway/methodSettings:MethodSettings example 12345abcde/example/test/GET

Properties

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val methodPath: Output<String>

/* Method path defined as {resource_path}/{http_method} for an individual method override, or */* for overriding all methods in the stage. Ensure to trim any leading forward slashes in the path (e.g., trimprefix(aws_api_gateway_resource.example.path, "/")).

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val restApi: Output<String>

ID of the REST API

Link copied to clipboard

Settings block, see below.

Link copied to clipboard
val stageName: Output<String>

Name of the stage

Link copied to clipboard
val urn: Output<String>