【发布时间】:2018-06-24 22:39:14
【问题描述】:
以下是 YAML 格式的示例云形成文件。这个想法是让 Route53 记录依赖于 RDS 数据库的创建,然后在创建后从 RDS 数据库的端点获取值。
我在这些参考文档中进行了很多研究,但始终未能正确获取语法。
您可以看到它应该有一个返回值,但我不确定如何获取它并将其用于 route53 cName 记录名称。
resources:
Resources:
uploadBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.uploadBucket}
RDSDatabase:
Type: AWS::RDS::DBInstance
Properties:
Engine : mysql
MasterUsername: ${env:RDS_USERNAME}
MasterUserPassword: ${env:RDS_PASSWORD}
DBInstanceClass : db.t2.micro
AllocatedStorage: '5'
PubliclyAccessible: true
#TODO: The Value of Stage is also available as a TAG automatically which I may use to replace this manually being put here..
Tags:
-
Key: "Name"
Value: ${self:custom.databaseName}
DeletionPolicy: Snapshot
DNSRecordSet:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneName: mydomain.com.
Name: database-${self:custom.stage}.mydomain.com
Type: CNAME
TTL: '300'
ResourceRecords:
- [[Put End Point Here]]
DependsOn: RDSDatabase
我试过这样做,但没有运气- ${!Ref RDSDatabase.Endpoint.Address}
An error occurred: DNSRecordSet - Invalid Resource Record: FATAL problem: RRDATANotSingleField (Value contains spaces) encounte
red with '${!Ref RDSDatabase.Endpoint.Address}'.
【问题讨论】:
-
我在这里找到了一些非常接近我需要的东西,forums.aws.amazon.com/thread.jspa?threadID=69082,只是不断出现语法错误,不确定 YAML 是否等效?
标签: amazon-rds amazon-cloudformation amazon-route53 serverless-framework serverless