'What is the purpose of using 'securitytenant' header in OpenSearch API?
def getAWSToken():
region = 'ap-south-1'
service = 'es'
sts_connection = boto3.client('sts',endpoint_url='https://sts.ap-south-1.amazonaws.com', region_name=region)
acct_b = sts_connection.assume_role(
RoleArn="arn:aws:iam::<account-number>:role/Role-Read-Tenant1-Data"
)
ACCESS_KEY = acct_b['Credentials']['AccessKeyId']
SECRET_KEY = acct_b['Credentials']['SecretAccessKey']
SESSION_TOKEN = acct_b['Credentials']['SessionToken']
awsauth = AWS4Auth(ACCESS_KEY, SECRET_KEY, region, service, session_token=SESSION_TOKEN)
return awsauth
def searchDataUsingSQL(indexName, tenantName):
url = "https://"+host+"/_plugins/_sql?format=json"
condition=''
payload = json.dumps({
"query": "select * from " + type.lower() + condition + ";"
})
headers = {
'Content-Type': 'application/json',
'securitytenant': tenantName
}
response = requests.request("POST", url, headers=headers, data=payload, auth=getAWSToken())
Can we leverage on 'securitytenant' header in searchUsingSQL() to select specific tenant's index using API?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
