amazon-web-services - CloudFormation:以 HostedZone 身份访问 PrivateDnsNamespace
问题描述
的文档ServiceDiscovery::PrivateDnsNamespace
指出:
当您创建私有 DNS 命名空间时,AWS Cloud Map 会自动创建一个与命名空间同名的 Amazon Route 53 私有托管区域。
在 CloudFormation 中,有什么方法可以访问创建的HostedZone
(作为 a Route53::HostedZone
),以便我可以向其中添加额外Route53:RecordSet
的 s?
- 身份证是一样的吗?
- 我可以包含一个
Route53::HostedZone
同名以获得正确的 ID 吗? - 是不是还有什么妙招?
例如,我想在私有 DNS 条目中公开我的 RDS 和 ElastiCache (Redis) 实例。我意识到这可能是 XY 问题,但我正在我的遗留代码中的标准位置访问这些系统,并尝试在我的第一次 ECS 尝试中最小化定制(以及潜在的错误)。
警告:虽然 AWS 服务发现策略可用于公开 DB 和 RDS 等服务,但有几个条件:
- AWS Service Discovery 需要语法
<name>.<namespace>
,因此您不能简单地在db
和处公开服务redis
。您获得“标准”域的最佳机会类似于redis.local
和db.local
。虽然local
是保留的 TLD,但对其使用存在一些敌意。 - RDS SSL 证书与 RDS 域名绑定,不支持自定义 SSL 证书,因此您无法在
db.<mydomain>.com
. 如果您不使用 RDS CNAME,您将无法通过受信任的 SSL 连接连接到这些实例。
解决方案
无法访问HostedZone
在 CloudFormation 中创建的内容。
不过,如果您想向此私有区域添加其他记录,您可以使用AWS::ServiceDiscovery::Service
和AWS::ServiceDiscovery::Instance
资源。
基本上,您需要为您的 RDS 实例创建一项服务,并为您的 Redis 实例创建一项服务。然后在服务中创建实例。
RDS 示例:
RDSSDService:
Type: AWS::ServiceDiscovery::Service
Properties:
DnsConfig:
DnsRecords:
- TTL: 60
Type: CNAME
NamespaceId:
Ref: YourNamespace
RoutingPolicy: WEIGHTED
Name: my-rds-service # this will become the record name
NamespaceId:
Ref: YourNamespace
RDSSDInstance: # If your RDS instance is in the same stack
Type: AWS::ServiceDiscovery::Instance
Properties:
InstanceAttributes:
AWS_INSTANCE_CNAME:
Fn::GetAtt:
- YourInstanceLogicalName
- Endpoint.Address
ServiceId:
Fn::GetAtt:
- RDSSDService
- Id
InstanceId: # this is optional
Ref: YourInstanceLogicalName
RDSInstance: # If referencing an existing instance
Type: AWS::ServiceDiscovery::Instance
Properties:
InstanceAttributes:
AWS_INSTANCE_CNAME: xyz.abc.us-east-1.rds.amazonaws.com # or with Fn::ImportValue
ServiceId:
Fn::GetAtt:
- RDSSDService
- Id
InstanceId: xyz # this is optional
推荐阅读
- sql - PostgreSQL 参考数据可能在一个或另一个表中
- cordova - Firebase Cloud Messaging - 静默通知在后台不起作用(iOS)
- reactjs - 使用 React JS 将数据发布到 API
- c# - VersionControl TFS API 以编程方式获取搁置的项目 c#
- python - 如何使用 Python 通过按钮下载 csv?
- multithreading - RxJava:理解并发执行
- python-3.x - 使用python3.6在html表中抓取动态数据
- docker - Kafka:使用 wurstmeister/zookeeper 映像在 Docker 中设置 Kafka Zookeeper 集群时出错
- sql - XML 解析 - SQL Server
- kubernetes - 删除 pod 后 kubernetes pod 无法挂载 gcloud 持久化磁盘