我需要使用AWS elasticsearch服务,但也希望自动化它。我们有无服务器配置。我们如何使用serverless.yml创建AWS elasticsearch服务?
答案 0 :(得分:19)
您可以将CloudFormation资源添加到"资源"部分。对于ElasticSearch,这看起来像这样。
service: aws-nodejs
provider:
name: aws
runtime: nodejs6.10
functions:
hello:
handler: handler.hello
environment:
elasticURL:
Fn::GetAtt: [ ElasticSearchInstance , DomainEndpoint ]
resources:
Resources:
ElasticSearchInstance:
Type: AWS::Elasticsearch::Domain
Properties:
EBSOptions:
EBSEnabled: true
VolumeType: gp2
VolumeSize: 10
ElasticsearchClusterConfig:
InstanceType: t2.small.elasticsearch
InstanceCount: 1
DedicatedMasterEnabled: false
ZoneAwarenessEnabled: false
ElasticsearchVersion: 5.3
答案 1 :(得分:1)
要添加到Jens的答案中,您可能需要输出
您可以将其添加到您的serverless.yml
配置中
Outputs:
DomainArn:
Value: !GetAtt ElasticsearchDomain.DomainArn
DomainEndpoint:
Value: !GetAtt ElasticsearchDomain.DomainEndpoint
SecurityGroupId:
Value: !Ref mySecurityGroup
SubnetId:
Value: !Ref subnet