Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit cee29cf

Browse files
author
Christopher Hein
authored
Merge pull request #149 from trulia/feature/adding_ec
Adding elasticache
2 parents 0afe49c + adb3be8 commit cee29cf

File tree

31 files changed

+1950
-24
lines changed

31 files changed

+1950
-24
lines changed

cloudformation/elasticache.yaml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Description: 'AWS Operator - Amazon Elasticache Cluster'
3+
Parameters:
4+
Namespace:
5+
Description: >-
6+
This is the namespace for the Kubernetes object.
7+
Type: String
8+
ResourceVersion:
9+
Type: String
10+
Description: >-
11+
This is the resource version for the Kubernetes object.
12+
ResourceName:
13+
Description: >-
14+
This is the resource name for the Kubernetes object
15+
Type: String
16+
AutoMinorVersionUpgrade:
17+
Description: >-
18+
Indicates that minor engine upgrades will be applied automatically to the cache cluster during the maintenance window.
19+
Type: String
20+
Default: false
21+
AZMode:
22+
Description: >-
23+
For Memcached cache clusters, indicates whether the nodes are created in a single Availability Zone or across multiple Availability Zones in the cluster's region.
24+
Type: String
25+
CacheNodeType:
26+
Description: >-
27+
The compute and memory capacity of nodes in a cache cluster.
28+
https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/CacheNodes.SupportedTypes.html
29+
Type: String
30+
Default: cache.m5.large
31+
CacheParameterGroupName:
32+
Description: >-
33+
The name of the cache parameter group that is associated with this cache cluster.
34+
Type: String
35+
CacheSubnetGroupName:
36+
Description: >-
37+
The cache subnet group that you associate with a cache cluster.
38+
"Required: Conditional. If you specified the VpcSecurityGroupIds property, you must specify this property."
39+
Type: String
40+
ClusterName:
41+
Description: >-
42+
This is the cluster name for the operator
43+
Type: String
44+
Engine:
45+
Description: >-
46+
The name of the cache engine to be used for this cache cluster, such as memcached or redis.
47+
Type: String
48+
Default: "redis"
49+
EngineVersion:
50+
Description: >-
51+
The version of the cache engine to be used for this cluster.
52+
Type: String
53+
Default: "5.0.0"
54+
NotificationTopicArn:
55+
Description: >-
56+
The Amazon Resource Name (ARN) of the Amazon Simple Notification Service (SNS) topic to which notifications will be sent.
57+
Type: String
58+
NumCacheNodes:
59+
Description: >-
60+
The number of cache nodes that the cache cluster should have.
61+
Type: Number
62+
Default: "1"
63+
Port:
64+
Description: >-
65+
The port number on which each of the cache nodes will accept connections.
66+
Type: Number
67+
PreferredMaintenanceWindow:
68+
Description: >-
69+
The weekly time range (in UTC) during which system maintenance can occur.
70+
Type: String
71+
Default: mon:05:00-mon:09:00
72+
PreferredAvailabilityZone:
73+
Description: >-
74+
The Amazon EC2 Availability Zone in which the cache cluster is created.
75+
Type: String
76+
PreferredAvailabilityZones:
77+
Description: >-
78+
For Memcached cache clusters, the list of Availability Zones in which cache nodes are created. The number of Availability Zones listed must equal the number of cache nodes. For example, if you want to create three nodes in two different Availability Zones, you can specify ["us-east-1a", "us-east-1a", "us-east-1b"], which would create two nodes in us-east-1a and one node in us-east-1b.
79+
Type: CommaDelimitedList
80+
SnapshotWindow:
81+
Description: >-
82+
For Redis cache clusters, the daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your node group. For example, you can specify 05:00-09:00.
83+
Type: String
84+
Default: "05:00-09:00"
85+
VpcSecurityGroupIds:
86+
Description: >-
87+
A list of VPC security group IDs. If your cache cluster isn't in a VPC, specify the CacheSecurityGroupNames property instead.
88+
Type: CommaDelimitedList
89+
Conditions:
90+
IsRedis:
91+
!Equals [!Ref Engine, "redis"]
92+
IsMemcached:
93+
!Equals [!Ref Engine, "memcached"]
94+
HasAZMode:
95+
!Not [!Equals [!Ref AZMode, ""]]
96+
HasPreferredAvailabilityZones:
97+
!Not [!Equals [!Select [0, !Ref PreferredAvailabilityZones], ""]]
98+
HasPreferredAvailabilityZone:
99+
!Not [!Equals [!Ref PreferredAvailabilityZone, ""]]
100+
HasVpcSecurityGroupIds:
101+
!Not [!Equals [!Select [0, !Ref VpcSecurityGroupIds], ""]]
102+
Resources:
103+
ElastiCacheCluster:
104+
Type: AWS::ElastiCache::CacheCluster
105+
Properties:
106+
AutoMinorVersionUpgrade: !Ref AutoMinorVersionUpgrade
107+
AZMode:
108+
!If [HasAZMode, !Ref AZMode, !Ref "AWS::NoValue"]
109+
CacheNodeType: !Ref CacheNodeType
110+
CacheParameterGroupName: !Ref CacheParameterGroupName
111+
CacheSubnetGroupName: !Ref CacheSubnetGroupName
112+
ClusterName: !Ref ClusterName
113+
Engine: !Ref Engine
114+
EngineVersion: !Ref EngineVersion
115+
NumCacheNodes: !Ref NumCacheNodes
116+
Port: !Ref Port
117+
PreferredAvailabilityZone:
118+
!If [HasPreferredAvailabilityZone, !Ref PreferredAvailabilityZone, !Ref "AWS::NoValue"]
119+
PreferredAvailabilityZones:
120+
!If [HasPreferredAvailabilityZones, !Ref PreferredAvailabilityZones, !Ref "AWS::NoValue"]
121+
PreferredMaintenanceWindow: !Ref PreferredMaintenanceWindow
122+
SnapshotWindow: !Ref SnapshotWindow
123+
Tags:
124+
- Key: Namespace
125+
Value: !Ref Namespace
126+
- Key: ResourceVersion
127+
Value: !Ref ResourceVersion
128+
- Key: ResourceName
129+
Value: !Ref ResourceName
130+
- Key: ClusterName
131+
Value: !Ref ClusterName
132+
- Key: Heritage
133+
Value: operator.aws
134+
VpcSecurityGroupIds:
135+
!If [HasVpcSecurityGroupIds, !Ref VpcSecurityGroupIds, !Ref "AWS::NoValue"]
136+
Outputs:
137+
RedisEndpointAddress:
138+
Value: !GetAtt
139+
- ElastiCacheCluster
140+
- RedisEndpoint.Address
141+
Condition: IsRedis
142+
Description: The DNS address of the configuration endpoint for the Redis cache cluster.
143+
RedisEndpointPort:
144+
Value: !GetAtt
145+
- ElastiCacheCluster
146+
- RedisEndpoint.Port
147+
Condition: IsRedis
148+
Description: The port number of the configuration endpoint for the Redis cache cluster.
149+
ConfigurationEndpointAddress:
150+
Value: !GetAtt
151+
- ElastiCacheCluster
152+
- ConfigurationEndpoint.Address
153+
Condition: IsMemcached
154+
Description: The DNS address of the configuration endpoint for the Memcached cache cluster.
155+
ConfigurationEndpointPort:
156+
Value: !GetAtt
157+
- ElastiCacheCluster
158+
- ConfigurationEndpoint.Port
159+
Condition: IsMemcached
160+
Description: The port number of the configuration endpoint for the Memcached cache cluster.

cmd/aws-service-operator/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func init() {
5050
rootCmd.PersistentFlags().StringVarP(&awsRegion, "region", "r", "us-west-2", "AWS Region for resources to be created in")
5151
rootCmd.PersistentFlags().StringVarP(&logLevel, "loglevel", "l", "Info", "Log level for the CLI")
5252
rootCmd.PersistentFlags().StringVarP(&logFile, "logfile", "", "", "Log file for the CLI")
53-
rootCmd.PersistentFlags().StringVarP(&resources, "resources", "", "cloudformationtemplate,dynamodb,ecrrepository,s3bucket,snssubscription,snstopic,sqsqueue", "Comma delimited list of CRDs to deploy")
53+
rootCmd.PersistentFlags().StringVarP(&resources, "resources", "", "cloudformationtemplate,dynamodb,ecrrepository,elasticache,s3bucket,snssubscription,snstopic,sqsqueue", "Comma delimited list of CRDs to deploy")
5454
rootCmd.PersistentFlags().StringVarP(&clusterName, "cluster-name", "i", "aws-operator", "Cluster name for the Application to run as, used to label the Cloudformation templated to avoid conflict")
5555
rootCmd.PersistentFlags().StringVarP(&bucket, "bucket", "b", "aws-operator", "To configure the operator you need a base bucket to contain the resources")
5656
rootCmd.PersistentFlags().StringVarP(&accountID, "account-id", "a", "", "AWS Account ID, this is used to configure outputs and operate on the proper account.")

code-generation/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ install-bindata:
1616
.PHONY: update-bindata
1717
update-bindata:
1818
go generate ./pkg/codegen/
19+
go fmt ./...
1920

2021
.PHONY: rebuild
2122
rebuild: update-bindata build

code-generation/pkg/codegen/assets/operator.go.templ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func syncAdditionalResources(config config.Config, s *awsV1alpha1.{{.Spec.Kind}}
294294
{{ if .Spec.AdditionalResources.Services }}services := []string{}{{end}}
295295
{{- range $resource := .Spec.AdditionalResources.Services }}
296296
{{- if eq $resource.Type "ExternalName"}}
297-
{{$resource.Name}} := helpers.CreateExternalNameService(config, s, s.Name, s.Namespace, "{{$resource.ExternalName}}", {{(index $resource.Ports 0).Port}})
297+
{{$resource.Name}} := helpers.CreateExternalNameService(config, s, s.Name, s.Namespace, "{{$resource.ExternalName}}", "{{(index $resource.Ports 0).Port}}")
298298
services = append(services, {{$resource.Name}})
299299
{{- end}}
300300
{{- end}}

code-generation/pkg/codegen/codegen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func createFile(rootPath string, fileName string, templateName string, path stri
196196
if templateName[len(templateName)-3:] == ".go" {
197197
formatted, err = format.Source(bf.Bytes())
198198
if err != nil {
199-
log.Fatalf("Error formatting resolved template: %+v", err)
199+
log.Fatalf("Error formatting resolved template %s: %+v", templateName, err)
200200
}
201201
}
202202

0 commit comments

Comments
 (0)