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
new MethodSettings(name: string, args: MethodSettingsArgs, opts?: CustomResourceOptions);def MethodSettings(resource_name, opts=None, method_path=None, rest_api=None, settings=None, stage_name=None, __props__=None);func NewMethodSettings(ctx *Context, name string, args MethodSettingsArgs, opts ...ResourceOption) (*MethodSettings, error)public MethodSettings(string name, MethodSettingsArgs args, CustomResourceOptions? opts = null)- 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:
- Method
Path string Method path defined as
{resource_path}/{http_method}for an individual method override, or*/*for overriding all methods in the stage.- Rest
Api string The ID of the REST API
- Settings
Method
Settings Settings Args The settings block, see below.
- Stage
Name string The name of the stage
- Method
Path string Method path defined as
{resource_path}/{http_method}for an individual method override, or*/*for overriding all methods in the stage.- Rest
Api interface{} The ID of the REST API
- Settings
Method
Settings Settings The settings block, see below.
- Stage
Name string The name of the stage
- method
Path string Method path defined as
{resource_path}/{http_method}for an individual method override, or*/*for overriding all methods in the stage.- rest
Api string | RestApi The ID of the REST API
- settings
Method
Settings Settings The settings block, see below.
- stage
Name 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[Method
Settings Settings] 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:
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): MethodSettingsstatic 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:
- Method
Path string Method path defined as
{resource_path}/{http_method}for an individual method override, or*/*for overriding all methods in the stage.- Rest
Api string The ID of the REST API
- Settings
Method
Settings Settings Args The settings block, see below.
- Stage
Name string The name of the stage
- Method
Path string Method path defined as
{resource_path}/{http_method}for an individual method override, or*/*for overriding all methods in the stage.- Rest
Api interface{} The ID of the REST API
- Settings
Method
Settings Settings The settings block, see below.
- Stage
Name string The name of the stage
- method
Path string Method path defined as
{resource_path}/{http_method}for an individual method override, or*/*for overriding all methods in the stage.- rest
Api string | RestApi The ID of the REST API
- settings
Method
Settings Settings The settings block, see below.
- stage
Name 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[Method
Settings Settings] The settings block, see below.
- stage_
name str The name of the stage
Supporting Types
MethodSettingsSettings
- Cache
Data boolEncrypted Specifies whether the cached responses are encrypted.
- Cache
Ttl intIn Seconds Specifies the time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.
- Caching
Enabled 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.
- Data
Trace boolEnabled Specifies whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.
- Logging
Level string Specifies the logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are
OFF,ERROR, andINFO.- Metrics
Enabled bool Specifies whether Amazon CloudWatch metrics are enabled for this method.
- bool
Specifies whether authorization is required for a cache invalidation request.
- Throttling
Burst intLimit Specifies the throttling burst limit.
- Throttling
Rate doubleLimit Specifies the throttling rate limit.
- 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.
- Cache
Data boolEncrypted Specifies whether the cached responses are encrypted.
- Cache
Ttl intIn Seconds Specifies the time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.
- Caching
Enabled 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.
- Data
Trace boolEnabled Specifies whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.
- Logging
Level string Specifies the logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are
OFF,ERROR, andINFO.- Metrics
Enabled bool Specifies whether Amazon CloudWatch metrics are enabled for this method.
- bool
Specifies whether authorization is required for a cache invalidation request.
- Throttling
Burst intLimit Specifies the throttling burst limit.
- Throttling
Rate float64Limit Specifies the throttling rate limit.
- 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.
- cache
Data booleanEncrypted Specifies whether the cached responses are encrypted.
- cache
Ttl numberIn Seconds Specifies the time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.
- caching
Enabled 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.
- data
Trace booleanEnabled Specifies whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.
- logging
Level string Specifies the logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are
OFF,ERROR, andINFO.- metrics
Enabled boolean Specifies whether Amazon CloudWatch metrics are enabled for this method.
- boolean
Specifies whether authorization is required for a cache invalidation request.
- throttling
Burst numberLimit Specifies the throttling burst limit.
- throttling
Rate numberLimit Specifies the throttling rate limit.
- 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.
- cache
Data boolEncrypted Specifies whether the cached responses are encrypted.
- cache
Ttl floatIn Seconds Specifies the time to live (TTL), in seconds, for cached responses. The higher the TTL, the longer the response will be cached.
- caching
Enabled 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.
- data
Trace boolEnabled Specifies whether data trace logging is enabled for this method, which effects the log entries pushed to Amazon CloudWatch Logs.
- logging
Level str Specifies the logging level for this method, which effects the log entries pushed to Amazon CloudWatch Logs. The available levels are
OFF,ERROR, andINFO.- metrics
Enabled bool Specifies whether Amazon CloudWatch metrics are enabled for this method.
- bool
Specifies whether authorization is required for a cache invalidation request.
- throttling
Burst floatLimit Specifies the throttling burst limit.
- throttling
Rate floatLimit Specifies the throttling rate limit.
- 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
awsTerraform Provider.