I created a aws firehose
stream with source input: direct put.
Where do i see the address now, i can send the data to. I can not find it.
You don't need an address or Endpoints. You need to make sure you have proper permission to put records in the firehose. You just need the name of the firehose along with the region where it resides and you are good to go.
Here is an example code:
import datetime
import json
import random
import boto3
STREAM_NAME = "<STREAM_NAME>"
REGION_NAME = "<REGION>"
def get_data():
"""Generate random data."""
return {
'EVENT_TIME': datetime.datetime.now().isoformat(),
'CITY': random.choice(['NYC', 'ITL', 'ABD', 'SRT', 'THI','HYD']),
'TICKER': random.choice(['AAPL', 'AMZN', 'MSFT', 'INTC', 'TBV']),
'PRICE': round(random.random() * 100, 2)
}
def generate(stream_name, firehose_client):
"""Generate and send data to Kinesis Data Firehose."""
while True:
data = get_data()
try:
firehose_client.put_record(
DeliveryStreamName=stream_name,
Record={
'Data': json.dumps(data)
}
)
print("Data sent successfully:", data)
except Exception as e:
print("Error:", e)
if __name__ == '__main__':
firehose_client = boto3.client('firehose', region_name=REGION_NAME)
generate(STREAM_NAME, firehose_client)