AuroraPostgresClusterEngineProps

class aws_cdk.aws_rds.AuroraPostgresClusterEngineProps(*, version)

Bases: object

Creation properties of the Aurora PostgreSQL database cluster engine.

Used in DatabaseClusterEngine.auroraPostgres.

Parameters:

version (AuroraPostgresEngineVersion) – The version of the Aurora PostgreSQL cluster engine.

ExampleMetadata:

infused

Example:

# Build a data source for AppSync to access the database.
# api: appsync.GraphqlApi
# Create username and password secret for DB Cluster
secret = rds.DatabaseSecret(self, "AuroraSecret",
    username="clusteradmin"
)

# The VPC to place the cluster in
vpc = ec2.Vpc(self, "AuroraVpc")

# Create the serverless cluster, provide all values needed to customise the database.
cluster = rds.DatabaseCluster(self, "AuroraClusterV2",
    engine=rds.DatabaseClusterEngine.aurora_postgres(version=rds.AuroraPostgresEngineVersion.VER_15_5),
    credentials={"username": "clusteradmin"},
    cluster_identifier="db-endpoint-test",
    writer=rds.ClusterInstance.serverless_v2("writer"),
    serverless_v2_min_capacity=2,
    serverless_v2_max_capacity=10,
    vpc=vpc,
    default_database_name="demos",
    enable_data_api=True
)
rds_dS = api.add_rds_data_source_v2("rds", cluster, secret, "demos")

# Set up a resolver for an RDS query.
rds_dS.create_resolver("QueryGetDemosRdsResolver",
    type_name="Query",
    field_name="getDemosRds",
    request_mapping_template=appsync.MappingTemplate.from_string("""
          {
            "version": "2018-05-29",
            "statements": [
              "SELECT * FROM demos"
            ]
          }
          """),
    response_mapping_template=appsync.MappingTemplate.from_string("""
            $utils.toJson($utils.rds.toJsonObject($ctx.result)[0])
          """)
)

# Set up a resolver for an RDS mutation.
rds_dS.create_resolver("MutationAddDemoRdsResolver",
    type_name="Mutation",
    field_name="addDemoRds",
    request_mapping_template=appsync.MappingTemplate.from_string("""
          {
            "version": "2018-05-29",
            "statements": [
              "INSERT INTO demos VALUES (:id, :version)",
              "SELECT * WHERE id = :id"
            ],
            "variableMap": {
              ":id": $util.toJson($util.autoId()),
              ":version": $util.toJson($ctx.args.version)
            }
          }
          """),
    response_mapping_template=appsync.MappingTemplate.from_string("""
            $utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])
          """)
)

Attributes

version

The version of the Aurora PostgreSQL cluster engine.