zalando-stups / senza

Deploy immutable application stacks and create and execute AWS CloudFormation templates in a sane way
https://pypi.python.org/pypi/stups-senza
Other
96 stars 72 forks source link

Allow to specify Redis cluster name when using RedisNode component #493

Open inikolaev opened 6 years ago

inikolaev commented 6 years ago

Right now when using RedisNode component to create Redis instance cluster name is set to the name of the resource section where component is declared:

SenzaComponents:
  - Configuration:
      Type: Senza::StupsAutoConfiguration
  - Redis:
      Type: Senza::RedisNode
      CacheNodeType: "{{Arguments.InstanceType}}"
      CacheParameterGroupName: "{{Arguments.RedisParameterGroupName}}"
      EngineVersion: "{{Arguments.RedisVersion}}"
      SecurityGroups:
        - Fn::GetAtt: ["RedisSecurityGroup", GroupId]

The above definition will create a cluster named redis.

While it's possible to use mustache templates to name a section I don't particulary like that approach as it hurts readability in my opinion.

I would like to propose to support ClusterName attribute which would allow to set cluster name, For compatibility it will fallback to using section name. After that change the template will look like this:

SenzaComponents:
  - Configuration:
      Type: Senza::StupsAutoConfiguration
  - Redis:
      Type: Senza::RedisNode
      CacheNodeType: "{{Arguments.InstanceType}}"
      CacheParameterGroupName: "{{Arguments.RedisParameterGroupName}}"
      ClusterName: "{{Arguments.Environment}}-redis-{{Arguments.ClusterName}}"
      EngineVersion: "{{Arguments.RedisVersion}}"
      SecurityGroups:
        - Fn::GetAtt: ["RedisSecurityGroup", GroupId]

I will provide a PR for this ticket shortly.