!mkdir -p ~/.aws && cp /content/drive/MyDrive/AWS/684947_admin ~/.aws/credentials
!chmod 600 ~/.aws/credentials
!pip install -qq awscli boto3
!aws sts get-caller-identity
In this lab you will learn how to ingest, process, and consume streaming data using AWS serverless services such as Kinesis Data Streams, Glue, S3, and Athena. To simulate the data streaming input, we will use Kinesis Data Generator (KDG).
!aws cloudformation create-stack \
--stack-name KinesisGlue \
--template-body file://kinesis_glue.yml \
--capabilities CAPABILITY_NAMED_IAM
{ "StackId": "arn:aws:cloudformation:us-east-1:684199068947:stack/KinesisGlue/821f3c20-6c97-11ed-a13b-0e9b6ec0e0ff" }
{
"customerId": "{{random.number(50)}}",
"transactionAmount": {{random.number(
{
"min":10,
"max":150
}
)}},
"sourceIp" : "{{internet.ip}}",
"status": "{{random.weightedArrayElement({
"weights" : [0.8,0.1,0.1],
"data": ["OK","FAIL","PENDING"]
}
)}}",
"transactionTime": "{{date.now}}"
}
{
"customerId": "{{random.number(50)}}",
"transactionAmount": {{random.number(
{
"min":10,
"max":150
}
)}},
"sourceIp" : "221.233.116.256",
"status": "{{random.weightedArrayElement({
"weights" : [0.8,0.1,0.1],
"data": ["OK","FAIL","PENDING"]
}
)}}",
"transactionTime": "{{date.now}}"
}
SELECT count(*) as numberOfTransactions, sourceip
FROM "tickettransactiondatabase"."parquet_tickettransactionstreamingdata"
WHERE ingest_year='2022'
AND cast(ingest_year as bigint)=year(now())
AND cast(ingest_month as bigint)=month(now())
AND cast(ingest_day as bigint)=day_of_month(now())
AND cast(ingest_hour as bigint)=hour(now())
GROUP BY sourceip
Order by numberOfTransactions DESC;
SELECT *
FROM "tickettransactiondatabase"."parquet_tickettransactionstreamingdata"
WHERE ingest_year='2022'
AND cast(ingest_year as bigint)=year(now())
AND cast(ingest_month as bigint)=month(now())
AND cast(ingest_day as bigint)=day_of_month(now())
AND cast(ingest_hour as bigint)=hour(now())
AND sourceip='221.233.116.256'
limit 100;
As you created, Kinesis Analytics application manually, so need to delete it by selecting your analytics application . Click on Action drop down and select delete application
Delete the Glue Crawlers, Tables and Databases also manually.