AWS Native is in preview. AWS Classic is fully supported.
aws-native.apigateway.Authorizer
Explore with Pulumi AI
AWS Native is in preview. AWS Classic is fully supported.
The AWS::ApiGateway::Authorizer
resource creates an authorization layer that API Gateway activates for methods that have authorization enabled. API Gateway activates the authorizer when a client calls those methods.
Create Authorizer Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Authorizer(name: string, args: AuthorizerArgs, opts?: CustomResourceOptions);
@overload
def Authorizer(resource_name: str,
args: AuthorizerArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Authorizer(resource_name: str,
opts: Optional[ResourceOptions] = None,
rest_api_id: Optional[str] = None,
type: Optional[str] = None,
auth_type: Optional[str] = None,
authorizer_credentials: Optional[str] = None,
authorizer_result_ttl_in_seconds: Optional[int] = None,
authorizer_uri: Optional[str] = None,
identity_source: Optional[str] = None,
identity_validation_expression: Optional[str] = None,
name: Optional[str] = None,
provider_arns: Optional[Sequence[str]] = None)
func NewAuthorizer(ctx *Context, name string, args AuthorizerArgs, opts ...ResourceOption) (*Authorizer, error)
public Authorizer(string name, AuthorizerArgs args, CustomResourceOptions? opts = null)
public Authorizer(String name, AuthorizerArgs args)
public Authorizer(String name, AuthorizerArgs args, CustomResourceOptions options)
type: aws-native:apigateway:Authorizer
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args AuthorizerArgs
- 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 AuthorizerArgs
- 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 AuthorizerArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args AuthorizerArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args AuthorizerArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Authorizer 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 Authorizer resource accepts the following input properties:
- Rest
Api stringId - The string identifier of the associated RestApi.
- Type string
- The authorizer type. Valid values are
TOKEN
for a Lambda function using a single authorization token submitted in a custom header,REQUEST
for a Lambda function using incoming request parameters, andCOGNITO_USER_POOLS
for using an Amazon Cognito user pool. - Auth
Type string - Optional customer-defined field, used in OpenAPI imports and exports without functional impact.
- string
- 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.
- int
- 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.
- string
- Specifies the authorizer's Uniform Resource Identifier (URI). For
TOKEN
orREQUEST
authorizers, this must be a well-formed Lambda function URI, for example,arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations
. In general, the URI has this formarn:aws:apigateway:{region}:lambda:path/{service_api}
, where{region}
is the same as the region hosting the Lambda function,path
indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial/
. For Lambda functions, this is usually of the form/2015-03-31/functions/[FunctionARN]/invocations
. - Identity
Source string - The identity source for which authorization is requested. For a
TOKEN
orCOGNITO_USER_POOLS
authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name isAuth
, the header mapping expression ismethod.request.header.Auth
. For theREQUEST
authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if anAuth
header, aName
query string parameter are defined as identity sources, this value ismethod.request.header.Auth, method.request.querystring.Name
. These parameters will be used to derive the authorization caching key and to perform runtime validation of theREQUEST
authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional. - Identity
Validation stringExpression - A validation expression for the incoming identity token. For
TOKEN
authorizers, this value is a regular expression. ForCOGNITO_USER_POOLS
authorizers, API Gateway will match theaud
field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to theREQUEST
authorizer. - Name string
- The name of the authorizer.
- Provider
Arns List<string> - A list of the Amazon Cognito user pool ARNs for the
COGNITO_USER_POOLS
authorizer. Each element is of this format:arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}
. For aTOKEN
orREQUEST
authorizer, this is not defined.
- Rest
Api stringId - The string identifier of the associated RestApi.
- Type string
- The authorizer type. Valid values are
TOKEN
for a Lambda function using a single authorization token submitted in a custom header,REQUEST
for a Lambda function using incoming request parameters, andCOGNITO_USER_POOLS
for using an Amazon Cognito user pool. - Auth
Type string - Optional customer-defined field, used in OpenAPI imports and exports without functional impact.
- string
- 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.
- int
- 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.
- string
- Specifies the authorizer's Uniform Resource Identifier (URI). For
TOKEN
orREQUEST
authorizers, this must be a well-formed Lambda function URI, for example,arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations
. In general, the URI has this formarn:aws:apigateway:{region}:lambda:path/{service_api}
, where{region}
is the same as the region hosting the Lambda function,path
indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial/
. For Lambda functions, this is usually of the form/2015-03-31/functions/[FunctionARN]/invocations
. - Identity
Source string - The identity source for which authorization is requested. For a
TOKEN
orCOGNITO_USER_POOLS
authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name isAuth
, the header mapping expression ismethod.request.header.Auth
. For theREQUEST
authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if anAuth
header, aName
query string parameter are defined as identity sources, this value ismethod.request.header.Auth, method.request.querystring.Name
. These parameters will be used to derive the authorization caching key and to perform runtime validation of theREQUEST
authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional. - Identity
Validation stringExpression - A validation expression for the incoming identity token. For
TOKEN
authorizers, this value is a regular expression. ForCOGNITO_USER_POOLS
authorizers, API Gateway will match theaud
field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to theREQUEST
authorizer. - Name string
- The name of the authorizer.
- Provider
Arns []string - A list of the Amazon Cognito user pool ARNs for the
COGNITO_USER_POOLS
authorizer. Each element is of this format:arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}
. For aTOKEN
orREQUEST
authorizer, this is not defined.
- rest
Api StringId - The string identifier of the associated RestApi.
- type String
- The authorizer type. Valid values are
TOKEN
for a Lambda function using a single authorization token submitted in a custom header,REQUEST
for a Lambda function using incoming request parameters, andCOGNITO_USER_POOLS
for using an Amazon Cognito user pool. - auth
Type String - Optional customer-defined field, used in OpenAPI imports and exports without functional impact.
- String
- 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.
- Integer
- 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.
- String
- Specifies the authorizer's Uniform Resource Identifier (URI). For
TOKEN
orREQUEST
authorizers, this must be a well-formed Lambda function URI, for example,arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations
. In general, the URI has this formarn:aws:apigateway:{region}:lambda:path/{service_api}
, where{region}
is the same as the region hosting the Lambda function,path
indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial/
. For Lambda functions, this is usually of the form/2015-03-31/functions/[FunctionARN]/invocations
. - identity
Source String - The identity source for which authorization is requested. For a
TOKEN
orCOGNITO_USER_POOLS
authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name isAuth
, the header mapping expression ismethod.request.header.Auth
. For theREQUEST
authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if anAuth
header, aName
query string parameter are defined as identity sources, this value ismethod.request.header.Auth, method.request.querystring.Name
. These parameters will be used to derive the authorization caching key and to perform runtime validation of theREQUEST
authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional. - identity
Validation StringExpression - A validation expression for the incoming identity token. For
TOKEN
authorizers, this value is a regular expression. ForCOGNITO_USER_POOLS
authorizers, API Gateway will match theaud
field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to theREQUEST
authorizer. - name String
- The name of the authorizer.
- provider
Arns List<String> - A list of the Amazon Cognito user pool ARNs for the
COGNITO_USER_POOLS
authorizer. Each element is of this format:arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}
. For aTOKEN
orREQUEST
authorizer, this is not defined.
- rest
Api stringId - The string identifier of the associated RestApi.
- type string
- The authorizer type. Valid values are
TOKEN
for a Lambda function using a single authorization token submitted in a custom header,REQUEST
for a Lambda function using incoming request parameters, andCOGNITO_USER_POOLS
for using an Amazon Cognito user pool. - auth
Type string - Optional customer-defined field, used in OpenAPI imports and exports without functional impact.
- string
- 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.
- number
- 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.
- string
- Specifies the authorizer's Uniform Resource Identifier (URI). For
TOKEN
orREQUEST
authorizers, this must be a well-formed Lambda function URI, for example,arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations
. In general, the URI has this formarn:aws:apigateway:{region}:lambda:path/{service_api}
, where{region}
is the same as the region hosting the Lambda function,path
indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial/
. For Lambda functions, this is usually of the form/2015-03-31/functions/[FunctionARN]/invocations
. - identity
Source string - The identity source for which authorization is requested. For a
TOKEN
orCOGNITO_USER_POOLS
authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name isAuth
, the header mapping expression ismethod.request.header.Auth
. For theREQUEST
authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if anAuth
header, aName
query string parameter are defined as identity sources, this value ismethod.request.header.Auth, method.request.querystring.Name
. These parameters will be used to derive the authorization caching key and to perform runtime validation of theREQUEST
authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional. - identity
Validation stringExpression - A validation expression for the incoming identity token. For
TOKEN
authorizers, this value is a regular expression. ForCOGNITO_USER_POOLS
authorizers, API Gateway will match theaud
field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to theREQUEST
authorizer. - name string
- The name of the authorizer.
- provider
Arns string[] - A list of the Amazon Cognito user pool ARNs for the
COGNITO_USER_POOLS
authorizer. Each element is of this format:arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}
. For aTOKEN
orREQUEST
authorizer, this is not defined.
- rest_
api_ strid - The string identifier of the associated RestApi.
- type str
- The authorizer type. Valid values are
TOKEN
for a Lambda function using a single authorization token submitted in a custom header,REQUEST
for a Lambda function using incoming request parameters, andCOGNITO_USER_POOLS
for using an Amazon Cognito user pool. - auth_
type str - Optional customer-defined field, used in OpenAPI imports and exports without functional impact.
- str
- 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.
- int
- 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.
- str
- Specifies the authorizer's Uniform Resource Identifier (URI). For
TOKEN
orREQUEST
authorizers, this must be a well-formed Lambda function URI, for example,arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations
. In general, the URI has this formarn:aws:apigateway:{region}:lambda:path/{service_api}
, where{region}
is the same as the region hosting the Lambda function,path
indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial/
. For Lambda functions, this is usually of the form/2015-03-31/functions/[FunctionARN]/invocations
. - identity_
source str - The identity source for which authorization is requested. For a
TOKEN
orCOGNITO_USER_POOLS
authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name isAuth
, the header mapping expression ismethod.request.header.Auth
. For theREQUEST
authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if anAuth
header, aName
query string parameter are defined as identity sources, this value ismethod.request.header.Auth, method.request.querystring.Name
. These parameters will be used to derive the authorization caching key and to perform runtime validation of theREQUEST
authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional. - identity_
validation_ strexpression - A validation expression for the incoming identity token. For
TOKEN
authorizers, this value is a regular expression. ForCOGNITO_USER_POOLS
authorizers, API Gateway will match theaud
field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to theREQUEST
authorizer. - name str
- The name of the authorizer.
- provider_
arns Sequence[str] - A list of the Amazon Cognito user pool ARNs for the
COGNITO_USER_POOLS
authorizer. Each element is of this format:arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}
. For aTOKEN
orREQUEST
authorizer, this is not defined.
- rest
Api StringId - The string identifier of the associated RestApi.
- type String
- The authorizer type. Valid values are
TOKEN
for a Lambda function using a single authorization token submitted in a custom header,REQUEST
for a Lambda function using incoming request parameters, andCOGNITO_USER_POOLS
for using an Amazon Cognito user pool. - auth
Type String - Optional customer-defined field, used in OpenAPI imports and exports without functional impact.
- String
- 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.
- Number
- 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.
- String
- Specifies the authorizer's Uniform Resource Identifier (URI). For
TOKEN
orREQUEST
authorizers, this must be a well-formed Lambda function URI, for example,arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations
. In general, the URI has this formarn:aws:apigateway:{region}:lambda:path/{service_api}
, where{region}
is the same as the region hosting the Lambda function,path
indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial/
. For Lambda functions, this is usually of the form/2015-03-31/functions/[FunctionARN]/invocations
. - identity
Source String - The identity source for which authorization is requested. For a
TOKEN
orCOGNITO_USER_POOLS
authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name isAuth
, the header mapping expression ismethod.request.header.Auth
. For theREQUEST
authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if anAuth
header, aName
query string parameter are defined as identity sources, this value ismethod.request.header.Auth, method.request.querystring.Name
. These parameters will be used to derive the authorization caching key and to perform runtime validation of theREQUEST
authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional. - identity
Validation StringExpression - A validation expression for the incoming identity token. For
TOKEN
authorizers, this value is a regular expression. ForCOGNITO_USER_POOLS
authorizers, API Gateway will match theaud
field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to theREQUEST
authorizer. - name String
- The name of the authorizer.
- provider
Arns List<String> - A list of the Amazon Cognito user pool ARNs for the
COGNITO_USER_POOLS
authorizer. Each element is of this format:arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}
. For aTOKEN
orREQUEST
authorizer, this is not defined.
Outputs
All input properties are implicitly available as output properties. Additionally, the Authorizer resource produces the following output properties:
- string
- The ID for the authorizer. For example:
abc123
. - Id string
- The provider-assigned unique ID for this managed resource.
- string
- The ID for the authorizer. For example:
abc123
. - Id string
- The provider-assigned unique ID for this managed resource.
- String
- The ID for the authorizer. For example:
abc123
. - id String
- The provider-assigned unique ID for this managed resource.
- string
- The ID for the authorizer. For example:
abc123
. - id string
- The provider-assigned unique ID for this managed resource.
- str
- The ID for the authorizer. For example:
abc123
. - id str
- The provider-assigned unique ID for this managed resource.
- String
- The ID for the authorizer. For example:
abc123
. - id String
- The provider-assigned unique ID for this managed resource.
Package Details
- Repository
- AWS Native pulumi/pulumi-aws-native
- License
- Apache-2.0
AWS Native is in preview. AWS Classic is fully supported.