AuthorizationConfig

class aws_cdk.aws_appsync.AuthorizationConfig(*, additional_authorization_modes=None, default_authorization=None)

Bases: object

(experimental) Configuration of the API authorization modes.

Parameters:
  • additional_authorization_modes (Optional[Sequence[Union[AuthorizationMode, Dict[str, Any]]]]) – (experimental) Additional authorization modes. Default: - No other modes

  • default_authorization (Union[AuthorizationMode, Dict[str, Any], None]) – (experimental) Optional authorization configuration. Default: - API Key authorization

Stability:

experimental

ExampleMetadata:

infused

Example:

api = appsync.GraphqlApi(self, "Api",
    name="demo",
    schema=appsync.Schema.from_asset(path.join(__dirname, "schema.graphql")),
    authorization_config=appsync.AuthorizationConfig(
        default_authorization=appsync.AuthorizationMode(
            authorization_type=appsync.AuthorizationType.IAM
        )
    ),
    xray_enabled=True
)

demo_table = dynamodb.Table(self, "DemoTable",
    partition_key=dynamodb.Attribute(
        name="id",
        type=dynamodb.AttributeType.STRING
    )
)

demo_dS = api.add_dynamo_db_data_source("demoDataSource", demo_table)

# Resolver for the Query "getDemos" that scans the DynamoDb table and returns the entire list.
demo_dS.create_resolver(
    type_name="Query",
    field_name="getDemos",
    request_mapping_template=appsync.MappingTemplate.dynamo_db_scan_table(),
    response_mapping_template=appsync.MappingTemplate.dynamo_db_result_list()
)

# Resolver for the Mutation "addDemo" that puts the item into the DynamoDb table.
demo_dS.create_resolver(
    type_name="Mutation",
    field_name="addDemo",
    request_mapping_template=appsync.MappingTemplate.dynamo_db_put_item(
        appsync.PrimaryKey.partition("id").auto(),
        appsync.Values.projecting("input")),
    response_mapping_template=appsync.MappingTemplate.dynamo_db_result_item()
)

Attributes

additional_authorization_modes

(experimental) Additional authorization modes.

Default:
  • No other modes

Stability:

experimental

default_authorization

(experimental) Optional authorization configuration.

Default:
  • API Key authorization

Stability:

experimental