コード例 #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
コード例 #2
0
 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"))
コード例 #3
0
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:*',
                        'Resource': '*'
                    }]},
    AdvancedOptions={"rest.action.multi.allow_explicit_index": True},
    VPCOptions=VPCOptions(
       SubnetIds=["subnet-4f2bb123"],
       SecurityGroupIds=["sg-04cf048c"]
コード例 #4
0
                       Not(Equals(Ref(es_instance_type), dont_create_value)))

# Create an Elasticsearch domain
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,
    ))
コード例 #5
0
    ]
)

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
template.add_output([
    Output('ElasticsearchDomain',
           Description='Elasticsearch Domain',
           Value=Ref(elasticsearch_domain)),