小编典典

如何在ElasticBeanstalk上安装和配置Redis

redis

如何在AWS ElasticBeanstalk上安装和配置Redis?有人知道如何编写.ebextension脚本来实现这一目标吗?


阅读 303

收藏
2020-06-20

共1个答案

小编典典

AWS Elastic
Beanstalk确实通过.ebextensions文件夹提供了资源配置。本质上,除了应用程序之外,您还需要告诉Elastic Beanstalk您还希望提供什么。用于置备到默认vpc。你需要

创建一个.ebextensions文件夹

添加一个elasticache.config文件

并包括以下内容。

Resources:
  MyCacheSecurityGroup:
    Type: "AWS::EC2::SecurityGroup"
    Properties:
      GroupDescription: "Lock cache down to webserver access only"
      SecurityGroupIngress :
        - IpProtocol : "tcp"
          FromPort :
            Fn::GetOptionSetting:
              OptionName : "CachePort"
              DefaultValue: "6379"
          ToPort :
            Fn::GetOptionSetting:
              OptionName : "CachePort"
              DefaultValue: "6379"
          SourceSecurityGroupName:
            Ref: "AWSEBSecurityGroup"
  MyElastiCache:
    Type: "AWS::ElastiCache::CacheCluster"
    Properties:
      CacheNodeType:
        Fn::GetOptionSetting:
          OptionName : "CacheNodeType"
          DefaultValue : "cache.t1.micro"
      NumCacheNodes:
        Fn::GetOptionSetting:
          OptionName : "NumCacheNodes"
          DefaultValue : "1"
      Engine:
        Fn::GetOptionSetting:
          OptionName : "Engine"
          DefaultValue : "redis"
      VpcSecurityGroupIds:
        -
          Fn::GetAtt:
            - MyCacheSecurityGroup
            - GroupId

Outputs:
  ElastiCache:
    Description : "ID of ElastiCache Cache Cluster with Redis Engine"
    Value :
      Ref : "MyElastiCache"

引用自:“如何向Elastic Beanstalk VPC添加ElasticCache资源”
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-environment-
resources-
elasticache.html

2020-06-20