Authentication definitions are found under the appSync.authentication
(for the default authentication method) and appSync.additionalAuthentications
(as an array) for additional ones
appSync:
authentication:
type: 'API_KEY'
additionalAuthentications:
- type: 'AMAZON_COGNITO_USER_POOLS'
config:
userPoolId: '123456789'
type
: The type of authentication. Can beAPI_KEY
,AWS_IAM
,AMAZON_COGNITO_USER_POOLS
,AWS_LAMBDA
orOPENID_CONNECT
config
: The configuration for the providedtype
(See below).
Enables the API Key based authentication. See the API Keys section to see how to configure them.
appSync:
authentication:
type: 'API_KEY'
config
is not required for this type.
Allows IAM users and roles to access the API.
appSync:
authentication:
type: 'AWS_IAM'
config
is not required for this type.
Allows authentication using a Cognito user pool.
appSync:
authentication:
type: 'AMAZON_COGNITO_USER_POOLS'
config:
userPoolId: '123456789'
userPoolId
: The user pool id to use.awsRegion
: The region where the user pool is located. Defaults to the stack's region.appIdClientRegex
: An optional regular expression for validating the incoming Amazon Cognito user pool app client ID.defaultAction
:ALLOW
orDENY
. The action that you want your GraphQL API to take when a request that uses Amazon Cognito user pool authentication doesn't match the Amazon Cognito user pool configuration. When specifying Amazon Cognito user pools as the default authentication, you must set this value toALLOW
if specifying additionalAuthentications. Default:ALLOW
. This field is only available for the defaultauthorization
configuration.
Allows users to authenticate against the API using a third-party OIDC auth provider.
appSync:
authentication:
type: 'OPENID_CONNECT'
config:
issuer: 'https://auth.example.com'
clientId: '5fbc318d-5920-48a8-92ea-20d62d16cc60'
issuer
: The issuer of this OIDC config.clientId
: Optional. The client identifier of the Relying party at the OpenID identity provider. This identifier is typically obtained when the Relying party is registered with the OpenID identity provider. You can specify a regular expression so that AWS AppSync can validate against multiple client identifiers at a time.iatTTL
: Optional. The number of milliseconds that a token is valid after it's issued to a user.authTTL
: Optional. The number of milliseconds that a token is valid after being authenticated.
Allows custom authentication through Lambda.
appSync:
authentication:
type: 'AWS_LAMBDA'
config:
authorizerResultTtlInSeconds: 300
function:
timeout: 30
handler: 'functions/auth.handler'
identityValidationExpression
: Optional. A regular expression for validation of tokens before the Lambda function is called.authorizerResultTtlInSeconds
: Optional. The number of seconds a response should be cached for. The default is 5 minutes (300 seconds).function
: A Lambda function definition as you would define it under thefunctions
section of yourserverless.yml
file.functionName
: The name of the function as defined under thefunctions
section of theserverless.yml
filefunctionAlias
: A specific function alias to use.functionArn
: The function ARN to use.