@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-07T23:47:01.095Z") @Stability(value=Experimental) public class RdsDataSource extends BackedDataSource
Example:
// Build a data source for AppSync to access the database.
GraphqlApi api;
// Create username and password secret for DB Cluster
DatabaseSecret secret = DatabaseSecret.Builder.create(this, "AuroraSecret")
.username("clusteradmin")
.build();
// The VPC to place the cluster in
Vpc vpc = new Vpc(this, "AuroraVpc");
// Create the serverless cluster, provide all values needed to customise the database.
ServerlessCluster cluster = ServerlessCluster.Builder.create(this, "AuroraCluster")
.engine(DatabaseClusterEngine.AURORA_MYSQL)
.vpc(vpc)
.credentials(Map.of("username", "clusteradmin"))
.clusterIdentifier("db-endpoint-test")
.defaultDatabaseName("demos")
.build();
RdsDataSource rdsDS = api.addRdsDataSource("rds", cluster, secret, "demos");
// Set up a resolver for an RDS query.
rdsDS.createResolver(BaseResolverProps.builder()
.typeName("Query")
.fieldName("getDemosRds")
.requestMappingTemplate(MappingTemplate.fromString("\n {\n \"version\": \"2018-05-29\",\n \"statements\": [\n \"SELECT * FROM demos\"\n ]\n }\n "))
.responseMappingTemplate(MappingTemplate.fromString("\n $utils.toJson($utils.rds.toJsonObject($ctx.result)[0])\n "))
.build());
// Set up a resolver for an RDS mutation.
rdsDS.createResolver(BaseResolverProps.builder()
.typeName("Mutation")
.fieldName("addDemoRds")
.requestMappingTemplate(MappingTemplate.fromString("\n {\n \"version\": \"2018-05-29\",\n \"statements\": [\n \"INSERT INTO demos VALUES (:id, :version)\",\n \"SELECT * WHERE id = :id\"\n ],\n \"variableMap\": {\n \":id\": $util.toJson($util.autoId()),\n \":version\": $util.toJson($ctx.args.version)\n }\n }\n "))
.responseMappingTemplate(MappingTemplate.fromString("\n $utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])\n "))
.build());
| Modifier and Type | Class and Description |
|---|---|
static class |
RdsDataSource.Builder
(experimental) A fluent builder for
RdsDataSource. |
software.amazon.jsii.JsiiObject.InitializationModeIGrantable.Jsii$DefaultIConstruct.Jsii$Default| Modifier | Constructor and Description |
|---|---|
|
RdsDataSource(software.constructs.Construct scope,
String id,
RdsDataSourceProps props) |
protected |
RdsDataSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
RdsDataSource(software.amazon.jsii.JsiiObjectRef objRef) |
getGrantPrincipalcreateFunction, createResolver, getApi, getDs, getName, getServiceRole, setApi, setServiceRolegetNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validatejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected RdsDataSource(software.amazon.jsii.JsiiObjectRef objRef)
protected RdsDataSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Experimental)
public RdsDataSource(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
RdsDataSourceProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.Copyright © 2022. All rights reserved.