Пример #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"))
Пример #3
0
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
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',
                'Principal': {
                    'AWS': [Ref('AWS::AccountId')]
                },
                'Action': 'es:*',
                'Resource': '*',
            },
            {
                'Effect': 'Allow',
                'Principal': {
                    'AWS': "*"
                },
                'Action': 'es:*',
                'Resource': '*',
                'Condition': {
                    'IpAddress': {
                        'aws:SourceIp': PublicCidrIp
                    }
                }

            }
        ]
    },
))
Пример #5
0
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"]
        ),
    )
)
Пример #6
0
es_condition = "Elasticsearch"
template.add_condition(es_condition,
                       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"),
Пример #7
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',
Пример #8
0
Файл: es.py Проект: russest3/dev
 Domain(
     'ElasticsearchCluster',
     DomainName="dev-logs",
     ElasticsearchVersion="6.0",
     ElasticsearchClusterConfig=ElasticsearchClusterConfig(
         DedicatedMasterEnabled=False,
         InstanceCount=Ref("InstanceCount"),
         ZoneAwarenessEnabled=False,
         InstanceType=Ref("InstanceType"),
     ),
     AdvancedOptions={
         "indices.fielddata.cache.size": "",
         "rest.action.multi.allow_explicit_index": "true",
     },
     VPCOptions=VPCOptions(
         SubnetIds=["subnet-e8d7f68c"],
         SecurityGroupIds=[Ref("SecurityGroup")],
     ),
     EBSOptions=EBSOptions(EBSEnabled=True,
                           Iops=0,
                           VolumeSize=Ref("VolumeSize"),
                           VolumeType="gp2"),
     AccessPolicies={
         'Version':
         '2012-10-17',
         'Statement': [{
             'Effect': 'Allow',
             'Principal': {
                 'AWS': [Ref('AWS::AccountId')]
             },
             'Action': 'es:*',
             'Resource': '*',
         }, {
             'Effect': 'Allow',
             'Principal': {
                 'AWS': "*"
             },
             'Action': 'es:*',
             'Resource': '*',
             'Condition': {
                 'IpAddress': {
                     'aws:SourceIp': "10.10.0.0/16"
                 }
             }
         }]
     },
 ))