- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
CreateAuthorizerCommand
Adds a new Authorizer resource to an existing RestApi resource.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { APIGatewayClient, CreateAuthorizerCommand } from "@aws-sdk/client-api-gateway"; // ES Modules import
// const { APIGatewayClient, CreateAuthorizerCommand } = require("@aws-sdk/client-api-gateway"); // CommonJS import
const client = new APIGatewayClient(config);
const input = { // CreateAuthorizerRequest
restApiId: "STRING_VALUE", // required
name: "STRING_VALUE", // required
type: "TOKEN" || "REQUEST" || "COGNITO_USER_POOLS", // required
providerARNs: [ // ListOfARNs
"STRING_VALUE",
],
authType: "STRING_VALUE",
authorizerUri: "STRING_VALUE",
authorizerCredentials: "STRING_VALUE",
identitySource: "STRING_VALUE",
identityValidationExpression: "STRING_VALUE",
authorizerResultTtlInSeconds: Number("int"),
};
const command = new CreateAuthorizerCommand(input);
const response = await client.send(command);
// { // Authorizer
// id: "STRING_VALUE",
// name: "STRING_VALUE",
// type: "TOKEN" || "REQUEST" || "COGNITO_USER_POOLS",
// providerARNs: [ // ListOfARNs
// "STRING_VALUE",
// ],
// authType: "STRING_VALUE",
// authorizerUri: "STRING_VALUE",
// authorizerCredentials: "STRING_VALUE",
// identitySource: "STRING_VALUE",
// identityValidationExpression: "STRING_VALUE",
// authorizerResultTtlInSeconds: Number("int"),
// };
CreateAuthorizerCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
name Required | string | undefined | The name of the authorizer. |
restApiId Required | string | undefined | The string identifier of the associated RestApi. |
type Required | AuthorizerType | undefined | The authorizer type. Valid values are |
authType | string | undefined | Optional customer-defined field, used in OpenAPI imports and exports without functional impact. |
authorizerCredentials | string | undefined | Specifies the required credentials as an IAM role for API Gateway to invoke the authorizer. To specify an IAM role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To use resource-based permissions on the Lambda function, specify null. |
authorizerResultTtlInSeconds | number | undefined | The TTL in seconds of cached authorizer results. If it equals 0, authorization caching is disabled. If it is greater than 0, API Gateway will cache authorizer responses. If this field is not set, the default value is 300. The maximum value is 3600, or 1 hour. |
authorizerUri | string | undefined | Specifies the authorizer's Uniform Resource Identifier (URI). For |
identitySource | string | undefined | The identity source for which authorization is requested. For a |
identityValidationExpression | string | undefined | A validation expression for the incoming identity token. For |
providerARNs | string[] | undefined | A list of the Amazon Cognito user pool ARNs for the |
CreateAuthorizerCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
authType | string | undefined | Optional customer-defined field, used in OpenAPI imports and exports without functional impact. |
authorizerCredentials | string | undefined | Specifies the required credentials as an IAM role for API Gateway to invoke the authorizer. To specify an IAM role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To use resource-based permissions on the Lambda function, specify null. |
authorizerResultTtlInSeconds | number | undefined | The TTL in seconds of cached authorizer results. If it equals 0, authorization caching is disabled. If it is greater than 0, API Gateway will cache authorizer responses. If this field is not set, the default value is 300. The maximum value is 3600, or 1 hour. |
authorizerUri | string | undefined | Specifies the authorizer's Uniform Resource Identifier (URI). For |
id | string | undefined | The identifier for the authorizer resource. |
identitySource | string | undefined | The identity source for which authorization is requested. For a |
identityValidationExpression | string | undefined | A validation expression for the incoming identity token. For |
name | string | undefined | The name of the authorizer. |
providerARNs | string[] | undefined | A list of the Amazon Cognito user pool ARNs for the |
type | AuthorizerType | undefined | The authorizer type. Valid values are |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
BadRequestException | client | The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details. |
ConflictException | client | The request configuration has conflicts. For details, see the accompanying error message. |
LimitExceededException | client | The request exceeded the rate limit. Retry after the specified time period. |
NotFoundException | client | The requested resource is not found. Make sure that the request URI is correct. |
TooManyRequestsException | client | The request has reached its throttling limit. Retry after the specified time period. |
UnauthorizedException | client | The request is denied because the caller has insufficient permissions. |
APIGatewayServiceException | Base exception class for all service exceptions from APIGateway service. |