@@ -215,6 +215,76 @@ Resources:
215215 created_at :
216216 type : integer
217217 paths :
218+ /search/articles :
219+ get :
220+ description : " 記事検索"
221+ parameters :
222+ - name : " query"
223+ in : " query"
224+ description : " 検索ワード"
225+ required : true
226+ type : " string"
227+ - name : " limit"
228+ in : " query"
229+ description : " 取得件数"
230+ required : false
231+ type : " integer"
232+ minimum : 1
233+ - name : " page"
234+ in : " query"
235+ description : " ページ"
236+ required : false
237+ type : " integer"
238+ responses :
239+ " 200 " :
240+ description : " 検索記事一覧"
241+ schema :
242+ type : array
243+ items :
244+ $ref : ' #/definitions/ArticleInfo'
245+ x-amazon-apigateway-integration :
246+ responses :
247+ default :
248+ statusCode : " 200"
249+ uri : !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ElasticSearchSearchArticles.Arn}/invocations
250+ passthroughBehavior : when_no_templates
251+ httpMethod : POST
252+ type : aws_proxy
253+ /search/users :
254+ get :
255+ description : " ユーザー検索"
256+ parameters :
257+ - name : " query"
258+ in : " query"
259+ description : " 検索ワード"
260+ required : true
261+ type : " string"
262+ - name : " limit"
263+ in : " query"
264+ description : " 取得件数"
265+ required : false
266+ type : " integer"
267+ minimum : 1
268+ - name : " page"
269+ in : " query"
270+ description : " ページ"
271+ required : false
272+ type : " integer"
273+ responses :
274+ " 200 " :
275+ description : " 検索ユーザー一覧"
276+ schema :
277+ type : array
278+ items :
279+ $ref : ' #/definitions/UserInfo'
280+ x-amazon-apigateway-integration :
281+ responses :
282+ default :
283+ statusCode : " 200"
284+ uri : !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ElasticSearchSearchUsers.Arn}/invocations
285+ passthroughBehavior : when_no_templates
286+ httpMethod : POST
287+ type : aws_proxy
218288 /articles/recent :
219289 get :
220290 description : " 最新記事一覧情報を取得"
@@ -1644,3 +1714,67 @@ Resources:
16441714 Path : /me/unread_notification_managers
16451715 Method : put
16461716 RestApiId : !Ref RestApi
1717+ ElasticSearchSearchArticles :
1718+ Type : AWS::Serverless::Function
1719+ Properties :
1720+ Handler : handler.lambda_handler
1721+ Role : !GetAtt LambdaRole.Arn
1722+ CodeUri : ./deploy/search_articles.zip
1723+ Environment :
1724+ Variables :
1725+ ELASTIC_SEARCH_ENDPOINT : !GetAtt ElasticSearchService.DomainEndpoint
1726+ Events :
1727+ Api :
1728+ Type : Api
1729+ Properties :
1730+ Path : /search/articles
1731+ Method : get
1732+ RestApiId : !Ref RestApi
1733+ ElasticSearchSearchUsers :
1734+ Type : AWS::Serverless::Function
1735+ Properties :
1736+ Handler : handler.lambda_handler
1737+ Role : !GetAtt LambdaRole.Arn
1738+ CodeUri : ./deploy/search_users.zip
1739+ Environment :
1740+ Variables :
1741+ ELASTIC_SEARCH_ENDPOINT : !GetAtt ElasticSearchService.DomainEndpoint
1742+ Events :
1743+ Api :
1744+ Type : Api
1745+ Properties :
1746+ Path : /search/users
1747+ Method : get
1748+ RestApiId : !Ref RestApi
1749+ ElasticSearchService :
1750+ Type : " AWS::Elasticsearch::Domain"
1751+ Properties :
1752+ AccessPolicies : !Join
1753+ - ' '
1754+ - - '{ "Version" : " 2012-10-17" , "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "'
1755+ - !GetAtt LambdaRole.Arn
1756+ - ' " }, "Action": "es:*", "Resource": "'
1757+ - ' arn:aws:es:'
1758+ - !Ref ' AWS::Region'
1759+ - ' :'
1760+ - !Ref ' AWS::AccountId'
1761+ - ' :domain/'
1762+ - !Ref " AWS::StackName"
1763+ - ' /*" } ] }'
1764+ AdvancedOptions :
1765+ rest.action.multi.allow_explicit_index : ' true'
1766+ DomainName : !Ref "AWS::StackName"
1767+ EBSOptions :
1768+ EBSEnabled : true
1769+ VolumeType : gp2
1770+ VolumeSize : 20
1771+ ElasticsearchClusterConfig :
1772+ InstanceType : m4.large.elasticsearch
1773+ InstanceCount : 1
1774+ DedicatedMasterEnabled : true
1775+ ZoneAwarenessEnabled : false
1776+ DedicatedMasterType : m4.large.elasticsearch
1777+ DedicatedMasterCount : 3
1778+ ElasticsearchVersion : ' 6.2'
1779+ SnapshotOptions :
1780+ AutomatedSnapshotStartHour : 0
0 commit comments