Skip to content

Commit

Permalink
Example of Elasticsearch Domain creation
Browse files Browse the repository at this point in the history
  • Loading branch information
edubxb committed Mar 14, 2016
1 parent 94a3436 commit d7fcea3
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
42 changes: 42 additions & 0 deletions examples/ElasticsearchDomain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Converted from Elasticsearch Domain example located at:
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#d0e51519

from troposphere import Template
from troposphere.elasticsearch import ElasticsearchDomain, EBSOptions
from troposphere.elasticsearch import ElasticsearchClusterConfig
from troposphere.elasticsearch import SnapshotOptions


templ = Template()

templ.add_description('Elasticsearch Domain example')

es_domain = templ.add_resource(ElasticsearchDomain(
'ElasticsearchDomain',
DomainName="ExampleElasticsearchDomain",
ElasticsearchClusterConfig=ElasticsearchClusterConfig(
DedicatedMasterEnabled=True,
InstanceCount=2,
ZoneAwarenessEnabled=True,
InstanceType="m3.medium.elasticsearch",
DedicatedMasterType="m3.medium.elasticsearch",
DedicatedMasterCount=3
),
EBSOptions=EBSOptions(EBSEnabled=True,
Iops=0,
VolumeSize=20,
VolumeType="gp2"),
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(templ.to_json())
44 changes: 44 additions & 0 deletions tests/examples_output/ElasticsearchDomain.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"Description": "Elasticsearch Domain example",
"Resources": {
"ElasticsearchDomain": {
"Properties": {
"AccessPolicies": {
"Statement": [
{
"Action": "es:*",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Resource": "*"
}
],
"Version": "2012-10-17"
},
"AdvancedOptions": {
"rest.action.multi.allow_explicit_index": "true"
},
"DomainName": "ExampleElasticsearchDomain",
"EBSOptions": {
"EBSEnabled": "true",
"Iops": 0,
"VolumeSize": 20,
"VolumeType": "gp2"
},
"ElasticsearchClusterConfig": {
"DedicatedMasterCount": 3,
"DedicatedMasterEnabled": "true",
"DedicatedMasterType": "m3.medium.elasticsearch",
"InstanceCount": 2,
"InstanceType": "m3.medium.elasticsearch",
"ZoneAwarenessEnabled": "true"
},
"SnapshotOptions": {
"AutomatedSnapshotStartHour": 0
}
},
"Type": "AWS::Elasticsearch::Domain"
}
}
}

0 comments on commit d7fcea3

Please sign in to comment.