Created
July 13, 2017 14:42
-
-
Save b-meson/d9c2118240eb03839c4a0fd99ad73bd8 to your computer and use it in GitHub Desktop.
push ES Config's JSON to ES using requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Access Keys from ~/.aws/credentials | |
aws_access_key_id = 'SOMEKEY' | |
aws_secret_access_key = 'SECRETKEYVALUE' | |
aws_session_token = 'ANOTHER KEY FROM STS' | |
import requests | |
import requests_aws4auth | |
from requests_aws4auth import AWS4Auth | |
auth = AWS4Auth(aws_access_key_id,aws_secret_access_key,'region', 'es', session_token=aws_session_token) | |
endpoint = "https://clouddomain.region.es.amazonaws.com/_template/template_1" | |
payload = open('template.json','rb').read() | |
response = requests.post(endpoint, auth=auth, data=payload ) | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the below code is less fragile and fixes the endpoint issue