Serverless/Cloudformation 依赖于另一个资源存在的资源
Serverless/Cloudformation resource that depends on the existence of another resource
我正在尝试使用无服务器框架部署 Kinesis Firehose,它输出到 ElasticSearch 域。
由于 Firehose 在创建之前需要 ES 域已经存在,我 运行 陷入了这个错误:
An error occurred: MyFirehoseStream - Domain
arn:aws:es:us-east-1:1234567890:domain/my-elastic-search is still
being created.
有没有办法让Firehose的创建等到ES域创建完成之后?
为了以防万一,这里是我的 serverless.yml
文件的相关部分:
fyi,我正在使用 serverless-pseudo-parameters
插件来使用 #{AWS::Region}
和 #{AWS::AccountId}
resources:
Resources:
MyFirehoseStream:
Type: "AWS::KinesisFirehose::DeliveryStream"
Properties:
DeliveryStreamName: "MyFirehoseStream"
DeliveryStreamType: "DirectPut"
ElasticsearchDestinationConfiguration:
BufferingHints:
IntervalInSeconds: 300
SizeInMBs: 5
DomainARN: "arn:aws:es:#{AWS::Region}:#{AWS::AccountId}:domain/my-elastic-search"
IndexName: "myindex"
IndexRotationPeriod: "NoRotation"
RetryOptions:
DurationInSeconds: 300
RoleARN: { "Fn::GetAtt": ["FirehoseBackupBucketRole", "Arn" ] }
S3BackupMode: "FailedDocumentsOnly"
S3Configuration:
BucketARN: { "Fn::GetAtt": ["FirehoseBackupBucket", "Arn" ] }
BufferingHints:
IntervalInSeconds: 300
SizeInMBs: 5
CompressionFormat: "GZIP"
RoleARN: { "Fn::GetAtt": ["FirehoseBackupBucketRole", "Arn" ] }
TypeName: "mytype"
MyElasticSearch:
Type: "AWS::Elasticsearch::Domain"
Properties:
AccessPolicies: ${file(./iam_policies/elastic-search.json)}
DomainName: "my-elastic-search"
ElasticsearchVersion: 6.2
ElasticsearchClusterConfig:
InstanceCount: "1"
InstanceType: "t2.small.elasticsearch"
EBSOptions:
EBSEnabled: true
Iops: 0
VolumeSize: 10
VolumeType: "gp2"
更新:
我现在已经修复了这个问题,以防万一这些细节对任何人都有帮助:
我将 DomainARN
属性 更改为 { "Fn::GetAtt": ["MyElasticSearch", "DomainArn" ] }
。
我最初动态生成 ARN 的原因是因为对于 "Fn::GetAtt"
,我最初尝试仅使用 Arn
而不是 DomainArn
,但它不起作用。巧合的是,DomainArn
在最新版本中已被弃用,因此如果您使用的是最新版本,Arn
实际上是正确的。
Cloudformation 资源支持 DependsOn
属性。
resources:
Resources:
MyFirehoseStream:
Type: "AWS::KinesisFirehose::DeliveryStream"
DependsOn: MyElasticSearch
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html
我正在尝试使用无服务器框架部署 Kinesis Firehose,它输出到 ElasticSearch 域。
由于 Firehose 在创建之前需要 ES 域已经存在,我 运行 陷入了这个错误:
An error occurred: MyFirehoseStream - Domain arn:aws:es:us-east-1:1234567890:domain/my-elastic-search is still being created.
有没有办法让Firehose的创建等到ES域创建完成之后?
为了以防万一,这里是我的 serverless.yml
文件的相关部分:
fyi,我正在使用 serverless-pseudo-parameters
插件来使用 #{AWS::Region}
和 #{AWS::AccountId}
resources:
Resources:
MyFirehoseStream:
Type: "AWS::KinesisFirehose::DeliveryStream"
Properties:
DeliveryStreamName: "MyFirehoseStream"
DeliveryStreamType: "DirectPut"
ElasticsearchDestinationConfiguration:
BufferingHints:
IntervalInSeconds: 300
SizeInMBs: 5
DomainARN: "arn:aws:es:#{AWS::Region}:#{AWS::AccountId}:domain/my-elastic-search"
IndexName: "myindex"
IndexRotationPeriod: "NoRotation"
RetryOptions:
DurationInSeconds: 300
RoleARN: { "Fn::GetAtt": ["FirehoseBackupBucketRole", "Arn" ] }
S3BackupMode: "FailedDocumentsOnly"
S3Configuration:
BucketARN: { "Fn::GetAtt": ["FirehoseBackupBucket", "Arn" ] }
BufferingHints:
IntervalInSeconds: 300
SizeInMBs: 5
CompressionFormat: "GZIP"
RoleARN: { "Fn::GetAtt": ["FirehoseBackupBucketRole", "Arn" ] }
TypeName: "mytype"
MyElasticSearch:
Type: "AWS::Elasticsearch::Domain"
Properties:
AccessPolicies: ${file(./iam_policies/elastic-search.json)}
DomainName: "my-elastic-search"
ElasticsearchVersion: 6.2
ElasticsearchClusterConfig:
InstanceCount: "1"
InstanceType: "t2.small.elasticsearch"
EBSOptions:
EBSEnabled: true
Iops: 0
VolumeSize: 10
VolumeType: "gp2"
更新:
我现在已经修复了这个问题,以防万一这些细节对任何人都有帮助:
我将 DomainARN
属性 更改为 { "Fn::GetAtt": ["MyElasticSearch", "DomainArn" ] }
。
我最初动态生成 ARN 的原因是因为对于 "Fn::GetAtt"
,我最初尝试仅使用 Arn
而不是 DomainArn
,但它不起作用。巧合的是,DomainArn
在最新版本中已被弃用,因此如果您使用的是最新版本,Arn
实际上是正确的。
Cloudformation 资源支持 DependsOn
属性。
resources:
Resources:
MyFirehoseStream:
Type: "AWS::KinesisFirehose::DeliveryStream"
DependsOn: MyElasticSearch
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html