Authorizer
Manages an Amazon API Gateway Version 2 authorizer. More information can be found in the Amazon API Gateway Developer Guide.
Example Usage
Basic WebSocket API
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigatewayv2.Authorizer;
import com.pulumi.aws.apigatewayv2.AuthorizerArgs;
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 example = new Authorizer("example", AuthorizerArgs.builder()
.apiId(aws_apigatewayv2_api.example().id())
.authorizerType("REQUEST")
.authorizerUri(aws_lambda_function.example().invoke_arn())
.identitySources("route.request.header.Auth")
.build());
}
}
Basic HTTP API
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigatewayv2.Authorizer;
import com.pulumi.aws.apigatewayv2.AuthorizerArgs;
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 example = new Authorizer("example", AuthorizerArgs.builder()
.apiId(aws_apigatewayv2_api.example().id())
.authorizerType("REQUEST")
.authorizerUri(aws_lambda_function.example().invoke_arn())
.identitySources("$request.header.Authorization")
.authorizerPayloadFormatVersion("2.0")
.build());
}
}
Import
aws_apigatewayv2_authorizer
can be imported by using the API identifier and authorizer identifier, e.g.,
$ pulumi import aws:apigatewayv2/authorizer:Authorizer example aabbccddee/1122334
Properties
Required credentials as an IAM role for API Gateway to invoke the authorizer. Supported only for REQUEST
authorizers.
Format of the payload sent to an HTTP API Lambda authorizer. Required for HTTP API Lambda authorizers. Valid values: 1.0
, 2.0
.
Time to live (TTL) for cached authorizer results, in seconds. If it equals 0, authorization caching is disabled. If it is greater than 0, API Gateway caches authorizer responses. The maximum value is 3600, or 1 hour. Defaults to 300
. Supported only for HTTP API Lambda authorizers.
Authorizer type. Valid values: JWT
, REQUEST
. Specify REQUEST
for a Lambda function using incoming request parameters. For HTTP APIs, specify JWT
to use JSON Web Tokens.
Authorizer's Uniform Resource Identifier (URI). For REQUEST
authorizers this must be a well-formed Lambda function URI, such as the invoke_arn
attribute of the aws.lambda.Function
resource. Supported only for REQUEST
authorizers. Must be between 1 and 2048 characters in length.
Whether a Lambda authorizer returns a response in a simple format. If enabled, the Lambda authorizer can return a boolean value instead of an IAM policy. Supported only for HTTP APIs.
Identity sources for which authorization is requested. For REQUEST
authorizers the value is a list of one or more mapping expressions of the specified request parameters. For JWT
authorizers the single entry specifies where to extract the JSON Web Token (JWT) from inbound requests.
Configuration of a JWT authorizer. Required for the JWT
authorizer type. Supported only for HTTP APIs.