Interface IAuthorizationMode
(experimental) Interface to specify default or additional authorization(s).
Namespace: Amazon.CDK.AWS.AppSync
Assembly: Amazon.CDK.AWS.AppSync.dll
Syntax (csharp)
public interface IAuthorizationMode
Syntax (vb)
Public Interface IAuthorizationMode
Remarks
Stability: Experimental
ExampleMetadata: infused
Examples
var api = new GraphqlApi(this, "Api", new GraphqlApiProps {
Name = "demo",
Schema = Schema.FromAsset(Join(__dirname, "schema.graphql")),
AuthorizationConfig = new AuthorizationConfig {
DefaultAuthorization = new AuthorizationMode {
AuthorizationType = AuthorizationType.IAM
}
},
XrayEnabled = true
});
var demoTable = new Table(this, "DemoTable", new TableProps {
PartitionKey = new Attribute {
Name = "id",
Type = AttributeType.STRING
}
});
var demoDS = api.AddDynamoDbDataSource("demoDataSource", demoTable);
// Resolver for the Query "getDemos" that scans the DynamoDb table and returns the entire list.
demoDS.CreateResolver(new BaseResolverProps {
TypeName = "Query",
FieldName = "getDemos",
RequestMappingTemplate = MappingTemplate.DynamoDbScanTable(),
ResponseMappingTemplate = MappingTemplate.DynamoDbResultList()
});
// Resolver for the Mutation "addDemo" that puts the item into the DynamoDb table.
demoDS.CreateResolver(new BaseResolverProps {
TypeName = "Mutation",
FieldName = "addDemo",
RequestMappingTemplate = MappingTemplate.DynamoDbPutItem(PrimaryKey.Partition("id").Auto(), Values.Projecting("input")),
ResponseMappingTemplate = MappingTemplate.DynamoDbResultItem()
});
Synopsis
Properties
ApiKeyConfig | (experimental) If authorizationType is |
AuthorizationType | (experimental) One of possible four values AppSync supports. |
LambdaAuthorizerConfig | (experimental) If authorizationType is |
OpenIdConnectConfig | (experimental) If authorizationType is |
UserPoolConfig | (experimental) If authorizationType is |
Properties
ApiKeyConfig
(experimental) If authorizationType is AuthorizationType.API_KEY
, this option can be configured.
virtual IApiKeyConfig ApiKeyConfig { get; }
Property Value
Remarks
Default: - name: 'DefaultAPIKey' | description: 'Default API Key created by CDK'
Stability: Experimental
AuthorizationType
(experimental) One of possible four values AppSync supports.
AuthorizationType AuthorizationType { get; }
Property Value
Remarks
Default: - AuthorizationType.API_KEY
Stability: Experimental
See: https://docs.aws.amazon.com/appsync/latest/devguide/security.html
LambdaAuthorizerConfig
(experimental) If authorizationType is AuthorizationType.LAMBDA
, this option is required.
virtual ILambdaAuthorizerConfig LambdaAuthorizerConfig { get; }
Property Value
Remarks
Default: - none
Stability: Experimental
OpenIdConnectConfig
(experimental) If authorizationType is AuthorizationType.OIDC
, this option is required.
virtual IOpenIdConnectConfig OpenIdConnectConfig { get; }
Property Value
Remarks
Default: - none
Stability: Experimental
UserPoolConfig
(experimental) If authorizationType is AuthorizationType.USER_POOL
, this option is required.
virtual IUserPoolConfig UserPoolConfig { get; }
Property Value
Remarks
Default: - none
Stability: Experimental