从 CloudFormation 启用 Aurora 数据 Api
Enable Aurora Data Api from CloudFormation
我有一个 CloudFormation 模板,它使用 aurora serverless 创建我的 RDS 集群。我希望在启用数据 API 的情况下创建集群。
Web 控制台上存在该选项:
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html
但我在 CloudFormation 文档中找不到它。
如何从模板中启用此选项?
启用数据API 目前只能在网络控制台中使用。此功能仍处于测试阶段,因此诸如 CloudFormation 支持和 us-east-1 之外的可用性之类的事情仍在等待中,并且在生产中使用数据 API 时应谨慎,因为它可能仍会发生变化。
您可以通过创建自定义资源支持的 lambda 并使用任何可用的 SDK 启用 CloudFormation 中的数据 API。
我使用 boto3 (python),因此 lambda 的代码类似于以下内容:
import boto3
client = boto3.client('rds')
response = client.modify_db_cluster(
DBClusterIdentifier='string',
EnableHttpEndpoint=True|False
)
显然,您需要处理不同的自定义资源请求类型和 return 来自 lambda 的成功或失败。但是为了回答您的问题,这是目前通过 CloudFormation 设置数据 API 的最佳方式,恕我直言。
有关函数 (Boto3) 的更多信息:
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html#RDS.Client.modify_db_cluster
将the EnableHttpEndpoint
property设置为true
,例如:
AWSTemplateFormatVersion: '2010-09-09'
Description: Aurora PostgreSQL Serverless Cluster
Resources:
ServerlessWithDataAPI:
Type: AWS::RDS::DBCluster
Properties:
Engine: aurora-postgresql
EngineMode: serverless
EnableHttpEndpoint: true
ScalingConfiguration:
...
我有一个 CloudFormation 模板,它使用 aurora serverless 创建我的 RDS 集群。我希望在启用数据 API 的情况下创建集群。
Web 控制台上存在该选项: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html
但我在 CloudFormation 文档中找不到它。 如何从模板中启用此选项?
启用数据API 目前只能在网络控制台中使用。此功能仍处于测试阶段,因此诸如 CloudFormation 支持和 us-east-1 之外的可用性之类的事情仍在等待中,并且在生产中使用数据 API 时应谨慎,因为它可能仍会发生变化。
您可以通过创建自定义资源支持的 lambda 并使用任何可用的 SDK 启用 CloudFormation 中的数据 API。
我使用 boto3 (python),因此 lambda 的代码类似于以下内容:
import boto3
client = boto3.client('rds')
response = client.modify_db_cluster(
DBClusterIdentifier='string',
EnableHttpEndpoint=True|False
)
显然,您需要处理不同的自定义资源请求类型和 return 来自 lambda 的成功或失败。但是为了回答您的问题,这是目前通过 CloudFormation 设置数据 API 的最佳方式,恕我直言。
有关函数 (Boto3) 的更多信息: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html#RDS.Client.modify_db_cluster
将the EnableHttpEndpoint
property设置为true
,例如:
AWSTemplateFormatVersion: '2010-09-09'
Description: Aurora PostgreSQL Serverless Cluster
Resources:
ServerlessWithDataAPI:
Type: AWS::RDS::DBCluster
Properties:
Engine: aurora-postgresql
EngineMode: serverless
EnableHttpEndpoint: true
ScalingConfiguration:
...