2
votes

Hello I need some help with sending a PUT request to my ElasticSearch on AWS to create a snapshot in a S3 bucket, with POSTMAN.

I have created a S3 bucket called cb-search-es-backup. I've created a role, and a policy for S3 (see:this post of mine for the steps I've taken).

REQUEST URL https://myelasticsearchendpoint.eu-west-1.es.amazonaws.com/

REQUEST METHOD: PUT

BODY : RAW / json

{
 "type": "s3",
    "settings": {
        "bucket": "cb-search-es-backup",  // my bucketname
        "region": "eu-west-1", // region
        "role_arn": "arn:aws:iam::12345676890:role/Role_ES_TO_S3" // my role arn
   }
 }

enter image description here

I've also tried the authorization type: 'AWS Signature', with access and secret key filled in.

1
Added an answer, looks like the problem in your other question is the same - not passing the credentials. - Nikolay Vasiliev

1 Answers

4
votes

It looks like you are not passing AWS credentials with this request.

There is a detailed guide how to make a Postman request with AWS authentication here: Use Postman to Call an API.

Your Postman window might look like this:

AWS Postman auth

To do the same from python please check out Sample python client section of this documentation page, note that AWS4Auth object is created and it's passed as auth parameter to requests.put():

credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)

# Register repository

path = '_snapshot/my-snapshot-repo' # the Elasticsearch API endpoint
url = host + path

payload = {
  ...
}

headers = {"Content-Type": "application/json"}

r = requests.put(url, auth=awsauth, json=payload, headers=headers)

Hope that helps!