interface AuthorizationMode
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.AppSync.AuthorizationMode |
Java | software.amazon.awscdk.services.appsync.AuthorizationMode |
Python | aws_cdk.aws_appsync.AuthorizationMode |
TypeScript (source) | @aws-cdk/aws-appsync » AuthorizationMode |
Interface to specify default or additional authorization(s).
Example
const api = new appsync.GraphqlApi(this, 'Api', {
name: 'demo',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'schema.graphql')),
authorizationConfig: {
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.IAM,
},
},
xrayEnabled: true,
});
const demoTable = new dynamodb.Table(this, 'DemoTable', {
partitionKey: {
name: 'id',
type: dynamodb.AttributeType.STRING,
},
});
const demoDS = api.addDynamoDbDataSource('demoDataSource', demoTable);
// Resolver for the Query "getDemos" that scans the DynamoDb table and returns the entire list.
demoDS.createResolver({
typeName: 'Query',
fieldName: 'getDemos',
requestMappingTemplate: appsync.MappingTemplate.dynamoDbScanTable(),
responseMappingTemplate: appsync.MappingTemplate.dynamoDbResultList(),
});
// Resolver for the Mutation "addDemo" that puts the item into the DynamoDb table.
demoDS.createResolver({
typeName: 'Mutation',
fieldName: 'addDemo',
requestMappingTemplate: appsync.MappingTemplate.dynamoDbPutItem(
appsync.PrimaryKey.partition('id').auto(),
appsync.Values.projecting('input'),
),
responseMappingTemplate: appsync.MappingTemplate.dynamoDbResultItem(),
});
Properties
| Name | Type | Description |
|---|---|---|
| authorization | Authorization | One of possible four values AppSync supports. |
| api | Api | If authorizationType is AuthorizationType.API_KEY, this option can be configured. |
| lambda | Lambda | If authorizationType is AuthorizationType.LAMBDA, this option is required. |
| open | Open | If authorizationType is AuthorizationType.OIDC, this option is required. |
| user | User | If authorizationType is AuthorizationType.USER_POOL, this option is required. |
authorizationType
Type:
Authorization
One of possible four values AppSync supports.
apiKeyConfig?
Type:
Api
(optional, default: name: 'DefaultAPIKey' | description: 'Default API Key created by CDK')
If authorizationType is AuthorizationType.API_KEY, this option can be configured.
lambdaAuthorizerConfig?
Type:
Lambda
(optional, default: none)
If authorizationType is AuthorizationType.LAMBDA, this option is required.
openIdConnectConfig?
Type:
Open
(optional, default: none)
If authorizationType is AuthorizationType.OIDC, this option is required.
userPoolConfig?
Type:
User
(optional, default: none)
If authorizationType is AuthorizationType.USER_POOL, this option is required.

.NET
Java
Python
TypeScript (