import gzip
def decompress(file_path):
with gzip.open(file_path, 'rb') as f:
decompressed_data = f.read().decode('utf-8')
return decompressed_data
print(decompress("output.tar.gz"))
code karma
python code to decompress a file and return the value in a variable(in memory)
API Gateway with custom authorizer lambda wont support signature validation
AWS API Gateway with custom authorizer |
If you have an API Gateway with a custom authorizer and you want to validate the signature of the incoming request(POST, PUT or calls with payload) then AWS currently does not support this. Usually the signature validation logic will need the request payload.
But AWS API Gateway does not forward the request body to the authorizer lambda. You may try to hack(stage variables etc) this but there is no real way to do this as of now.
AWS cloudwatch insights queries
Here are some common useful queries for AWS insights working with lambda.
- For cold start metrics.
filter
@type
=
"REPORT"
|
parse
@message
/Init Duration: (?<init>\S+)/ |
stats count() as total, count(init) as coldStarts,
median(init) as avgInitDuration,
max(init) as maxInitDuration,
avg(
@maxMemoryUsed
)/
1000
/
1000
as memoryused
by bin (30min)
- For Lambda memory size utilization metrics.
filter
@type
=
"REPORT"
| stats avg(
@maxMemoryUsed
/
1024
/
1024
) as mean_MemoryUsed,
min(
@maxMemoryUsed
/
1024
/
1024
) as min_MemoryUsed,
max(
@maxMemoryUsed
/
1024
/
1024
) as max_MemoryUsed,
percentile(
@maxMemoryUsed
/
1024
/
1024
,
95
) as Percentile95
Subscribe to:
Posts (Atom)