1. Packages
  2. AWS Classic
  3. API Docs
  4. apigateway
  5. MethodSettings

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.3.0 published on Thursday, Sep 28, 2023 by Pulumi

aws.apigateway.MethodSettings

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.3.0 published on Thursday, Sep 28, 2023 by Pulumi

    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

    Basic Usage

    using System.Collections.Generic;
    using System.Linq;
    using System.Security.Cryptography;
    using System.Text;
    using System.Text.Json;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    	private static string ComputeSHA1(string input) {
    		return BitConverter.ToString(
    			SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(input))
    		).Replace("-","").ToLowerInvariant());
    	}
    
    return await Deployment.RunAsync(() => 
    {
        var exampleRestApi = new Aws.ApiGateway.RestApi("exampleRestApi", new()
        {
            Body = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["openapi"] = "3.0.1",
                ["info"] = new Dictionary<string, object?>
                {
                    ["title"] = "example",
                    ["version"] = "1.0",
                },
                ["paths"] = new Dictionary<string, object?>
                {
                    ["/path1"] = new Dictionary<string, object?>
                    {
                        ["get"] = new Dictionary<string, object?>
                        {
                            ["x-amazon-apigateway-integration"] = new Dictionary<string, object?>
                            {
                                ["httpMethod"] = "GET",
                                ["payloadFormatVersion"] = "1.0",
                                ["type"] = "HTTP_PROXY",
                                ["uri"] = "https://ip-ranges.amazonaws.com/ip-ranges.json",
                            },
                        },
                    },
                },
            }),
        });
    
        var exampleDeployment = new Aws.ApiGateway.Deployment("exampleDeployment", new()
        {
            RestApi = exampleRestApi.Id,
            Triggers = 
            {
                { "redeployment", exampleRestApi.Body.Apply(body => JsonSerializer.Serialize(body)).Apply(toJSON => ComputeSHA1(toJSON)) },
            },
        });
    
        var exampleStage = new Aws.ApiGateway.Stage("exampleStage", new()
        {
            Deployment = exampleDeployment.Id,
            RestApi = exampleRestApi.Id,
            StageName = "example",
        });
    
        var all = new Aws.ApiGateway.MethodSettings("all", new()
        {
            RestApi = exampleRestApi.Id,
            StageName = exampleStage.StageName,
            MethodPath = "*/*",
            Settings = new Aws.ApiGateway.Inputs.MethodSettingsSettingsArgs
            {
                MetricsEnabled = true,
                LoggingLevel = "ERROR",
            },
        });
    
        var pathSpecific = new Aws.ApiGateway.MethodSettings("pathSpecific", new()
        {
            RestApi = exampleRestApi.Id,
            StageName = exampleStage.StageName,
            MethodPath = "path1/GET",
            Settings = new Aws.ApiGateway.Inputs.MethodSettingsSettingsArgs
            {
                MetricsEnabled = true,
                LoggingLevel = "INFO",
            },
        });
    
    });
    
    package main
    
    import (
    	"crypto/sha1"
    	"encoding/json"
    	"fmt"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func sha1Hash(input string) string {
    	hash := sha1.Sum([]byte(input))
    	return hex.EncodeToString(hash[:])
    }
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"openapi": "3.0.1",
    			"info": map[string]interface{}{
    				"title":   "example",
    				"version": "1.0",
    			},
    			"paths": map[string]interface{}{
    				"/path1": map[string]interface{}{
    					"get": map[string]interface{}{
    						"x-amazon-apigateway-integration": map[string]interface{}{
    							"httpMethod":           "GET",
    							"payloadFormatVersion": "1.0",
    							"type":                 "HTTP_PROXY",
    							"uri":                  "https://ip-ranges.amazonaws.com/ip-ranges.json",
    						},
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		exampleRestApi, err := apigateway.NewRestApi(ctx, "exampleRestApi", &apigateway.RestApiArgs{
    			Body: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		exampleDeployment, err := apigateway.NewDeployment(ctx, "exampleDeployment", &apigateway.DeploymentArgs{
    			RestApi: exampleRestApi.ID(),
    			Triggers: pulumi.StringMap{
    				"redeployment": exampleRestApi.Body.ApplyT(func(body *string) (pulumi.String, error) {
    					var _zero pulumi.String
    					tmpJSON1, err := json.Marshal(body)
    					if err != nil {
    						return _zero, err
    					}
    					json1 := string(tmpJSON1)
    					return pulumi.String(json1), nil
    				}).(pulumi.StringOutput).ApplyT(func(toJSON string) (pulumi.String, error) {
    					return pulumi.String(sha1Hash(toJSON)), nil
    				}).(pulumi.StringOutput),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		exampleStage, err := apigateway.NewStage(ctx, "exampleStage", &apigateway.StageArgs{
    			Deployment: exampleDeployment.ID(),
    			RestApi:    exampleRestApi.ID(),
    			StageName:  pulumi.String("example"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = apigateway.NewMethodSettings(ctx, "all", &apigateway.MethodSettingsArgs{
    			RestApi:    exampleRestApi.ID(),
    			StageName:  exampleStage.StageName,
    			MethodPath: pulumi.String("*/*"),
    			Settings: &apigateway.MethodSettingsSettingsArgs{
    				MetricsEnabled: pulumi.Bool(true),
    				LoggingLevel:   pulumi.String("ERROR"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = apigateway.NewMethodSettings(ctx, "pathSpecific", &apigateway.MethodSettingsArgs{
    			RestApi:    exampleRestApi.ID(),
    			StageName:  exampleStage.StageName,
    			MethodPath: pulumi.String("path1/GET"),
    			Settings: &apigateway.MethodSettingsSettingsArgs{
    				MetricsEnabled: pulumi.Bool(true),
    				LoggingLevel:   pulumi.String("INFO"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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 pulumi
    import hashlib
    import json
    import pulumi_aws as aws
    
    example_rest_api = aws.apigateway.RestApi("exampleRestApi", body=json.dumps({
        "openapi": "3.0.1",
        "info": {
            "title": "example",
            "version": "1.0",
        },
        "paths": {
            "/path1": {
                "get": {
                    "x-amazon-apigateway-integration": {
                        "httpMethod": "GET",
                        "payloadFormatVersion": "1.0",
                        "type": "HTTP_PROXY",
                        "uri": "https://ip-ranges.amazonaws.com/ip-ranges.json",
                    },
                },
            },
        },
    }))
    example_deployment = aws.apigateway.Deployment("exampleDeployment",
        rest_api=example_rest_api.id,
        triggers={
            "redeployment": example_rest_api.body.apply(lambda body: json.dumps(body)).apply(lambda to_json: hashlib.sha1(to_json.encode()).hexdigest()),
        })
    example_stage = aws.apigateway.Stage("exampleStage",
        deployment=example_deployment.id,
        rest_api=example_rest_api.id,
        stage_name="example")
    all = aws.apigateway.MethodSettings("all",
        rest_api=example_rest_api.id,
        stage_name=example_stage.stage_name,
        method_path="*/*",
        settings=aws.apigateway.MethodSettingsSettingsArgs(
            metrics_enabled=True,
            logging_level="ERROR",
        ))
    path_specific = aws.apigateway.MethodSettings("pathSpecific",
        rest_api=example_rest_api.id,
        stage_name=example_stage.stage_name,
        method_path="path1/GET",
        settings=aws.apigateway.MethodSettingsSettingsArgs(
            metrics_enabled=True,
            logging_level="INFO",
        ))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    import * as crypto from "crypto";
    
    const exampleRestApi = new aws.apigateway.RestApi("exampleRestApi", {body: JSON.stringify({
        openapi: "3.0.1",
        info: {
            title: "example",
            version: "1.0",
        },
        paths: {
            "/path1": {
                get: {
                    "x-amazon-apigateway-integration": {
                        httpMethod: "GET",
                        payloadFormatVersion: "1.0",
                        type: "HTTP_PROXY",
                        uri: "https://ip-ranges.amazonaws.com/ip-ranges.json",
                    },
                },
            },
        },
    })});
    const exampleDeployment = new aws.apigateway.Deployment("exampleDeployment", {
        restApi: exampleRestApi.id,
        triggers: {
            redeployment: exampleRestApi.body.apply(body => JSON.stringify(body)).apply(toJSON => crypto.createHash('sha1').update(toJSON).digest('hex')),
        },
    });
    const exampleStage = new aws.apigateway.Stage("exampleStage", {
        deployment: exampleDeployment.id,
        restApi: exampleRestApi.id,
        stageName: "example",
    });
    const all = new aws.apigateway.MethodSettings("all", {
        restApi: exampleRestApi.id,
        stageName: exampleStage.stageName,
        methodPath: "*/*",
        settings: {
            metricsEnabled: true,
            loggingLevel: "ERROR",
        },
    });
    const pathSpecific = new aws.apigateway.MethodSettings("pathSpecific", {
        restApi: exampleRestApi.id,
        stageName: exampleStage.stageName,
        methodPath: "path1/GET",
        settings: {
            metricsEnabled: true,
            loggingLevel: "INFO",
        },
    });
    

    Coming soon!

    Off

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var pathSpecific = new Aws.ApiGateway.MethodSettings("pathSpecific", new()
        {
            RestApi = aws_api_gateway_rest_api.Example.Id,
            StageName = aws_api_gateway_stage.Example.Stage_name,
            MethodPath = "path1/GET",
            Settings = new Aws.ApiGateway.Inputs.MethodSettingsSettingsArgs
            {
                LoggingLevel = "OFF",
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := apigateway.NewMethodSettings(ctx, "pathSpecific", &apigateway.MethodSettingsArgs{
    			RestApi:    pulumi.Any(aws_api_gateway_rest_api.Example.Id),
    			StageName:  pulumi.Any(aws_api_gateway_stage.Example.Stage_name),
    			MethodPath: pulumi.String("path1/GET"),
    			Settings: &apigateway.MethodSettingsSettingsArgs{
    				LoggingLevel: pulumi.String("OFF"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.apigateway.MethodSettings;
    import com.pulumi.aws.apigateway.MethodSettingsArgs;
    import com.pulumi.aws.apigateway.inputs.MethodSettingsSettingsArgs;
    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 pathSpecific = new MethodSettings("pathSpecific", MethodSettingsArgs.builder()        
                .restApi(aws_api_gateway_rest_api.example().id())
                .stageName(aws_api_gateway_stage.example().stage_name())
                .methodPath("path1/GET")
                .settings(MethodSettingsSettingsArgs.builder()
                    .loggingLevel("OFF")
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    path_specific = aws.apigateway.MethodSettings("pathSpecific",
        rest_api=aws_api_gateway_rest_api["example"]["id"],
        stage_name=aws_api_gateway_stage["example"]["stage_name"],
        method_path="path1/GET",
        settings=aws.apigateway.MethodSettingsSettingsArgs(
            logging_level="OFF",
        ))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const pathSpecific = new aws.apigateway.MethodSettings("pathSpecific", {
        restApi: aws_api_gateway_rest_api.example.id,
        stageName: aws_api_gateway_stage.example.stage_name,
        methodPath: "path1/GET",
        settings: {
            loggingLevel: "OFF",
        },
    });
    
    resources:
      pathSpecific:
        type: aws:apigateway:MethodSettings
        properties:
          restApi: ${aws_api_gateway_rest_api.example.id}
          stageName: ${aws_api_gateway_stage.example.stage_name}
          methodPath: path1/GET
          settings:
            loggingLevel: OFF
    

    Errors Only

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var pathSpecific = new Aws.ApiGateway.MethodSettings("pathSpecific", new()
        {
            RestApi = aws_api_gateway_rest_api.Example.Id,
            StageName = aws_api_gateway_stage.Example.Stage_name,
            MethodPath = "path1/GET",
            Settings = new Aws.ApiGateway.Inputs.MethodSettingsSettingsArgs
            {
                LoggingLevel = "ERROR",
                MetricsEnabled = true,
                DataTraceEnabled = false,
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := apigateway.NewMethodSettings(ctx, "pathSpecific", &apigateway.MethodSettingsArgs{
    			RestApi:    pulumi.Any(aws_api_gateway_rest_api.Example.Id),
    			StageName:  pulumi.Any(aws_api_gateway_stage.Example.Stage_name),
    			MethodPath: pulumi.String("path1/GET"),
    			Settings: &apigateway.MethodSettingsSettingsArgs{
    				LoggingLevel:     pulumi.String("ERROR"),
    				MetricsEnabled:   pulumi.Bool(true),
    				DataTraceEnabled: pulumi.Bool(false),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.apigateway.MethodSettings;
    import com.pulumi.aws.apigateway.MethodSettingsArgs;
    import com.pulumi.aws.apigateway.inputs.MethodSettingsSettingsArgs;
    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 pathSpecific = new MethodSettings("pathSpecific", MethodSettingsArgs.builder()        
                .restApi(aws_api_gateway_rest_api.example().id())
                .stageName(aws_api_gateway_stage.example().stage_name())
                .methodPath("path1/GET")
                .settings(MethodSettingsSettingsArgs.builder()
                    .loggingLevel("ERROR")
                    .metricsEnabled(true)
                    .dataTraceEnabled(false)
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    path_specific = aws.apigateway.MethodSettings("pathSpecific",
        rest_api=aws_api_gateway_rest_api["example"]["id"],
        stage_name=aws_api_gateway_stage["example"]["stage_name"],
        method_path="path1/GET",
        settings=aws.apigateway.MethodSettingsSettingsArgs(
            logging_level="ERROR",
            metrics_enabled=True,
            data_trace_enabled=False,
        ))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const pathSpecific = new aws.apigateway.MethodSettings("pathSpecific", {
        restApi: aws_api_gateway_rest_api.example.id,
        stageName: aws_api_gateway_stage.example.stage_name,
        methodPath: "path1/GET",
        settings: {
            loggingLevel: "ERROR",
            metricsEnabled: true,
            dataTraceEnabled: false,
        },
    });
    
    resources:
      pathSpecific:
        type: aws:apigateway:MethodSettings
        properties:
          restApi: ${aws_api_gateway_rest_api.example.id}
          stageName: ${aws_api_gateway_stage.example.stage_name}
          methodPath: path1/GET
          settings:
            loggingLevel: ERROR
            metricsEnabled: true
            dataTraceEnabled: false
    

    Errors and Info Logs

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var pathSpecific = new Aws.ApiGateway.MethodSettings("pathSpecific", new()
        {
            RestApi = aws_api_gateway_rest_api.Example.Id,
            StageName = aws_api_gateway_stage.Example.Stage_name,
            MethodPath = "path1/GET",
            Settings = new Aws.ApiGateway.Inputs.MethodSettingsSettingsArgs
            {
                LoggingLevel = "INFO",
                MetricsEnabled = true,
                DataTraceEnabled = false,
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := apigateway.NewMethodSettings(ctx, "pathSpecific", &apigateway.MethodSettingsArgs{
    			RestApi:    pulumi.Any(aws_api_gateway_rest_api.Example.Id),
    			StageName:  pulumi.Any(aws_api_gateway_stage.Example.Stage_name),
    			MethodPath: pulumi.String("path1/GET"),
    			Settings: &apigateway.MethodSettingsSettingsArgs{
    				LoggingLevel:     pulumi.String("INFO"),
    				MetricsEnabled:   pulumi.Bool(true),
    				DataTraceEnabled: pulumi.Bool(false),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.apigateway.MethodSettings;
    import com.pulumi.aws.apigateway.MethodSettingsArgs;
    import com.pulumi.aws.apigateway.inputs.MethodSettingsSettingsArgs;
    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 pathSpecific = new MethodSettings("pathSpecific", MethodSettingsArgs.builder()        
                .restApi(aws_api_gateway_rest_api.example().id())
                .stageName(aws_api_gateway_stage.example().stage_name())
                .methodPath("path1/GET")
                .settings(MethodSettingsSettingsArgs.builder()
                    .loggingLevel("INFO")
                    .metricsEnabled(true)
                    .dataTraceEnabled(false)
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    path_specific = aws.apigateway.MethodSettings("pathSpecific",
        rest_api=aws_api_gateway_rest_api["example"]["id"],
        stage_name=aws_api_gateway_stage["example"]["stage_name"],
        method_path="path1/GET",
        settings=aws.apigateway.MethodSettingsSettingsArgs(
            logging_level="INFO",
            metrics_enabled=True,
            data_trace_enabled=False,
        ))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const pathSpecific = new aws.apigateway.MethodSettings("pathSpecific", {
        restApi: aws_api_gateway_rest_api.example.id,
        stageName: aws_api_gateway_stage.example.stage_name,
        methodPath: "path1/GET",
        settings: {
            loggingLevel: "INFO",
            metricsEnabled: true,
            dataTraceEnabled: false,
        },
    });
    
    resources:
      pathSpecific:
        type: aws:apigateway:MethodSettings
        properties:
          restApi: ${aws_api_gateway_rest_api.example.id}
          stageName: ${aws_api_gateway_stage.example.stage_name}
          methodPath: path1/GET
          settings:
            loggingLevel: INFO
            metricsEnabled: true
            dataTraceEnabled: false
    

    Full Request and Response Logs

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var pathSpecific = new Aws.ApiGateway.MethodSettings("pathSpecific", new()
        {
            RestApi = aws_api_gateway_rest_api.Example.Id,
            StageName = aws_api_gateway_stage.Example.Stage_name,
            MethodPath = "path1/GET",
            Settings = new Aws.ApiGateway.Inputs.MethodSettingsSettingsArgs
            {
                LoggingLevel = "INFO",
                MetricsEnabled = true,
                DataTraceEnabled = true,
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := apigateway.NewMethodSettings(ctx, "pathSpecific", &apigateway.MethodSettingsArgs{
    			RestApi:    pulumi.Any(aws_api_gateway_rest_api.Example.Id),
    			StageName:  pulumi.Any(aws_api_gateway_stage.Example.Stage_name),
    			MethodPath: pulumi.String("path1/GET"),
    			Settings: &apigateway.MethodSettingsSettingsArgs{
    				LoggingLevel:     pulumi.String("INFO"),
    				MetricsEnabled:   pulumi.Bool(true),
    				DataTraceEnabled: pulumi.Bool(true),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.apigateway.MethodSettings;
    import com.pulumi.aws.apigateway.MethodSettingsArgs;
    import com.pulumi.aws.apigateway.inputs.MethodSettingsSettingsArgs;
    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 pathSpecific = new MethodSettings("pathSpecific", MethodSettingsArgs.builder()        
                .restApi(aws_api_gateway_rest_api.example().id())
                .stageName(aws_api_gateway_stage.example().stage_name())
                .methodPath("path1/GET")
                .settings(MethodSettingsSettingsArgs.builder()
                    .loggingLevel("INFO")
                    .metricsEnabled(true)
                    .dataTraceEnabled(true)
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    path_specific = aws.apigateway.MethodSettings("pathSpecific",
        rest_api=aws_api_gateway_rest_api["example"]["id"],
        stage_name=aws_api_gateway_stage["example"]["stage_name"],
        method_path="path1/GET",
        settings=aws.apigateway.MethodSettingsSettingsArgs(
            logging_level="INFO",
            metrics_enabled=True,
            data_trace_enabled=True,
        ))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const pathSpecific = new aws.apigateway.MethodSettings("pathSpecific", {
        restApi: aws_api_gateway_rest_api.example.id,
        stageName: aws_api_gateway_stage.example.stage_name,
        methodPath: "path1/GET",
        settings: {
            loggingLevel: "INFO",
            metricsEnabled: true,
            dataTraceEnabled: true,
        },
    });
    
    resources:
      pathSpecific:
        type: aws:apigateway:MethodSettings
        properties:
          restApi: ${aws_api_gateway_rest_api.example.id}
          stageName: ${aws_api_gateway_stage.example.stage_name}
          methodPath: path1/GET
          settings:
            loggingLevel: INFO
            metricsEnabled: true
            dataTraceEnabled: true
    

    Create MethodSettings Resource

    new MethodSettings(name: string, args: MethodSettingsArgs, opts?: CustomResourceOptions);
    @overload
    def MethodSettings(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       method_path: Optional[str] = None,
                       rest_api: Optional[str] = None,
                       settings: Optional[MethodSettingsSettingsArgs] = None,
                       stage_name: Optional[str] = None)
    @overload
    def MethodSettings(resource_name: str,
                       args: MethodSettingsArgs,
                       opts: Optional[ResourceOptions] = None)
    func NewMethodSettings(ctx *Context, name string, args MethodSettingsArgs, opts ...ResourceOption) (*MethodSettings, error)
    public MethodSettings(string name, MethodSettingsArgs args, CustomResourceOptions? opts = null)
    public MethodSettings(String name, MethodSettingsArgs args)
    public MethodSettings(String name, MethodSettingsArgs args, CustomResourceOptions options)
    
    type: aws:apigateway:MethodSettings
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args MethodSettingsArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args MethodSettingsArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args MethodSettingsArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args MethodSettingsArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args MethodSettingsArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    MethodSettings Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The MethodSettings resource accepts the following input properties:

    MethodPath 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, "/")).

    RestApi string | string

    ID of the REST API

    Settings MethodSettingsSettings

    Settings block, see below.

    StageName string

    Name of the stage

    MethodPath 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, "/")).

    RestApi string | string

    ID of the REST API

    Settings MethodSettingsSettingsArgs

    Settings block, see below.

    StageName string

    Name of the stage

    methodPath 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, "/")).

    restApi String | String

    ID of the REST API

    settings MethodSettingsSettings

    Settings block, see below.

    stageName String

    Name of the stage

    methodPath 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, "/")).

    restApi string | RestApi

    ID of the REST API

    settings MethodSettingsSettings

    Settings block, see below.

    stageName string

    Name of the stage

    method_path str

    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, "/")).

    rest_api str | str

    ID of the REST API

    settings MethodSettingsSettingsArgs

    Settings block, see below.

    stage_name str

    Name of the stage

    methodPath 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, "/")).

    restApi String |

    ID of the REST API

    settings Property Map

    Settings block, see below.

    stageName String

    Name of the stage

    Outputs

    All input properties are implicitly available as output properties. Additionally, the MethodSettings resource produces the following output properties:

    Id string

    The provider-assigned unique ID for this managed resource.

    Id string

    The provider-assigned unique ID for this managed resource.

    id String

    The provider-assigned unique ID for this managed resource.

    id string

    The provider-assigned unique ID for this managed resource.

    id str

    The provider-assigned unique ID for this managed resource.

    id String

    The provider-assigned unique ID for this managed resource.

    Look up Existing MethodSettings Resource

    Get an existing MethodSettings resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: MethodSettingsState, opts?: CustomResourceOptions): MethodSettings
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            method_path: Optional[str] = None,
            rest_api: Optional[str] = None,
            settings: Optional[MethodSettingsSettingsArgs] = None,
            stage_name: Optional[str] = None) -> MethodSettings
    func GetMethodSettings(ctx *Context, name string, id IDInput, state *MethodSettingsState, opts ...ResourceOption) (*MethodSettings, error)
    public static MethodSettings Get(string name, Input<string> id, MethodSettingsState? state, CustomResourceOptions? opts = null)
    public static MethodSettings get(String name, Output<String> id, MethodSettingsState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    MethodPath 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, "/")).

    RestApi string | string

    ID of the REST API

    Settings MethodSettingsSettings

    Settings block, see below.

    StageName string

    Name of the stage

    MethodPath 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, "/")).

    RestApi string | string

    ID of the REST API

    Settings MethodSettingsSettingsArgs

    Settings block, see below.

    StageName string

    Name of the stage

    methodPath 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, "/")).

    restApi String | String

    ID of the REST API

    settings MethodSettingsSettings

    Settings block, see below.

    stageName String

    Name of the stage

    methodPath 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, "/")).

    restApi string | RestApi

    ID of the REST API

    settings MethodSettingsSettings

    Settings block, see below.

    stageName string

    Name of the stage

    method_path str

    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, "/")).

    rest_api str | str

    ID of the REST API

    settings MethodSettingsSettingsArgs

    Settings block, see below.

    stage_name str

    Name of the stage

    methodPath 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, "/")).

    restApi String |

    ID of the REST API

    settings Property Map

    Settings block, see below.

    stageName String

    Name of the stage

    Supporting Types

    MethodSettingsSettings, MethodSettingsSettingsArgs

    CacheDataEncrypted bool

    Whether the cached responses are encrypted.

    CacheTtlInSeconds int

    Time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.

    CachingEnabled bool

    Whether responses should be cached and returned for requests. A cache cluster must be enabled on the stage for responses to be cached.

    DataTraceEnabled bool

    Whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.

    LoggingLevel string

    Logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are OFF, ERROR, and INFO.

    MetricsEnabled bool

    Whether Amazon CloudWatch metrics are enabled for this method.

    RequireAuthorizationForCacheControl bool

    Whether authorization is required for a cache invalidation request.

    ThrottlingBurstLimit int

    Throttling burst limit. Default: -1 (throttling disabled).

    ThrottlingRateLimit double

    Throttling rate limit. Default: -1 (throttling disabled).

    UnauthorizedCacheControlHeaderStrategy string

    How to handle unauthorized requests for cache invalidation. The available values are FAIL_WITH_403, SUCCEED_WITH_RESPONSE_HEADER, SUCCEED_WITHOUT_RESPONSE_HEADER.

    CacheDataEncrypted bool

    Whether the cached responses are encrypted.

    CacheTtlInSeconds int

    Time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.

    CachingEnabled bool

    Whether responses should be cached and returned for requests. A cache cluster must be enabled on the stage for responses to be cached.

    DataTraceEnabled bool

    Whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.

    LoggingLevel string

    Logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are OFF, ERROR, and INFO.

    MetricsEnabled bool

    Whether Amazon CloudWatch metrics are enabled for this method.

    RequireAuthorizationForCacheControl bool

    Whether authorization is required for a cache invalidation request.

    ThrottlingBurstLimit int

    Throttling burst limit. Default: -1 (throttling disabled).

    ThrottlingRateLimit float64

    Throttling rate limit. Default: -1 (throttling disabled).

    UnauthorizedCacheControlHeaderStrategy string

    How to handle unauthorized requests for cache invalidation. The available values are FAIL_WITH_403, SUCCEED_WITH_RESPONSE_HEADER, SUCCEED_WITHOUT_RESPONSE_HEADER.

    cacheDataEncrypted Boolean

    Whether the cached responses are encrypted.

    cacheTtlInSeconds Integer

    Time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.

    cachingEnabled Boolean

    Whether responses should be cached and returned for requests. A cache cluster must be enabled on the stage for responses to be cached.

    dataTraceEnabled Boolean

    Whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.

    loggingLevel String

    Logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are OFF, ERROR, and INFO.

    metricsEnabled Boolean

    Whether Amazon CloudWatch metrics are enabled for this method.

    requireAuthorizationForCacheControl Boolean

    Whether authorization is required for a cache invalidation request.

    throttlingBurstLimit Integer

    Throttling burst limit. Default: -1 (throttling disabled).

    throttlingRateLimit Double

    Throttling rate limit. Default: -1 (throttling disabled).

    unauthorizedCacheControlHeaderStrategy String

    How to handle unauthorized requests for cache invalidation. The available values are FAIL_WITH_403, SUCCEED_WITH_RESPONSE_HEADER, SUCCEED_WITHOUT_RESPONSE_HEADER.

    cacheDataEncrypted boolean

    Whether the cached responses are encrypted.

    cacheTtlInSeconds number

    Time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.

    cachingEnabled boolean

    Whether responses should be cached and returned for requests. A cache cluster must be enabled on the stage for responses to be cached.

    dataTraceEnabled boolean

    Whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.

    loggingLevel string

    Logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are OFF, ERROR, and INFO.

    metricsEnabled boolean

    Whether Amazon CloudWatch metrics are enabled for this method.

    requireAuthorizationForCacheControl boolean

    Whether authorization is required for a cache invalidation request.

    throttlingBurstLimit number

    Throttling burst limit. Default: -1 (throttling disabled).

    throttlingRateLimit number

    Throttling rate limit. Default: -1 (throttling disabled).

    unauthorizedCacheControlHeaderStrategy string

    How to handle unauthorized requests for cache invalidation. The available values are FAIL_WITH_403, SUCCEED_WITH_RESPONSE_HEADER, SUCCEED_WITHOUT_RESPONSE_HEADER.

    cache_data_encrypted bool

    Whether the cached responses are encrypted.

    cache_ttl_in_seconds int

    Time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.

    caching_enabled bool

    Whether responses should be cached and returned for requests. A cache cluster must be enabled on the stage for responses to be cached.

    data_trace_enabled bool

    Whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.

    logging_level str

    Logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are OFF, ERROR, and INFO.

    metrics_enabled bool

    Whether Amazon CloudWatch metrics are enabled for this method.

    require_authorization_for_cache_control bool

    Whether authorization is required for a cache invalidation request.

    throttling_burst_limit int

    Throttling burst limit. Default: -1 (throttling disabled).

    throttling_rate_limit float

    Throttling rate limit. Default: -1 (throttling disabled).

    unauthorized_cache_control_header_strategy str

    How to handle unauthorized requests for cache invalidation. The available values are FAIL_WITH_403, SUCCEED_WITH_RESPONSE_HEADER, SUCCEED_WITHOUT_RESPONSE_HEADER.

    cacheDataEncrypted Boolean

    Whether the cached responses are encrypted.

    cacheTtlInSeconds Number

    Time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.

    cachingEnabled Boolean

    Whether responses should be cached and returned for requests. A cache cluster must be enabled on the stage for responses to be cached.

    dataTraceEnabled Boolean

    Whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.

    loggingLevel String

    Logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are OFF, ERROR, and INFO.

    metricsEnabled Boolean

    Whether Amazon CloudWatch metrics are enabled for this method.

    requireAuthorizationForCacheControl Boolean

    Whether authorization is required for a cache invalidation request.

    throttlingBurstLimit Number

    Throttling burst limit. Default: -1 (throttling disabled).

    throttlingRateLimit Number

    Throttling rate limit. Default: -1 (throttling disabled).

    unauthorizedCacheControlHeaderStrategy String

    How to handle unauthorized requests for cache invalidation. The available values are FAIL_WITH_403, SUCCEED_WITH_RESPONSE_HEADER, SUCCEED_WITHOUT_RESPONSE_HEADER.

    Import

    Using pulumi import, import aws_api_gateway_method_settings using REST-API-ID/STAGE-NAME/METHOD-PATH. For example:

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

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the aws Terraform Provider.

    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.3.0 published on Thursday, Sep 28, 2023 by Pulumi