Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElasticsearchHttpPostPolicy set but still receiving "not authorized to perform: es:ESHttpPost" #429

Closed
villasv opened this issue May 10, 2018 · 3 comments

Comments

@villasv
Copy link
Contributor

villasv commented May 10, 2018

Description:

I have a Lambda Function that I want to use to query an Amazon Elasticsearch Domain, but even after setting ElasticsearchHttpPostPolicy, using search will yield "{\"Message\":\"User: anonymous is not authorized to perform: es:ESHttpPost\"}" }

  Function:
    Type: AWS::Serverless::Function
    Properties:
      Policies:
        - ElasticsearchHttpPostPolicy:
            DomainName: my-domain

  Search:
    Type: AWS::Elasticsearch::Domain
    Properties:
      DomainName: my-domain
      ElasticsearchVersion: 6.2
      ElasticsearchClusterConfig:
        InstanceCount: 1
        InstanceType: t2.small.elasticsearch
      EBSOptions:
        EBSEnabled: true
        Iops: 0
        VolumeSize: 10
        VolumeType: standard
@villasv
Copy link
Contributor Author

villasv commented May 10, 2018

I understand that this error message is usually associated with not signing the request, but intuitively ElasticsearchHttpPostPolicy was useful because I don't need to deal with credentials. Is that interpretation wrong? I wouldn't be surprised, because I guess that just sending a POST from the lambda won't send any policy or iam information by default.

But even after trying to sign the request, I get:

"{\"Message\":\"User: arn:aws:sts::XXXXXX:assumed-role/my-stack-FunctionRole-QUYMLS5WBXY1/my-function is not authorized to perform: es:ESHttpPost\"}"

@villasv villasv changed the title ElasticsearchHttpPostPolicy set but still receiving "User: anonymous is not authorized to perform: es:ESHttpPost" ElasticsearchHttpPostPolicy set but still receiving "not authorized to perform: es:ESHttpPost" May 10, 2018
@villasv
Copy link
Contributor Author

villasv commented May 10, 2018

Hmmm. After further investigation, this is the ARN generated by the managed policy:

arn:${AWS::Partition}:es:${AWS::Region}:${AWS::AccountId}:domain/${domainName}

But this is the ARN used elsewhere:

arn:${AWS::Partition}:es:${AWS::Region}:${AWS::AccountId}:domain/${domainName}/*

After swaping out the managed SAM policy for a standard IAM policy with that ARN, it started working.
Another option is to keep using the managed ElasticsearchHttpPostPolicy policy but set domainName to your-domain-name/*.

@shakirjames
Copy link
Contributor

I had the same issue: #858

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants