-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Improvement] state/elasticsearch: add option to spread nodes in 3-AZs #524
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ Metadata: | |
- ElasticsearchVersion | ||
- EBSEnabled | ||
- EBSVolumeSize | ||
- AvailabilityZones | ||
- ClusterInstanceCount | ||
- ClusterInstanceType | ||
- DedicatedMasterCount | ||
|
@@ -78,8 +79,13 @@ Parameters: | |
Type: String | ||
Default: '5.5' | ||
AllowedValues: ['7.7', '7.4', '7.1', '6.8', '6.7', '6.5', '6.4', '6.3', '6.2', '6.0', '5.6', '5.5'] # aws es list-elasticsearch-versions --query "ElasticsearchVersions[]" | ||
AvailabilityZones: | ||
Description: 'Number of Availability Zones nodes are spread across.' | ||
Type: String | ||
Default: '2-AZ' | ||
AllowedValues: ['1-AZ', '2-AZ', '3-AZ'] | ||
ClusterInstanceCount: | ||
Description: 'The number of data nodes (instances) to use in the Amazon ES domain.' | ||
Description: 'The number of data nodes (instances) to use in the Amazon ES domain. If the defaul value of 1 is used, then automatically 1 node per Availability Zones is used. Therefore if 3-AZ is selected the value 1 and 3 produces the same result and 2 is not supported.' | ||
Type: Number | ||
Default: 1 | ||
ClusterInstanceType: | ||
|
@@ -103,10 +109,12 @@ Conditions: | |
HasZone: !Not [!Equals [!Ref ParentZoneStack, '']] | ||
HasSSHBastionSecurityGroup: !Not [!Equals [!Ref ParentSSHBastionStack, '']] | ||
HasAlertTopic: !Not [!Equals [!Ref ParentAlertStack, '']] | ||
HasSingleClusterInstance: !Equals [!Ref ClusterInstanceCount, '1'] | ||
HasDedicatedMasterNodes: !Not [!Equals [!Ref DedicatedMasterCount, 0]] | ||
HasEBSEnabled: !Equals [!Ref EBSEnabled, 'true'] | ||
HasAlertTopicAndNotSingleClusterInstance: !And [!Condition HasAlertTopic, !Not [!Condition HasSingleClusterInstance]] | ||
HasZoneAwareness: !Not [!Equals [!Ref AvailabilityZones, '1-AZ']] | ||
HasAlertTopicAndZoneAwareness: !And [!Condition HasAlertTopic, !Condition HasZoneAwareness] | ||
Has3AvailabilityZones: !Equals [!Ref AvailabilityZones, '3-AZ'] | ||
HasCustomClusterInstanceCount: !Not [!Equals [!Ref ClusterInstanceCount, 1]] | ||
Resources: | ||
RecordSet: | ||
Condition: HasZone | ||
|
@@ -163,25 +171,37 @@ Resources: | |
DedicatedMasterCount: !If [HasDedicatedMasterNodes, !Ref DedicatedMasterCount, !Ref 'AWS::NoValue'] | ||
DedicatedMasterEnabled: !If [HasDedicatedMasterNodes, true, false] | ||
DedicatedMasterType: !If [HasDedicatedMasterNodes, !Ref DedicatedMasterType, !Ref 'AWS::NoValue'] | ||
InstanceCount: !Ref ClusterInstanceCount | ||
InstanceCount: !If | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you decide to do it like that? Why not just use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always try to automatically set the correct values for dependent values and the count of instances must be at least the number of availability zones. I contemplated setting the default value to 0 and only then use the number of availability zones as instance count. But I was not sure if this will cause an issue if someone updates the template and is not aware, that the default value has changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should add one parameter If InstanceCount = 1: we ignore AvailabilityZoneCount and use subnet A. Would that make sense? |
||
- HasCustomClusterInstanceCount | ||
- !Ref ClusterInstanceCount | ||
- !Select ['0', {'Fn::Split': ['-', !Ref AvailabilityZones]}] | ||
InstanceType: !Ref ClusterInstanceType | ||
ZoneAwarenessEnabled: !If [HasSingleClusterInstance, false, true] | ||
ZoneAwarenessEnabled: !If [HasZoneAwareness, true, false] | ||
ZoneAwarenessConfig: !If | ||
- HasZoneAwareness | ||
- AvailabilityZoneCount: !Select ['0', {'Fn::Split': ['-', !Ref AvailabilityZones]}] | ||
- !Ref 'AWS::NoValue' | ||
ElasticsearchVersion: !Ref ElasticsearchVersion | ||
EncryptionAtRestOptions: !If [HasKmsKey, {Enabled: true, KmsKeyId: {'Fn::ImportValue': !Sub '${ParentKmsKeyStack}-KeyId'}}, !Ref 'AWS::NoValue'] | ||
SnapshotOptions: | ||
AutomatedSnapshotStartHour: 10 | ||
VPCOptions: | ||
SecurityGroupIds: | ||
- !Ref SecurityGroup | ||
SubnetIds: !If | ||
- HasSingleClusterInstance | ||
- - {'Fn::ImportValue': !Sub '${ParentVPCStack}-SubnetAPrivate'} | ||
- - {'Fn::ImportValue': !Sub '${ParentVPCStack}-SubnetAPrivate'} | ||
SubnetIds: | ||
- {'Fn::ImportValue': !Sub '${ParentVPCStack}-SubnetAPrivate'} | ||
- !If | ||
- HasZoneAwareness | ||
- {'Fn::ImportValue': !Sub '${ParentVPCStack}-SubnetBPrivate'} | ||
- !Ref 'AWS::NoValue' | ||
- !If | ||
- Has3AvailabilityZones | ||
- {'Fn::ImportValue': !Sub '${ParentVPCStack}-SubnetCPrivate'} | ||
- !Ref 'AWS::NoValue' | ||
UpdatePolicy: | ||
EnableVersionUpgrade: true | ||
ClusterStatusYellowAlarm: | ||
Condition: HasAlertTopicAndNotSingleClusterInstance | ||
Condition: HasAlertTopicAndZoneAwareness | ||
Type: 'AWS::CloudWatch::Alarm' | ||
Properties: | ||
AlarmActions: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit of using a
String
instead of aNumber
type?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can find the configuration value faster in the list of parameters, because it looks differently visually. I do not know anymore why I choose a string instead of a number, because the change was made months ago. It could be that I wanted to create a similarity to the 2azs and 3azs vpc templates.