Enable Aurora Data Api from CloudFormation

Set the EnableHttpEndpoint property to true, e.g.:

AWSTemplateFormatVersion: '2010-09-09'
Description: Aurora PostgreSQL Serverless Cluster
Resources:
  ServerlessWithDataAPI:
    Type: AWS::RDS::DBCluster
    Properties:
      Engine: aurora-postgresql
      EngineMode: serverless
      EnableHttpEndpoint: true
      ScalingConfiguration:
        ...

You can enable the Data API from CloudFormation by creating a custom resource backed lambda and enable it using any of the available SDK.

I use boto3 (python), so the lambda would have code similar as below:

import boto3

client = boto3.client('rds')

response = client.modify_db_cluster(
    DBClusterIdentifier='string',
    EnableHttpEndpoint=True|False
) 

Obviously, you need to handle different custom resource request types and return from the lambda with success or failure. But to answer your question, this is the best possible way to set up data API via CloudFormation, for now, IMHO.

For more information about the function (Boto3): https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html#RDS.Client.modify_db_cluster


Enabling the Data API is currently only possible in the web console. This feature is still in beta so things like CloudFormation support and availability outside of us-east-1 are still pending, and using the Data API in production should be done with caution as it may still change.