Skip to content

Instantly share code, notes, and snippets.

@wp-davisona
Created March 14, 2016 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wp-davisona/20562a3fb898babb93cc to your computer and use it in GitHub Desktop.
Save wp-davisona/20562a3fb898babb93cc to your computer and use it in GitHub Desktop.
# Converted from Elasticsearch template Example located at:
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html
from troposphere import Template, If, Ref, Not, Equals, Parameter
from troposphere.elasticsearch import ElasticsearchDomain, \
ElasticsearchClusterConfig, EBSOptions, SnapshotOptions
def main():
template = Template()
template.add_version("2010-09-09")
template.add_description(
"AWS CloudFormation Sample ElasticSearch Template")
par_iops = Parameter(
'IOPS',
Type='Number',
Description='Dedicated IOPS for the volumes',
Default='0'
)
template.add_parameter(par_iops)
template.add_condition(
'con_iops', Not(Equals(Ref(par_iops), "0"))
)
template.add_resource(
ElasticsearchDomain(
"ElasticsearchDomain",
ElasticsearchClusterConfig=ElasticsearchClusterConfig(
"ElasticsearchClusterConfig",
DedicatedMasterEnabled=True,
InstanceCount=2,
ZoneAwarenessEnabled=True,
InstanceType="m3.medium.elasticsearch",
DedicatedMasterType="m3.medium.elasticsearch",
DedicatedMasterCount=3
),
DomainName="exampledomain",
EBSOptions=EBSOptions(
"EBSOptions",
EBSEnabled=True,
Iops=If('con_iops', Ref(par_iops), Ref("AWS::NoValue")),
VolumeSize=20,
VolumeType=If('con_iops', 'io1', 'gp2')
),
SnapshotOptions=SnapshotOptions(
"SnapshotOptions",
AutomatedSnapshotStartHour=0
),
AccessPolicies={
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "es:*",
"Resource": "*"
}]
},
AdvancedOptions={"rest.action.multi.allow_explicit_index": "true"}
)
)
print(template.to_json())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment