Exemple #1
0
 def elasticsearch_cluster(self, name, ebs=True, voltype='gp2'):
     es_domain = self.template.add_resource(
         Domain(
             name,
             DomainName=name + 'domain',
             ElasticsearchClusterConfig=ElasticsearchClusterConfig(
                 DedicatedMasterEnabled=True,
                 InstanceCount=2,
                 ZoneAwarenessEnabled=True,
                 InstanceType=constants.ELASTICSEARCH_M3_MEDIUM,
                 DedicatedMasterType=constants.ELASTICSEARCH_M3_MEDIUM,
                 DedicatedMasterCount=3),
             EBSOptions=EBSOptions(EBSEnabled=ebs,
                                   Iops=0,
                                   VolumeSize=20,
                                   VolumeType=voltype),
             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"
             }))
     return es_domain
 def create_es_domain(self, ):
     t = self.template
     self.es_domain = t.add_resource(
         Domain(
             'ElasticsearchDomain',
             DomainName="jd-estest-domain-two",
             ElasticsearchClusterConfig=ElasticsearchClusterConfig(
                 DedicatedMasterEnabled=False,
                 InstanceCount=1,
                 ZoneAwarenessEnabled=False,
                 InstanceType=constants.ELASTICSEARCH_T2_SMALL),
             EBSOptions=EBSOptions(EBSEnabled=True,
                                   Iops=0,
                                   VolumeSize=10,
                                   VolumeType="gp2"),
             ElasticsearchVersion="6.2",
             SnapshotOptions=SnapshotOptions(AutomatedSnapshotStartHour=0),
             AccessPolicies={
                 'Version':
                 '2012-10-17',
                 'Statement': [{
                     'Effect': 'Allow',
                     'Principal': {
                         'AWS': '*'
                     },
                     'Action': 'es:*',
                     'Resource': '*'
                 }]
             }))
     t.add_output(
         Output("ElasticSearchDomainName",
                Value=Ref(self.es_domain),
                Description="Name of ES domain for cluster"))
Exemple #3
0
from troposphere.elasticsearch import Domain, EBSOptions, VPCOptions
from troposphere.elasticsearch import ElasticsearchClusterConfig
from troposphere.elasticsearch import SnapshotOptions


templ = Template()

templ.set_description('Elasticsearch Domain example')

es_domain = templ.add_resource(Domain(
    'ElasticsearchDomain',
    DomainName="ExampleElasticsearchDomain",
    ElasticsearchClusterConfig=ElasticsearchClusterConfig(
        DedicatedMasterEnabled=True,
        InstanceCount=2,
        ZoneAwarenessEnabled=True,
        InstanceType=constants.ELASTICSEARCH_M3_MEDIUM,
        DedicatedMasterType=constants.ELASTICSEARCH_M3_MEDIUM,
        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:*',
Exemple #4
0
))

t.add_parameter(Parameter(
    "VolumeSize",
    Default="10",
    Type="String",
    Description="Size in Gib of the EBS volumes",
))

t.add_resource(Domain(
    'ElasticsearchCluster',
    DomainName="logs",
    ElasticsearchVersion="5.3",
    ElasticsearchClusterConfig=ElasticsearchClusterConfig(
        DedicatedMasterEnabled=False,
        InstanceCount=Ref("InstanceCount"),
        ZoneAwarenessEnabled=False,
        InstanceType=Ref("InstanceType")
    ),
    AdvancedOptions={
        "indices.fielddata.cache.size": "",
        "rest.action.multi.allow_explicit_index": "true"
    },
    EBSOptions=EBSOptions(EBSEnabled=True,
                          Iops=0,
                          VolumeSize=Ref("VolumeSize"),
                          VolumeType="gp2"),
    AccessPolicies={
        'Version': '2012-10-17',
        'Statement': [
            {
                'Effect': 'Allow',
Exemple #5
0
es_domain = template.add_resource(
    Domain(
        "ElasticsearchDomain",
        AccessPolicies=Policy(Statement=[
            Statement(
                Effect=Allow,
                Action=[Action("es", "*")],
                Principal=Principal("AWS", [GetAtt(instance_role, "Arn")]),
            ),
        ]),
        Condition=es_condition,
        EBSOptions=EBSOptions(
            EBSEnabled=True,
            VolumeSize=Ref(es_volume_size),
        ),
        ElasticsearchClusterConfig=ElasticsearchClusterConfig(
            InstanceType=Ref(es_instance_type), ),
        ElasticsearchVersion=Ref(es_version),
    ))

# Output Elasticsearch domain endpoint and ARN
template.add_output(
    Output(
        "ElasticsearchDomainEndpoint",
        Description="Elasticsearch domain endpoint",
        Value=GetAtt(es_domain, "DomainEndpoint"),
        Condition=es_condition,
    ))

template.add_output(
    Output(
        "ElasticsearchDomainArn",
Exemple #6
0
            #     IpAddress({
            #         'aws:SourceIp': '...../24'
            #     }),
            # )
        ),
    ]
)

elasticsearch_domain = template.add_resource(
    Domain('ElasticsearchDomain',
           DomainName='nicor88-es-dev',
           AccessPolicies=access_policy,
           ElasticsearchVersion='5.3',
           ElasticsearchClusterConfig=ElasticsearchClusterConfig(
               InstanceCount=1,
               InstanceType='t2.small.elasticsearch',
               ZoneAwarenessEnabled=False,
           ),
           EBSOptions=EBSOptions(EBSEnabled=True,
                                 VolumeSize='10',
                                 VolumeType='gp2',  # General Purpose SSD
                                 Iops=0
                                 ),
           SnapshotOptions=SnapshotOptions(AutomatedSnapshotStartHour=0),
           AdvancedOptions={
               'rest.action.multi.allow_explicit_index': 'true'
           }
           )
)

# Outputs
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': '*'