Create Index in OpenSearch AWS from Lambda failing

Getting Started with Microservices on AWS Lambda | by Michael ZaczekSource: Getting Started with Microservices on AWS Lambda | by Michael Zaczek from medium.com

lambda microservices creating

one person any information that one demand to scale successful my fresh opensearch case. one havent labored with opensearch earlier truthful person been pursuing the tutorials connected the aws tract, however one'm getting entree points once creating the indices.

present's what one've achieved, created a area with properties arsenic beneath

area instauration technique - casual make interpretation - OpenSearch 2.9 web - PublicAccess good-grained - make maestro person (added username/pwd)

That's it

one've created the lambda relation by pursuing the tutorial present

Tutorial nexus From AWS

however instaed of populating information from dynamo, one person a database of information that one demand to participate.

one've created python lambda codification, added beneath insurance policies, successful summation to the lambda basal execution

AmazonESFullAccess AmazonOpenSearchServiceFullAccess

My codification appears similar beneath

import boto3
import re
import requests
from requests_aws4auth import AWS4Auth
from data_to_index import bulk_data_to_index

part = 'ap-southbound-1' # e.g. america-westbound-1
work = 'es'
credentials = boto3.conference().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, part, work, session_token=credentials.token)

adult = 'my_domain' # the OpenSearch work area, e.g. https://hunt-mydomain.america-westbound-1.es.amazonaws.com
scale = 'my_index'
datatype = '_doc'
url = adult + '/' + scale + '/' + datatype

headers =  "contented-kind": "exertion/json" 

# Lambda execution begins present
def lambda_handler(case, discourse):
    for information successful bulk_data_to_index:
        papers = 
            "key1": information[1],
            "key2": information[2],
            "information": ', '.articulation(information)
        
        r = requests.station(url, auth=awsauth, json=papers, headers=headers)

        # mark consequence contented and position codification
        mark("consequence contented:", r.contented)
        mark("position codification:", r.status_code)

        # cheque if the petition was palmy
        if r.status_code == 201:
            mark("papers added efficiently to OpenSearch!")
        other:
            mark("Failed to adhd papers to OpenSearch. position codification:", r.status_code)
            mark("mistake consequence:", r.matter)

once moving this, one americium getting mistake

consequence contented: b'"mistake":"root_cause":["kind":"security_exception","ground":"nary permissions for [indices:information/compose/scale] and person [sanction=my_lambda_role, backend_roles=[my_lambda_role], requestedTenant=null]"],"kind":"security_exception","ground":"nary permissions for [indices:information/compose/scale] and person [sanction=my_lambda_role, backend_roles=[my_lambda_role], requestedTenant=null]","position":403'

one tin not fig retired, wherefore does the FullAccessToOpenSearch work not springiness maine each the accesses one demand. person spent rather a fewer hours figuring this, truthful volition acknowledge immoderate aid one tin acquire present

overmuch acknowledgment

Artículo Anterior Artículo Siguiente

Formulario de contacto