# ElasticSearch DomainEndpoint from a resource file

**URL:** <https://forum.serverless.com/t/elasticsearch-domainendpoint-from-a-resource-file/6300>\
**Category:** Serverless Framework\
**Created:** [October 30, 2018, 2:59am UTC](https://forum.serverless.com/t/elasticsearch-domainendpoint-from-a-resource-file/6300 "2018-10-30T02:59:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidroman0O](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@davidroman0O](https://forum.serverless.com/u/davidroman0O)\
**Post date:** [October 30, 2018, 2:59am UTC](https://forum.serverless.com/t/elasticsearch-domainendpoint-from-a-resource-file/6300/1 "2018-10-30T02:59:03Z")

</div>

Hi everyone!

I’m posting because it drive my crazy!

I’ve already found this topic : [Can I access outputs from custom resources as variables in serverless.yml?](http://forum.serverless.com/t/can-i-access-outputs-from-custom-resources-as-variables-in-serverless-yml/508/8)

But, i couldn’t be able to have my endpoint on a single service project! ☹

Code before 1000 words !

My ./resources/es-instance.yml :

```auto
Resources:
  ElasticSearchLambdaServiceRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: ElasticSearchLambdaServiceRole
      AssumeRolePolicyDocument:
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action: sts:AssumeRole
      Policies:
        - PolicyName: ElasticSearchGeoLambdaServiceRolePolicy
          PolicyDocument:
            Version: "2012-10-17"
            Statement:
              # Public can query for information
              - Effect: Allow
                Principal: "*"
                Action:
                 - "es:ESHttpHead"
                 - "es:ESHttpGet"
                Resource: "arn:aws:es:${self:provider.region}:*:domain/${self:provider.environment.es_domain_name}/*"
              # Lambda can take actions on the ES domain
              - Effect: Allow
                Principal:
                  Service: lambda.amazonaws.com
                Action: sts:AssumeRole
              - Effect: Allow
                Action:
                  - logs:CreateLogGroup
                  - logs:CreateLogStream
                  - logs:PutLogEvents
                Resource:
                  - 'Fn::Join':
                      - ':'
                      -
                        - 'arn:aws:logs'
                        - Ref: 'AWS::Region'
                        - Ref: 'AWS::AccountId'
                        - 'log-group~:/aws/lambda/*:*:*'
              - Effect: "Allow"
                Action:
                  - "es:*"
                Resource:
                  - 'Fn::Join':
                      - ''
                      -
                        - 'arn:aws:es:'
                        - Ref: 'AWS::Region'
                        - ':'
                        - Ref: 'AWS::AccountId'
                        - ':domain/'
                        - "${self:provider.environment.es_domain_name}"
                        - '/*'
  ElasticSearchInstance:
    Type: AWS::Elasticsearch::Domain
    Properties:
      ElasticsearchVersion: 6.3
      DomainName: "${self:provider.environment.es_domain_name}"
      EBSOptions:
        EBSEnabled: true
        VolumeType: gp2
        VolumeSize: 10
      ElasticsearchClusterConfig:
        InstanceType: t2.small.elasticsearch
        InstanceCount: 1
        DedicatedMasterEnabled: false
        ZoneAwarenessEnabled: false

Outputs:
  ElasticSearchInstance:
    Value:
      Ref: ElasticSearchInstance
  ElasticSearchLambdaServiceRole:
    Value:
      Ref: ElasticSearchLambdaServiceRole
  DomainEndpoint:
      Value:
        Fn::GetAtt: [ElasticSearchInstance, DomainEndpoint]

```

An extract from my serverless.yml

```auto
provider:
  # ... some properties
  environment:
    # ... some properties
    es_endpoint_url: ${file(./resources/es-instance.yml):Outputs.DomainEndpoint.Value}

```

On the terminal, I got :  
`Serverless: Resolved environment variable es_endpoint_url: {"Fn::GetAtt":["ElasticSearchInstance","DomainEndpoint"]}`

So, why ? How can i access to the endpoint ? 🙂

I’ve tested a lot of things and nothing really worked 😕

Do I missed something ?

Note : I don’t want to use dynamodb-geo so i’m searching to use ES for geoqueries 😕

Thx a lot for the framework, i made a lot a great projects, hope someone will help me to figure it out 🙂
