Authorizer
Provides an API Gateway Authorizer.
Example Usage
Coming soon!
Coming soon!
Coming soon!
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const demoRestApi = new aws.apigateway.RestApi("demo", {});
const invocationRole = new aws.iam.Role("invocation_role", {
assumeRolePolicy: `{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "apigateway.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
`,
path: "/",
});
const lambda = new aws.iam.Role("lambda", {
assumeRolePolicy: `{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
`,
});
const authorizer = new aws.lambda.Function("authorizer", {
code: new pulumi.asset.FileArchive("lambda-function.zip"),
handler: "exports.example",
role: lambda.arn,
});
const demoAuthorizer = new aws.apigateway.Authorizer("demo", {
authorizerCredentials: invocationRole.arn,
authorizerUri: authorizer.invokeArn,
restApi: demoRestApi.id,
});
const invocationPolicy = new aws.iam.RolePolicy("invocation_policy", {
policy: pulumi.interpolate`{
"Version": "2012-10-17",
"Statement": [
{
"Action": "lambda:InvokeFunction",
"Effect": "Allow",
"Resource": "${authorizer.arn}"
}
]
}
`,
role: invocationRole.id,
});Create a Authorizer Resource
new Authorizer(name: string, args: AuthorizerArgs, opts?: CustomResourceOptions);def Authorizer(resource_name, opts=None, authorizer_credentials=None, authorizer_result_ttl_in_seconds=None, authorizer_uri=None, identity_source=None, identity_validation_expression=None, name=None, provider_arns=None, rest_api=None, type=None, __props__=None);func NewAuthorizer(ctx *Context, name string, args AuthorizerArgs, opts ...ResourceOption) (*Authorizer, error)public Authorizer(string name, AuthorizerArgs args, CustomResourceOptions? opts = null)- 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.
- 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 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.
Authorizer Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The Authorizer resource accepts the following input properties:
- Rest
Api string The ID of the associated REST API
- string
The credentials required for the authorizer. To specify an IAM Role for API Gateway to assume, use the IAM Role ARN.
- int
The TTL of cached authorizer results in seconds. Defaults to
300.- string
The authorizer’s Uniform Resource Identifier (URI). This must be a well-formed Lambda function URI in the form of
arn:aws:apigateway:{region}:lambda:path/{service_api}, e.g.arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:012345678912:function:my-function/invocations- Identity
Source string The source of the identity in an incoming request. Defaults to
method.request.header.Authorization. ForREQUESTtype, this may be a comma-separated list of values, including headers, query string parameters and stage variables - e.g."method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName,stageVariables.SomeStageVariableName"- Identity
Validation stringExpression A validation expression for the incoming identity. For
TOKENtype, this value should be a regular expression. The incoming token from the client is matched against this expression, and will proceed if the token matches. If the token doesn’t match, the client receives a 401 Unauthorized response.- Name string
The name of the authorizer
- Provider
Arns List<string> A list of the Amazon Cognito user pool ARNs. Each element is of this format:
arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}.- Type string
The type of the authorizer. Possible values are
TOKENfor a Lambda function using a single authorization token submitted in a custom header,REQUESTfor a Lambda function using incoming request parameters, orCOGNITO_USER_POOLSfor using an Amazon Cognito user pool. Defaults toTOKEN.
- Rest
Api interface{} The ID of the associated REST API
- string
The credentials required for the authorizer. To specify an IAM Role for API Gateway to assume, use the IAM Role ARN.
- int
The TTL of cached authorizer results in seconds. Defaults to
300.- string
The authorizer’s Uniform Resource Identifier (URI). This must be a well-formed Lambda function URI in the form of
arn:aws:apigateway:{region}:lambda:path/{service_api}, e.g.arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:012345678912:function:my-function/invocations- Identity
Source string The source of the identity in an incoming request. Defaults to
method.request.header.Authorization. ForREQUESTtype, this may be a comma-separated list of values, including headers, query string parameters and stage variables - e.g."method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName,stageVariables.SomeStageVariableName"- Identity
Validation stringExpression A validation expression for the incoming identity. For
TOKENtype, this value should be a regular expression. The incoming token from the client is matched against this expression, and will proceed if the token matches. If the token doesn’t match, the client receives a 401 Unauthorized response.- Name string
The name of the authorizer
- Provider
Arns []string A list of the Amazon Cognito user pool ARNs. Each element is of this format:
arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}.- Type string
The type of the authorizer. Possible values are
TOKENfor a Lambda function using a single authorization token submitted in a custom header,REQUESTfor a Lambda function using incoming request parameters, orCOGNITO_USER_POOLSfor using an Amazon Cognito user pool. Defaults toTOKEN.
- rest
Api string | RestApi The ID of the associated REST API
- string
The credentials required for the authorizer. To specify an IAM Role for API Gateway to assume, use the IAM Role ARN.
- number
The TTL of cached authorizer results in seconds. Defaults to
300.- string
The authorizer’s Uniform Resource Identifier (URI). This must be a well-formed Lambda function URI in the form of
arn:aws:apigateway:{region}:lambda:path/{service_api}, e.g.arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:012345678912:function:my-function/invocations- identity
Source string The source of the identity in an incoming request. Defaults to
method.request.header.Authorization. ForREQUESTtype, this may be a comma-separated list of values, including headers, query string parameters and stage variables - e.g."method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName,stageVariables.SomeStageVariableName"- identity
Validation stringExpression A validation expression for the incoming identity. For
TOKENtype, this value should be a regular expression. The incoming token from the client is matched against this expression, and will proceed if the token matches. If the token doesn’t match, the client receives a 401 Unauthorized response.- name string
The name of the authorizer
- provider
Arns string[] A list of the Amazon Cognito user pool ARNs. Each element is of this format:
arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}.- type string
The type of the authorizer. Possible values are
TOKENfor a Lambda function using a single authorization token submitted in a custom header,REQUESTfor a Lambda function using incoming request parameters, orCOGNITO_USER_POOLSfor using an Amazon Cognito user pool. Defaults toTOKEN.
- rest_
api string | str The ID of the associated REST API
- str
The credentials required for the authorizer. To specify an IAM Role for API Gateway to assume, use the IAM Role ARN.
- float
The TTL of cached authorizer results in seconds. Defaults to
300.- str
The authorizer’s Uniform Resource Identifier (URI). This must be a well-formed Lambda function URI in the form of
arn:aws:apigateway:{region}:lambda:path/{service_api}, e.g.arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:012345678912:function:my-function/invocations- identity_
source str The source of the identity in an incoming request. Defaults to
method.request.header.Authorization. ForREQUESTtype, this may be a comma-separated list of values, including headers, query string parameters and stage variables - e.g."method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName,stageVariables.SomeStageVariableName"- identity_
validation_ strexpression A validation expression for the incoming identity. For
TOKENtype, this value should be a regular expression. The incoming token from the client is matched against this expression, and will proceed if the token matches. If the token doesn’t match, the client receives a 401 Unauthorized response.- name str
The name of the authorizer
- provider_
arns List[str] A list of the Amazon Cognito user pool ARNs. Each element is of this format:
arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}.- type str
The type of the authorizer. Possible values are
TOKENfor a Lambda function using a single authorization token submitted in a custom header,REQUESTfor a Lambda function using incoming request parameters, orCOGNITO_USER_POOLSfor using an Amazon Cognito user pool. Defaults toTOKEN.
Outputs
All input properties are implicitly available as output properties. Additionally, the Authorizer resource produces the following output properties:
Look up an Existing Authorizer Resource
Get an existing Authorizer 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?: AuthorizerState, opts?: CustomResourceOptions): Authorizerstatic get(resource_name, id, opts=None, authorizer_credentials=None, authorizer_result_ttl_in_seconds=None, authorizer_uri=None, identity_source=None, identity_validation_expression=None, name=None, provider_arns=None, rest_api=None, type=None, __props__=None);func GetAuthorizer(ctx *Context, name string, id IDInput, state *AuthorizerState, opts ...ResourceOption) (*Authorizer, error)public static Authorizer Get(string name, Input<string> id, AuthorizerState? 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:
- string
The credentials required for the authorizer. To specify an IAM Role for API Gateway to assume, use the IAM Role ARN.
- int
The TTL of cached authorizer results in seconds. Defaults to
300.- string
The authorizer’s Uniform Resource Identifier (URI). This must be a well-formed Lambda function URI in the form of
arn:aws:apigateway:{region}:lambda:path/{service_api}, e.g.arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:012345678912:function:my-function/invocations- Identity
Source string The source of the identity in an incoming request. Defaults to
method.request.header.Authorization. ForREQUESTtype, this may be a comma-separated list of values, including headers, query string parameters and stage variables - e.g."method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName,stageVariables.SomeStageVariableName"- Identity
Validation stringExpression A validation expression for the incoming identity. For
TOKENtype, this value should be a regular expression. The incoming token from the client is matched against this expression, and will proceed if the token matches. If the token doesn’t match, the client receives a 401 Unauthorized response.- Name string
The name of the authorizer
- Provider
Arns List<string> A list of the Amazon Cognito user pool ARNs. Each element is of this format:
arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}.- Rest
Api string The ID of the associated REST API
- Type string
The type of the authorizer. Possible values are
TOKENfor a Lambda function using a single authorization token submitted in a custom header,REQUESTfor a Lambda function using incoming request parameters, orCOGNITO_USER_POOLSfor using an Amazon Cognito user pool. Defaults toTOKEN.
- string
The credentials required for the authorizer. To specify an IAM Role for API Gateway to assume, use the IAM Role ARN.
- int
The TTL of cached authorizer results in seconds. Defaults to
300.- string
The authorizer’s Uniform Resource Identifier (URI). This must be a well-formed Lambda function URI in the form of
arn:aws:apigateway:{region}:lambda:path/{service_api}, e.g.arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:012345678912:function:my-function/invocations- Identity
Source string The source of the identity in an incoming request. Defaults to
method.request.header.Authorization. ForREQUESTtype, this may be a comma-separated list of values, including headers, query string parameters and stage variables - e.g."method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName,stageVariables.SomeStageVariableName"- Identity
Validation stringExpression A validation expression for the incoming identity. For
TOKENtype, this value should be a regular expression. The incoming token from the client is matched against this expression, and will proceed if the token matches. If the token doesn’t match, the client receives a 401 Unauthorized response.- Name string
The name of the authorizer
- Provider
Arns []string A list of the Amazon Cognito user pool ARNs. Each element is of this format:
arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}.- Rest
Api interface{} The ID of the associated REST API
- Type string
The type of the authorizer. Possible values are
TOKENfor a Lambda function using a single authorization token submitted in a custom header,REQUESTfor a Lambda function using incoming request parameters, orCOGNITO_USER_POOLSfor using an Amazon Cognito user pool. Defaults toTOKEN.
- string
The credentials required for the authorizer. To specify an IAM Role for API Gateway to assume, use the IAM Role ARN.
- number
The TTL of cached authorizer results in seconds. Defaults to
300.- string
The authorizer’s Uniform Resource Identifier (URI). This must be a well-formed Lambda function URI in the form of
arn:aws:apigateway:{region}:lambda:path/{service_api}, e.g.arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:012345678912:function:my-function/invocations- identity
Source string The source of the identity in an incoming request. Defaults to
method.request.header.Authorization. ForREQUESTtype, this may be a comma-separated list of values, including headers, query string parameters and stage variables - e.g."method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName,stageVariables.SomeStageVariableName"- identity
Validation stringExpression A validation expression for the incoming identity. For
TOKENtype, this value should be a regular expression. The incoming token from the client is matched against this expression, and will proceed if the token matches. If the token doesn’t match, the client receives a 401 Unauthorized response.- name string
The name of the authorizer
- provider
Arns string[] A list of the Amazon Cognito user pool ARNs. Each element is of this format:
arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}.- rest
Api string | RestApi The ID of the associated REST API
- type string
The type of the authorizer. Possible values are
TOKENfor a Lambda function using a single authorization token submitted in a custom header,REQUESTfor a Lambda function using incoming request parameters, orCOGNITO_USER_POOLSfor using an Amazon Cognito user pool. Defaults toTOKEN.
- str
The credentials required for the authorizer. To specify an IAM Role for API Gateway to assume, use the IAM Role ARN.
- float
The TTL of cached authorizer results in seconds. Defaults to
300.- str
The authorizer’s Uniform Resource Identifier (URI). This must be a well-formed Lambda function URI in the form of
arn:aws:apigateway:{region}:lambda:path/{service_api}, e.g.arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:012345678912:function:my-function/invocations- identity_
source str The source of the identity in an incoming request. Defaults to
method.request.header.Authorization. ForREQUESTtype, this may be a comma-separated list of values, including headers, query string parameters and stage variables - e.g."method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName,stageVariables.SomeStageVariableName"- identity_
validation_ strexpression A validation expression for the incoming identity. For
TOKENtype, this value should be a regular expression. The incoming token from the client is matched against this expression, and will proceed if the token matches. If the token doesn’t match, the client receives a 401 Unauthorized response.- name str
The name of the authorizer
- provider_
arns List[str] A list of the Amazon Cognito user pool ARNs. Each element is of this format:
arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}.- rest_
api string | str The ID of the associated REST API
- type str
The type of the authorizer. Possible values are
TOKENfor a Lambda function using a single authorization token submitted in a custom header,REQUESTfor a Lambda function using incoming request parameters, orCOGNITO_USER_POOLSfor using an Amazon Cognito user pool. Defaults toTOKEN.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.