MethodSettings

Provides an API Gateway Method Settings, e.g. logging or monitoring.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var testRestApi = new Aws.ApiGateway.RestApi("testRestApi", new Aws.ApiGateway.RestApiArgs
        {
            Description = "This is my API for demonstration purposes",
        });
        var testDeployment = new Aws.ApiGateway.Deployment("testDeployment", new Aws.ApiGateway.DeploymentArgs
        {
            RestApi = testRestApi.Id,
            StageName = "dev",
        }, new CustomResourceOptions
        {
            DependsOn = 
            {
                "aws_api_gateway_integration.test",
            },
        });
        var testStage = new Aws.ApiGateway.Stage("testStage", new Aws.ApiGateway.StageArgs
        {
            Deployment = testDeployment.Id,
            RestApi = testRestApi.Id,
            StageName = "prod",
        });
        var testResource = new Aws.ApiGateway.Resource("testResource", new Aws.ApiGateway.ResourceArgs
        {
            ParentId = testRestApi.RootResourceId,
            PathPart = "mytestresource",
            RestApi = testRestApi.Id,
        });
        var testMethod = new Aws.ApiGateway.Method("testMethod", new Aws.ApiGateway.MethodArgs
        {
            Authorization = "NONE",
            HttpMethod = "GET",
            ResourceId = testResource.Id,
            RestApi = testRestApi.Id,
        });
        var methodSettings = new Aws.ApiGateway.MethodSettings("methodSettings", new Aws.ApiGateway.MethodSettingsArgs
        {
            MethodPath = Output.Tuple(testResource.PathPart, testMethod.HttpMethod).Apply(values =>
            {
                var pathPart = values.Item1;
                var httpMethod = values.Item2;
                return $"{pathPart}/{httpMethod}";
            }),
            RestApi = testRestApi.Id,
            Settings = new Aws.ApiGateway.Inputs.MethodSettingsSettingsArgs
            {
                LoggingLevel = "INFO",
                MetricsEnabled = true,
            },
            StageName = testStage.StageName,
        });
        var testIntegration = new Aws.ApiGateway.Integration("testIntegration", new Aws.ApiGateway.IntegrationArgs
        {
            HttpMethod = testMethod.HttpMethod,
            RequestTemplates = 
            {
                { "application/xml", @"{
   ""body"" : $input.json('$')
}

" },
            },
            ResourceId = testResource.Id,
            RestApi = testRestApi.Id,
            Type = "MOCK",
        });
    }

}
package main

import (
    "fmt"

    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/apigateway"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        testRestApi, err := apigateway.NewRestApi(ctx, "testRestApi", &apigateway.RestApiArgs{
            Description: pulumi.String("This is my API for demonstration purposes"),
        })
        if err != nil {
            return err
        }
        testDeployment, err := apigateway.NewDeployment(ctx, "testDeployment", &apigateway.DeploymentArgs{
            RestApi:   testRestApi.ID(),
            StageName: pulumi.String("dev"),
        }, pulumi.DependsOn([]pulumi.Resource{
            "aws_api_gateway_integration.test",
        }))
        if err != nil {
            return err
        }
        testStage, err := apigateway.NewStage(ctx, "testStage", &apigateway.StageArgs{
            Deployment: testDeployment.ID(),
            RestApi:    testRestApi.ID(),
            StageName:  pulumi.String("prod"),
        })
        if err != nil {
            return err
        }
        testResource, err := apigateway.NewResource(ctx, "testResource", &apigateway.ResourceArgs{
            ParentId: testRestApi.RootResourceId,
            PathPart: pulumi.String("mytestresource"),
            RestApi:  testRestApi.ID(),
        })
        if err != nil {
            return err
        }
        testMethod, err := apigateway.NewMethod(ctx, "testMethod", &apigateway.MethodArgs{
            Authorization: pulumi.String("NONE"),
            HttpMethod:    pulumi.String("GET"),
            ResourceId:    testResource.ID(),
            RestApi:       testRestApi.ID(),
        })
        if err != nil {
            return err
        }
        _, err = apigateway.NewMethodSettings(ctx, "methodSettings", &apigateway.MethodSettingsArgs{
            MethodPath: pulumi.All(testResource.PathPart, testMethod.HttpMethod).ApplyT(func(_args []interface{}) (string, error) {
                pathPart := _args[0].(string)
                httpMethod := _args[1].(string)
                return fmt.Sprintf("%v%v%v", pathPart, "/", httpMethod), nil
            }).(pulumi.StringOutput),
            RestApi: testRestApi.ID(),
            Settings: &apigateway.MethodSettingsSettingsArgs{
                LoggingLevel:   pulumi.String("INFO"),
                MetricsEnabled: pulumi.Bool(true),
            },
            StageName: testStage.StageName,
        })
        if err != nil {
            return err
        }
        _, err = apigateway.NewIntegration(ctx, "testIntegration", &apigateway.IntegrationArgs{
            HttpMethod: testMethod.HttpMethod,
            RequestTemplates: pulumi.StringMap{
                "application/xml": pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v", "{\n", "   \"body\" : ", "$", "input.json('", "$", "')\n", "}\n", "\n")),
            },
            ResourceId: testResource.ID(),
            RestApi:    testRestApi.ID(),
            Type:       pulumi.String("MOCK"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

test_rest_api = aws.apigateway.RestApi("testRestApi", description="This is my API for demonstration purposes")
test_deployment = aws.apigateway.Deployment("testDeployment",
    rest_api=test_rest_api.id,
    stage_name="dev",
    opts=ResourceOptions(depends_on=["aws_api_gateway_integration.test"]))
test_stage = aws.apigateway.Stage("testStage",
    deployment=test_deployment.id,
    rest_api=test_rest_api.id,
    stage_name="prod")
test_resource = aws.apigateway.Resource("testResource",
    parent_id=test_rest_api.root_resource_id,
    path_part="mytestresource",
    rest_api=test_rest_api.id)
test_method = aws.apigateway.Method("testMethod",
    authorization="NONE",
    http_method="GET",
    resource_id=test_resource.id,
    rest_api=test_rest_api.id)
method_settings = aws.apigateway.MethodSettings("methodSettings",
    method_path=pulumi.Output.all(test_resource.path_part, test_method.http_method).apply(lambda path_part, http_method: f"{path_part}/{http_method}"),
    rest_api=test_rest_api.id,
    settings={
        "loggingLevel": "INFO",
        "metricsEnabled": True,
    },
    stage_name=test_stage.stage_name)
test_integration = aws.apigateway.Integration("testIntegration",
    http_method=test_method.http_method,
    request_templates={
        "application/xml": """{
   "body" : $input.json('$')
}

""",
    },
    resource_id=test_resource.id,
    rest_api=test_rest_api.id,
    type="MOCK")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const testRestApi = new aws.apigateway.RestApi("test", {
    description: "This is my API for demonstration purposes",
});
const testResource = new aws.apigateway.Resource("test", {
    parentId: testRestApi.rootResourceId,
    pathPart: "mytestresource",
    restApi: testRestApi.id,
});
const testMethod = new aws.apigateway.Method("test", {
    authorization: "NONE",
    httpMethod: "GET",
    resourceId: testResource.id,
    restApi: testRestApi.id,
});
const testIntegration = new aws.apigateway.Integration("test", {
    httpMethod: testMethod.httpMethod,
    requestTemplates: {
        "application/xml": `{
   "body" : $input.json('$')
}
`,
    },
    resourceId: testResource.id,
    restApi: testRestApi.id,
    type: "MOCK",
});
const testDeployment = new aws.apigateway.Deployment("test", {
    restApi: testRestApi.id,
    stageName: "dev",
}, { dependsOn: [testIntegration] });
const testStage = new aws.apigateway.Stage("test", {
    deployment: testDeployment.id,
    restApi: testRestApi.id,
    stageName: "prod",
});
const methodSettings = new aws.apigateway.MethodSettings("s", {
    methodPath: pulumi.interpolate`${testResource.pathPart}/${testMethod.httpMethod}`,
    restApi: testRestApi.id,
    settings: {
        loggingLevel: "INFO",
        metricsEnabled: true,
    },
    stageName: testStage.stageName,
});

Create a MethodSettings Resource

def MethodSettings(resource_name, opts=None, method_path=None, rest_api=None, settings=None, stage_name=None, __props__=None);
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.
opts ResourceOptions
A bag of options that control this 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.

MethodSettings Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model 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.

RestApi string

The ID of the REST API

Settings MethodSettingsSettingsArgs

The settings block, see below.

StageName string

The 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.

RestApi interface{}

The ID of the REST API

Settings MethodSettingsSettings

The settings block, see below.

StageName string

The 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.

restApi string | RestApi

The ID of the REST API

settings MethodSettingsSettings

The settings block, see below.

stageName string

The 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.

rest_api string | str

The ID of the REST API

settings Dict[MethodSettingsSettings]

The settings block, see below.

stage_name str

The 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 str
The provider-assigned unique ID for this managed resource.

Look up an 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
static get(resource_name, id, opts=None, method_path=None, rest_api=None, settings=None, stage_name=None, __props__=None);
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)
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.

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.

RestApi string

The ID of the REST API

Settings MethodSettingsSettingsArgs

The settings block, see below.

StageName string

The 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.

RestApi interface{}

The ID of the REST API

Settings MethodSettingsSettings

The settings block, see below.

StageName string

The 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.

restApi string | RestApi

The ID of the REST API

settings MethodSettingsSettings

The settings block, see below.

stageName string

The 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.

rest_api string | str

The ID of the REST API

settings Dict[MethodSettingsSettings]

The settings block, see below.

stage_name str

The name of the stage

Supporting Types

MethodSettingsSettings

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

CacheDataEncrypted bool

Specifies whether the cached responses are encrypted.

CacheTtlInSeconds int

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

CachingEnabled bool

Specifies 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

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

LoggingLevel string

Specifies the 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

Specifies whether Amazon CloudWatch metrics are enabled for this method.

RequireAuthorizationForCacheControl bool

Specifies whether authorization is required for a cache invalidation request.

ThrottlingBurstLimit int

Specifies the throttling burst limit.

ThrottlingRateLimit double

Specifies the throttling rate limit.

UnauthorizedCacheControlHeaderStrategy string

Specifies 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

Specifies whether the cached responses are encrypted.

CacheTtlInSeconds int

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

CachingEnabled bool

Specifies 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

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

LoggingLevel string

Specifies the 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

Specifies whether Amazon CloudWatch metrics are enabled for this method.

RequireAuthorizationForCacheControl bool

Specifies whether authorization is required for a cache invalidation request.

ThrottlingBurstLimit int

Specifies the throttling burst limit.

ThrottlingRateLimit float64

Specifies the throttling rate limit.

UnauthorizedCacheControlHeaderStrategy string

Specifies 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

Specifies whether the cached responses are encrypted.

cacheTtlInSeconds number

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

cachingEnabled boolean

Specifies 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

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

loggingLevel string

Specifies the 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

Specifies whether Amazon CloudWatch metrics are enabled for this method.

requireAuthorizationForCacheControl boolean

Specifies whether authorization is required for a cache invalidation request.

throttlingBurstLimit number

Specifies the throttling burst limit.

throttlingRateLimit number

Specifies the throttling rate limit.

unauthorizedCacheControlHeaderStrategy string

Specifies 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

Specifies whether the cached responses are encrypted.

cacheTtlInSeconds float

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

cachingEnabled bool

Specifies 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

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

loggingLevel str

Specifies the 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

Specifies whether Amazon CloudWatch metrics are enabled for this method.

requireAuthorizationForCacheControl bool

Specifies whether authorization is required for a cache invalidation request.

throttlingBurstLimit float

Specifies the throttling burst limit.

throttlingRateLimit float

Specifies the throttling rate limit.

unauthorizedCacheControlHeaderStrategy str

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

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.