SlideShare a Scribd company logo
How to send gzipped requests
with boto3
Luciano Mammino ( )
@loige
AWS UserGroup Dublin
2021-07-01
loige.link/gzip-boto3
1
loige.link/gzip-boto3
Get these slides!
loige 2
Let me introduce myself first...
3
Let me introduce myself first...
I'm Luciano ( 🍕🍝) 👋
3
Let me introduce myself first...
I'm Luciano ( 🍕🍝) 👋
Senior Architect @ fourTheorem (Dublin )
3
Let me introduce myself first...
I'm Luciano ( 🍕🍝) 👋
Senior Architect @ fourTheorem (Dublin )
nodejsdp.link
Co-Author of Node.js Design Patterns  👉
3
Let me introduce myself first...
I'm Luciano ( 🍕🍝) 👋
Senior Architect @ fourTheorem (Dublin )
nodejsdp.link
Co-Author of Node.js Design Patterns  👉
Connect with me:
 
  (blog)
  (twitter)
  (twitch)
  (github)
loige.co
@loige
loige
lmammino 3
We are business focused technologists that
deliver.
 |  |
Accelerated Serverless AI as a Service Platform Modernisation
We are hiring: do you want to ?
work with us
loige 4
loige
In the previous episodes...
SLIC WATCH:             
SLIDES:     
fth.link/slic-watch
fth.link/o11y-no-pain
5
loige
⚠   ALARM "Custom-Metrics-MetricsFunctionErrorsAlarm" in EU (Ireland)
Threshold crossed: 1 out of the last 1 datapoints [84.0 (23/06/21 09:30:00)] was
greater than or equal to the threshold (1.0) (minimum 1 datapoint for OK ->
ALARM transition).
@wake_me_up_bot
6
loige 7
loige 8
loige
This guy was failing... a lot!
8
loige 9
for event in payload['logEvents']:
# ...
cw_client.put_metric_data(...)
loige 10
for event in payload['logEvents']:
# ...
cw_client.put_metric_data(...)
loige
Sending 1 metric per log line... 🙈
10
[
{
'MetricName': 'SomeMetric1',
'Dimensions': [
{
'Name': 'Dimension1Name',
'Value': 'Dimension1Value'
},
# Up to other 9 dimensions here ...
],
'Unit': 'Count',
'Values': [217, 220, 221], # Up to 150 items here ...
'Timestamp': 1624290910000
},
# Up to other 19 metric items here ...
]
loige 11
[
{
'MetricName': 'SomeMetric1',
'Dimensions': [
{
'Name': 'Dimension1Name',
'Value': 'Dimension1Value'
},
# Up to other 9 dimensions here ...
],
'Unit': 'Count',
'Values': [217, 220, 221], # Up to 150 items here ...
'Timestamp': 1624290910000
},
# Up to other 19 metric items here ...
]
loige
⚠Payload size
limit: 40 KB
11
loige 12
loige
🤔
12
loige
Maybe boto3 gzips the data
automatically! 😏
13
import boto3
import gzip
endpoint_url = "http://localhost:8000/"
cw_client = boto3.client('cloudwatch', endpoint_url=endpoint_url, use_ssl=False)
cw_client.put_metric_data(
MetricData = [
{
'MetricName': 'TEST_BOTO',
'Dimensions': [
{
'Name': 'APP_VERSION',
'Value': '1.0'
},
],
'Unit': 'None',
'Value': 17
},
],
Namespace='BotoTest'
)
loige 14
import boto3
import gzip
endpoint_url = "http://localhost:8000/"
cw_client = boto3.client('cloudwatch', endpoint_url=endpoint_url, use_ssl=False)
cw_client.put_metric_data(
MetricData = [
{
'MetricName': 'TEST_BOTO',
'Dimensions': [
{
'Name': 'APP_VERSION',
'Value': '1.0'
},
],
'Unit': 'None',
'Value': 17
},
],
Namespace='BotoTest'
)
loige 14
import boto3
import gzip
endpoint_url = "http://localhost:8000/"
cw_client = boto3.client('cloudwatch', endpoint_url=endpoint_url, use_ssl=False)
cw_client.put_metric_data(
MetricData = [
{
'MetricName': 'TEST_BOTO',
'Dimensions': [
{
'Name': 'APP_VERSION',
'Value': '1.0'
},
],
'Unit': 'None',
'Value': 17
},
],
Namespace='BotoTest'
)
loige 14
loige 15
loige
... and there is no magic flag like
GzipPayload=True! 😭
16
loige
Can we extend boto3 somehow? 🤔
17
loige
boto3 has an event system! 🤩
youtu.be/eM8uoGJO2AI
@thekyleknapp
18
import boto3
lambda_client = boto3.client('lambda')
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
# get the event system for the lambda_client
event_system = lambda_client.meta.events
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
loige 19
import boto3
lambda_client = boto3.client('lambda')
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
# get the event system for the lambda_client
event_system = lambda_client.meta.events
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import boto3
lambda_client = boto3.client('lambda')
1
2
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
loige 19
import boto3
lambda_client = boto3.client('lambda')
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
# get the event system for the lambda_client
event_system = lambda_client.meta.events
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import boto3
lambda_client = boto3.client('lambda')
1
2
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
5
6
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
loige 19
import boto3
lambda_client = boto3.client('lambda')
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
# get the event system for the lambda_client
event_system = lambda_client.meta.events
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import boto3
lambda_client = boto3.client('lambda')
1
2
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
5
6
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# get the event system for the lambda_client
event_system = lambda_client.meta.events
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
9
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
loige 19
import boto3
lambda_client = boto3.client('lambda')
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
# get the event system for the lambda_client
event_system = lambda_client.meta.events
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import boto3
lambda_client = boto3.client('lambda')
1
2
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
5
6
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# get the event system for the lambda_client
event_system = lambda_client.meta.events
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
9
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
12
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
loige 19
import boto3
lambda_client = boto3.client('lambda')
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
# get the event system for the lambda_client
event_system = lambda_client.meta.events
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import boto3
lambda_client = boto3.client('lambda')
1
2
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
5
6
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# get the event system for the lambda_client
event_system = lambda_client.meta.events
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
9
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
12
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
15
16
loige 19
import boto3
lambda_client = boto3.client('lambda')
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
# get the event system for the lambda_client
event_system = lambda_client.meta.events
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import boto3
lambda_client = boto3.client('lambda')
1
2
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
5
6
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# get the event system for the lambda_client
event_system = lambda_client.meta.events
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
9
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
12
13
14
# invoke a lambda function
15
lambda_client.invoke(FunctionName='my-function')
16
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
import boto3
1
2
lambda_client = boto3.client('lambda')
3
4
# our event handler
5
def add_xtrace_header(request, **kwargs):
6
request.headers.add_header('x-trace-id', 'trace-trace')
7
8
# get the event system for the lambda_client
9
event_system = lambda_client.meta.events
10
11
# attach an event handler to the client for
12
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
13
14
15
16
import boto3
lambda_client = boto3.client('lambda')
# our event handler
def add_xtrace_header(request, **kwargs):
request.headers.add_header('x-trace-id', 'trace-trace')
# get the event system for the lambda_client
event_system = lambda_client.meta.events
# attach an event handler to the client for
event_system.register('before-sign.lambda.Invoke', add_xtrace_header)
# invoke a lambda function
lambda_client.invoke(FunctionName='my-function')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
loige 19
loige
Event naming convention
<event-type>.<service-name>.<operation-name>
20
loige
Event naming convention
<event-type>.<service-name>.<operation-name>
provide-client-params
request-created
before-sign
before-send
response-received
20
loige
Event naming convention
<event-type>.<service-name>.<operation-name>
provide-client-params
request-created
before-sign
before-send
response-received
s3
cloudwatch
lambda
...
20
loige
Event naming convention
<event-type>.<service-name>.<operation-name>
provide-client-params
request-created
before-sign
before-send
response-received
s3
cloudwatch
lambda
...
ListBuckets
PutMetricData
Invoke
...
20
loige
You can be a 🌟too!
 
* (every event)
after-call.*.* (all responses)
after-call.lambda.* (all responses for lambda)
21
loige
OK, now we know enough to write
our own event handler for gzip
compression! 🤓
22
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
loige 23
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
loige 23
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
import gzip
import boto3
1
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
loige 23
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
import gzip
import boto3
1
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
import boto3
1
import gzip
2
3
4
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
loige 23
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
import gzip
import boto3
1
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
import boto3
1
import gzip
2
3
4
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
7
8
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
loige 23
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
import gzip
import boto3
1
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
import boto3
1
import gzip
2
3
4
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
7
8
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
request.headers.add_header('Content-Encoding', 'gzip')
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
loige 23
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
import gzip
import boto3
1
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
import boto3
1
import gzip
2
3
4
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
7
8
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
request.headers.add_header('Content-Encoding', 'gzip')
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
loige 23
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
import gzip
import boto3
1
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
import boto3
1
import gzip
2
3
4
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
7
8
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
request.headers.add_header('Content-Encoding', 'gzip')
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
13
14
15
16
cw_client.put_metric_data(...)
17
loige 23
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
import gzip
import boto3
1
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
import boto3
1
import gzip
2
3
4
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
7
8
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
request.headers.add_header('Content-Encoding', 'gzip')
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
13
14
15
16
cw_client.put_metric_data(...)
17 cw_client.put_metric_data(...)
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
17
loige 23
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
import gzip
import boto3
1
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
import boto3
1
import gzip
2
3
4
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
7
8
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
request.headers.add_header('Content-Encoding', 'gzip')
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
13
14
15
16
cw_client.put_metric_data(...)
17 cw_client.put_metric_data(...)
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
17
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
loige 23
loige 24
loige
Other potential use cases
Log data before/after it is sent to AWS
Add additional headers to AWS requests (tracing)
Additional input validation (your custom rules)
Payload enrichment (e.g. make sure certain tags exist)
25
loige
What if you don't use Python?
Customizing the AWS SDK for Go V2 Client Requests
Introducing Middleware Stack in Modular AWS SDK for
JavaScript
Handlers and Middleware in the AWS SDK for PHP Version 3
26
loige
What did we learn?
Always have alarms for your lambdas!
(have you checked already? 😉)
You can use Gzip compression to send big payloads to AWS
Boto3 is extensible through its event system!
SLIC Watch
27
loige
Do you think boto3 should make it easier to
send gzipped payloads?
👍UPVOTE this issue: github.com/boto/botocore/issues/2425
28
loige
Do you want more details?
loige.link/gzip-boto3-article
29
Cover picturea by on
Thanks doggie by Stefanie Shank
Moritz Mentges Unsplash
loige
nodejsdp.link
loige.link/gzip-boto3
30

More Related Content

What's hot

Asynchronous programming done right - Node.js
Asynchronous programming done right - Node.jsAsynchronous programming done right - Node.js
Asynchronous programming done right - Node.js
Piotr Pelczar
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
Florent Pillet
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript
jnewmanux
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
deepfountainconsulting
 
$q and Promises in AngularJS
$q and Promises in AngularJS $q and Promises in AngularJS
$q and Promises in AngularJS
a_sharif
 
JavaScript Promise
JavaScript PromiseJavaScript Promise
JavaScript Promise
Joseph Chiang
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
xSawyer
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
Shmuel Fomberg
 
Promise pattern
Promise patternPromise pattern
Promise pattern
Sebastiaan Deckers
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
Derek Willian Stavis
 
Promises, Promises
Promises, PromisesPromises, Promises
Promises, Promises
Domenic Denicola
 
Practical JavaScript Promises
Practical JavaScript PromisesPractical JavaScript Promises
Practical JavaScript Promises
Asa Kusuma
 
Any event intro
Any event introAny event intro
Any event intro
qiang
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
Tomasz Bak
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
L&T Technology Services Limited
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitives
Bartosz Sypytkowski
 
Beyond Profilers: Tracing Node.js Transactions
Beyond Profilers: Tracing Node.js TransactionsBeyond Profilers: Tracing Node.js Transactions
Beyond Profilers: Tracing Node.js Transactions
Terral R Jordan
 
Présentation de HomeKit
Présentation de HomeKitPrésentation de HomeKit
Présentation de HomeKit
CocoaHeads France
 
Getting Comfortable with JS Promises
Getting Comfortable with JS PromisesGetting Comfortable with JS Promises
Getting Comfortable with JS Promises
Asa Kusuma
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
Bram Vogelaar
 

What's hot (20)

Asynchronous programming done right - Node.js
Asynchronous programming done right - Node.jsAsynchronous programming done right - Node.js
Asynchronous programming done right - Node.js
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
 
$q and Promises in AngularJS
$q and Promises in AngularJS $q and Promises in AngularJS
$q and Promises in AngularJS
 
JavaScript Promise
JavaScript PromiseJavaScript Promise
JavaScript Promise
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
 
Promise pattern
Promise patternPromise pattern
Promise pattern
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
Promises, Promises
Promises, PromisesPromises, Promises
Promises, Promises
 
Practical JavaScript Promises
Practical JavaScript PromisesPractical JavaScript Promises
Practical JavaScript Promises
 
Any event intro
Any event introAny event intro
Any event intro
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitives
 
Beyond Profilers: Tracing Node.js Transactions
Beyond Profilers: Tracing Node.js TransactionsBeyond Profilers: Tracing Node.js Transactions
Beyond Profilers: Tracing Node.js Transactions
 
Présentation de HomeKit
Présentation de HomeKitPrésentation de HomeKit
Présentation de HomeKit
 
Getting Comfortable with JS Promises
Getting Comfortable with JS PromisesGetting Comfortable with JS Promises
Getting Comfortable with JS Promises
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 

Similar to How to send gzipped requests with boto3

Mini Curso de Django
Mini Curso de DjangoMini Curso de Django
Mini Curso de Django
Felipe Queiroz
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratch
Katy Slemon
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
Leonardo Fernandes
 
Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2
Alessandro Molina
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
Antônio Roberto Silva
 
Behind the scenes of Scaleway Functions : when Kubernetes meets our products
Behind the scenes of Scaleway Functions : when Kubernetes meets our productsBehind the scenes of Scaleway Functions : when Kubernetes meets our products
Behind the scenes of Scaleway Functions : when Kubernetes meets our products
Scaleway
 
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Teleport
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
Yuriy Senko
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
Marco Vito Moscaritolo
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
Wesley Beary
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
Wesley Beary
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
Andrey Karpov
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
KAI CHU CHUNG
 
Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)
남균 김
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
MongoDB
 
Structure your Play application with the cake pattern (and test it)
Structure your Play application with the cake pattern (and test it)Structure your Play application with the cake pattern (and test it)
Structure your Play application with the cake pattern (and test it)
yann_s
 
Tasks: you gotta know how to run them
Tasks: you gotta know how to run themTasks: you gotta know how to run them
Tasks: you gotta know how to run them
Filipe Ximenes
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
CODE BLUE
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
Loiane Groner
 
Monitoring at scale: Migrating to Prometheus at Fastly
Monitoring at scale: Migrating to Prometheus at FastlyMonitoring at scale: Migrating to Prometheus at Fastly
Monitoring at scale: Migrating to Prometheus at Fastly
Marcus Barczak
 

Similar to How to send gzipped requests with boto3 (20)

Mini Curso de Django
Mini Curso de DjangoMini Curso de Django
Mini Curso de Django
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratch
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
 
Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Behind the scenes of Scaleway Functions : when Kubernetes meets our products
Behind the scenes of Scaleway Functions : when Kubernetes meets our productsBehind the scenes of Scaleway Functions : when Kubernetes meets our products
Behind the scenes of Scaleway Functions : when Kubernetes meets our products
 
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
Structure your Play application with the cake pattern (and test it)
Structure your Play application with the cake pattern (and test it)Structure your Play application with the cake pattern (and test it)
Structure your Play application with the cake pattern (and test it)
 
Tasks: you gotta know how to run them
Tasks: you gotta know how to run themTasks: you gotta know how to run them
Tasks: you gotta know how to run them
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 
Monitoring at scale: Migrating to Prometheus at Fastly
Monitoring at scale: Migrating to Prometheus at FastlyMonitoring at scale: Migrating to Prometheus at Fastly
Monitoring at scale: Migrating to Prometheus at Fastly
 

More from Luciano Mammino

Did you know JavaScript has iterators? DublinJS
Did you know JavaScript has iterators? DublinJSDid you know JavaScript has iterators? DublinJS
Did you know JavaScript has iterators? DublinJS
Luciano Mammino
 
What I learned by solving 50 Advent of Code challenges in Rust - RustNation U...
What I learned by solving 50 Advent of Code challenges in Rust - RustNation U...What I learned by solving 50 Advent of Code challenges in Rust - RustNation U...
What I learned by solving 50 Advent of Code challenges in Rust - RustNation U...
Luciano Mammino
 
Building an invite-only microsite with Next.js & Airtable - ReactJS Milano
Building an invite-only microsite with Next.js & Airtable - ReactJS MilanoBuilding an invite-only microsite with Next.js & Airtable - ReactJS Milano
Building an invite-only microsite with Next.js & Airtable - ReactJS Milano
Luciano Mammino
 
From Node.js to Design Patterns - BuildPiper
From Node.js to Design Patterns - BuildPiperFrom Node.js to Design Patterns - BuildPiper
From Node.js to Design Patterns - BuildPiper
Luciano Mammino
 
Let's build a 0-cost invite-only website with Next.js and Airtable!
Let's build a 0-cost invite-only website with Next.js and Airtable!Let's build a 0-cost invite-only website with Next.js and Airtable!
Let's build a 0-cost invite-only website with Next.js and Airtable!
Luciano Mammino
 
Everything I know about S3 pre-signed URLs
Everything I know about S3 pre-signed URLsEverything I know about S3 pre-signed URLs
Everything I know about S3 pre-signed URLs
Luciano Mammino
 
Serverless for High Performance Computing
Serverless for High Performance ComputingServerless for High Performance Computing
Serverless for High Performance Computing
Luciano Mammino
 
Serverless for High Performance Computing
Serverless for High Performance ComputingServerless for High Performance Computing
Serverless for High Performance Computing
Luciano Mammino
 
JavaScript Iteration Protocols - Workshop NodeConf EU 2022
JavaScript Iteration Protocols - Workshop NodeConf EU 2022JavaScript Iteration Protocols - Workshop NodeConf EU 2022
JavaScript Iteration Protocols - Workshop NodeConf EU 2022
Luciano Mammino
 
Building an invite-only microsite with Next.js & Airtable
Building an invite-only microsite with Next.js & AirtableBuilding an invite-only microsite with Next.js & Airtable
Building an invite-only microsite with Next.js & Airtable
Luciano Mammino
 
Let's take the monolith to the cloud 🚀
Let's take the monolith to the cloud 🚀Let's take the monolith to the cloud 🚀
Let's take the monolith to the cloud 🚀
Luciano Mammino
 
A look inside the European Covid Green Certificate - Rust Dublin
A look inside the European Covid Green Certificate - Rust DublinA look inside the European Covid Green Certificate - Rust Dublin
A look inside the European Covid Green Certificate - Rust Dublin
Luciano Mammino
 
Monoliths to the cloud!
Monoliths to the cloud!Monoliths to the cloud!
Monoliths to the cloud!
Luciano Mammino
 
The senior dev
The senior devThe senior dev
The senior dev
Luciano Mammino
 
Node.js: scalability tips - Azure Dev Community Vijayawada
Node.js: scalability tips - Azure Dev Community VijayawadaNode.js: scalability tips - Azure Dev Community Vijayawada
Node.js: scalability tips - Azure Dev Community Vijayawada
Luciano Mammino
 
A look inside the European Covid Green Certificate (Codemotion 2021)
A look inside the European Covid Green Certificate (Codemotion 2021)A look inside the European Covid Green Certificate (Codemotion 2021)
A look inside the European Covid Green Certificate (Codemotion 2021)
Luciano Mammino
 
AWS Observability Made Simple
AWS Observability Made SimpleAWS Observability Made Simple
AWS Observability Made Simple
Luciano Mammino
 
Semplificare l'observability per progetti Serverless
Semplificare l'observability per progetti ServerlessSemplificare l'observability per progetti Serverless
Semplificare l'observability per progetti Serverless
Luciano Mammino
 
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Luciano Mammino
 
Finding a lost song with Node.js and async iterators - EnterJS 2021
Finding a lost song with Node.js and async iterators - EnterJS 2021Finding a lost song with Node.js and async iterators - EnterJS 2021
Finding a lost song with Node.js and async iterators - EnterJS 2021
Luciano Mammino
 

More from Luciano Mammino (20)

Did you know JavaScript has iterators? DublinJS
Did you know JavaScript has iterators? DublinJSDid you know JavaScript has iterators? DublinJS
Did you know JavaScript has iterators? DublinJS
 
What I learned by solving 50 Advent of Code challenges in Rust - RustNation U...
What I learned by solving 50 Advent of Code challenges in Rust - RustNation U...What I learned by solving 50 Advent of Code challenges in Rust - RustNation U...
What I learned by solving 50 Advent of Code challenges in Rust - RustNation U...
 
Building an invite-only microsite with Next.js & Airtable - ReactJS Milano
Building an invite-only microsite with Next.js & Airtable - ReactJS MilanoBuilding an invite-only microsite with Next.js & Airtable - ReactJS Milano
Building an invite-only microsite with Next.js & Airtable - ReactJS Milano
 
From Node.js to Design Patterns - BuildPiper
From Node.js to Design Patterns - BuildPiperFrom Node.js to Design Patterns - BuildPiper
From Node.js to Design Patterns - BuildPiper
 
Let's build a 0-cost invite-only website with Next.js and Airtable!
Let's build a 0-cost invite-only website with Next.js and Airtable!Let's build a 0-cost invite-only website with Next.js and Airtable!
Let's build a 0-cost invite-only website with Next.js and Airtable!
 
Everything I know about S3 pre-signed URLs
Everything I know about S3 pre-signed URLsEverything I know about S3 pre-signed URLs
Everything I know about S3 pre-signed URLs
 
Serverless for High Performance Computing
Serverless for High Performance ComputingServerless for High Performance Computing
Serverless for High Performance Computing
 
Serverless for High Performance Computing
Serverless for High Performance ComputingServerless for High Performance Computing
Serverless for High Performance Computing
 
JavaScript Iteration Protocols - Workshop NodeConf EU 2022
JavaScript Iteration Protocols - Workshop NodeConf EU 2022JavaScript Iteration Protocols - Workshop NodeConf EU 2022
JavaScript Iteration Protocols - Workshop NodeConf EU 2022
 
Building an invite-only microsite with Next.js & Airtable
Building an invite-only microsite with Next.js & AirtableBuilding an invite-only microsite with Next.js & Airtable
Building an invite-only microsite with Next.js & Airtable
 
Let's take the monolith to the cloud 🚀
Let's take the monolith to the cloud 🚀Let's take the monolith to the cloud 🚀
Let's take the monolith to the cloud 🚀
 
A look inside the European Covid Green Certificate - Rust Dublin
A look inside the European Covid Green Certificate - Rust DublinA look inside the European Covid Green Certificate - Rust Dublin
A look inside the European Covid Green Certificate - Rust Dublin
 
Monoliths to the cloud!
Monoliths to the cloud!Monoliths to the cloud!
Monoliths to the cloud!
 
The senior dev
The senior devThe senior dev
The senior dev
 
Node.js: scalability tips - Azure Dev Community Vijayawada
Node.js: scalability tips - Azure Dev Community VijayawadaNode.js: scalability tips - Azure Dev Community Vijayawada
Node.js: scalability tips - Azure Dev Community Vijayawada
 
A look inside the European Covid Green Certificate (Codemotion 2021)
A look inside the European Covid Green Certificate (Codemotion 2021)A look inside the European Covid Green Certificate (Codemotion 2021)
A look inside the European Covid Green Certificate (Codemotion 2021)
 
AWS Observability Made Simple
AWS Observability Made SimpleAWS Observability Made Simple
AWS Observability Made Simple
 
Semplificare l'observability per progetti Serverless
Semplificare l'observability per progetti ServerlessSemplificare l'observability per progetti Serverless
Semplificare l'observability per progetti Serverless
 
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
 
Finding a lost song with Node.js and async iterators - EnterJS 2021
Finding a lost song with Node.js and async iterators - EnterJS 2021Finding a lost song with Node.js and async iterators - EnterJS 2021
Finding a lost song with Node.js and async iterators - EnterJS 2021
 

Recently uploaded

Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17
Bhajan Mehta
 
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptxFIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Alliance
 
The History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal EmbeddingsThe History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal Embeddings
Zilliz
 
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partesExchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
jorgelebrato
 
NVIDIA at Breakthrough Discuss for Space Exploration
NVIDIA at Breakthrough Discuss for Space ExplorationNVIDIA at Breakthrough Discuss for Space Exploration
NVIDIA at Breakthrough Discuss for Space Exploration
Alison B. Lowndes
 
Redefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI CapabilitiesRedefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI Capabilities
Priyanka Aash
 
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
FIDO Alliance
 
Demystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity ApplicationsDemystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity Applications
Priyanka Aash
 
It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
Zilliz
 
How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...
DianaGray10
 
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
Fwdays
 
Finetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and DefendingFinetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and Defending
Priyanka Aash
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
AmandaCheung15
 
History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )
Badri_Bady
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
Enterprise Knowledge
 
FIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptxFIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Alliance
 
"Making .NET Application Even Faster", Sergey Teplyakov.pptx
"Making .NET Application Even Faster", Sergey Teplyakov.pptx"Making .NET Application Even Faster", Sergey Teplyakov.pptx
"Making .NET Application Even Faster", Sergey Teplyakov.pptx
Fwdays
 
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptxFIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Alliance
 
Smart Mobility Market:Revolutionizing Transportation.pdf
Smart Mobility Market:Revolutionizing Transportation.pdfSmart Mobility Market:Revolutionizing Transportation.pdf
Smart Mobility Market:Revolutionizing Transportation.pdf
Market.us
 
Scaling Vector Search: How Milvus Handles Billions+
Scaling Vector Search: How Milvus Handles Billions+Scaling Vector Search: How Milvus Handles Billions+
Scaling Vector Search: How Milvus Handles Billions+
Zilliz
 

Recently uploaded (20)

Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17
 
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptxFIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
FIDO Munich Seminar Blueprint for In-Vehicle Payment Standard.pptx
 
The History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal EmbeddingsThe History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal Embeddings
 
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partesExchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
 
NVIDIA at Breakthrough Discuss for Space Exploration
NVIDIA at Breakthrough Discuss for Space ExplorationNVIDIA at Breakthrough Discuss for Space Exploration
NVIDIA at Breakthrough Discuss for Space Exploration
 
Redefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI CapabilitiesRedefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI Capabilities
 
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
 
Demystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity ApplicationsDemystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity Applications
 
It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
 
How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...
 
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
 
Finetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and DefendingFinetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and Defending
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
 
History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
 
FIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptxFIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptx
 
"Making .NET Application Even Faster", Sergey Teplyakov.pptx
"Making .NET Application Even Faster", Sergey Teplyakov.pptx"Making .NET Application Even Faster", Sergey Teplyakov.pptx
"Making .NET Application Even Faster", Sergey Teplyakov.pptx
 
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptxFIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
 
Smart Mobility Market:Revolutionizing Transportation.pdf
Smart Mobility Market:Revolutionizing Transportation.pdfSmart Mobility Market:Revolutionizing Transportation.pdf
Smart Mobility Market:Revolutionizing Transportation.pdf
 
Scaling Vector Search: How Milvus Handles Billions+
Scaling Vector Search: How Milvus Handles Billions+Scaling Vector Search: How Milvus Handles Billions+
Scaling Vector Search: How Milvus Handles Billions+
 

How to send gzipped requests with boto3

  • 1. How to send gzipped requests with boto3 Luciano Mammino ( ) @loige AWS UserGroup Dublin 2021-07-01 loige.link/gzip-boto3 1
  • 3. Let me introduce myself first... 3
  • 4. Let me introduce myself first... I'm Luciano ( 🍕🍝) 👋 3
  • 5. Let me introduce myself first... I'm Luciano ( 🍕🍝) 👋 Senior Architect @ fourTheorem (Dublin ) 3
  • 6. Let me introduce myself first... I'm Luciano ( 🍕🍝) 👋 Senior Architect @ fourTheorem (Dublin ) nodejsdp.link Co-Author of Node.js Design Patterns  👉 3
  • 7. Let me introduce myself first... I'm Luciano ( 🍕🍝) 👋 Senior Architect @ fourTheorem (Dublin ) nodejsdp.link Co-Author of Node.js Design Patterns  👉 Connect with me:     (blog)   (twitter)   (twitch)   (github) loige.co @loige loige lmammino 3
  • 8. We are business focused technologists that deliver.  |  | Accelerated Serverless AI as a Service Platform Modernisation We are hiring: do you want to ? work with us loige 4
  • 9. loige In the previous episodes... SLIC WATCH:              SLIDES:      fth.link/slic-watch fth.link/o11y-no-pain 5
  • 10. loige ⚠   ALARM "Custom-Metrics-MetricsFunctionErrorsAlarm" in EU (Ireland) Threshold crossed: 1 out of the last 1 datapoints [84.0 (23/06/21 09:30:00)] was greater than or equal to the threshold (1.0) (minimum 1 datapoint for OK -> ALARM transition). @wake_me_up_bot 6
  • 13. loige This guy was failing... a lot! 8
  • 15. for event in payload['logEvents']: # ... cw_client.put_metric_data(...) loige 10
  • 16. for event in payload['logEvents']: # ... cw_client.put_metric_data(...) loige Sending 1 metric per log line... 🙈 10
  • 17. [ { 'MetricName': 'SomeMetric1', 'Dimensions': [ { 'Name': 'Dimension1Name', 'Value': 'Dimension1Value' }, # Up to other 9 dimensions here ... ], 'Unit': 'Count', 'Values': [217, 220, 221], # Up to 150 items here ... 'Timestamp': 1624290910000 }, # Up to other 19 metric items here ... ] loige 11
  • 18. [ { 'MetricName': 'SomeMetric1', 'Dimensions': [ { 'Name': 'Dimension1Name', 'Value': 'Dimension1Value' }, # Up to other 9 dimensions here ... ], 'Unit': 'Count', 'Values': [217, 220, 221], # Up to 150 items here ... 'Timestamp': 1624290910000 }, # Up to other 19 metric items here ... ] loige ⚠Payload size limit: 40 KB 11
  • 21. loige Maybe boto3 gzips the data automatically! 😏 13
  • 22. import boto3 import gzip endpoint_url = "http://localhost:8000/" cw_client = boto3.client('cloudwatch', endpoint_url=endpoint_url, use_ssl=False) cw_client.put_metric_data( MetricData = [ { 'MetricName': 'TEST_BOTO', 'Dimensions': [ { 'Name': 'APP_VERSION', 'Value': '1.0' }, ], 'Unit': 'None', 'Value': 17 }, ], Namespace='BotoTest' ) loige 14
  • 23. import boto3 import gzip endpoint_url = "http://localhost:8000/" cw_client = boto3.client('cloudwatch', endpoint_url=endpoint_url, use_ssl=False) cw_client.put_metric_data( MetricData = [ { 'MetricName': 'TEST_BOTO', 'Dimensions': [ { 'Name': 'APP_VERSION', 'Value': '1.0' }, ], 'Unit': 'None', 'Value': 17 }, ], Namespace='BotoTest' ) loige 14
  • 24. import boto3 import gzip endpoint_url = "http://localhost:8000/" cw_client = boto3.client('cloudwatch', endpoint_url=endpoint_url, use_ssl=False) cw_client.put_metric_data( MetricData = [ { 'MetricName': 'TEST_BOTO', 'Dimensions': [ { 'Name': 'APP_VERSION', 'Value': '1.0' }, ], 'Unit': 'None', 'Value': 17 }, ], Namespace='BotoTest' ) loige 14
  • 26. loige ... and there is no magic flag like GzipPayload=True! 😭 16
  • 27. loige Can we extend boto3 somehow? 🤔 17
  • 28. loige boto3 has an event system! 🤩 youtu.be/eM8uoGJO2AI @thekyleknapp 18
  • 29. import boto3 lambda_client = boto3.client('lambda') # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') # get the event system for the lambda_client event_system = lambda_client.meta.events # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) # invoke a lambda function lambda_client.invoke(FunctionName='my-function') 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 loige 19
  • 30. import boto3 lambda_client = boto3.client('lambda') # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') # get the event system for the lambda_client event_system = lambda_client.meta.events # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) # invoke a lambda function lambda_client.invoke(FunctionName='my-function') 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import boto3 lambda_client = boto3.client('lambda') 1 2 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 loige 19
  • 31. import boto3 lambda_client = boto3.client('lambda') # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') # get the event system for the lambda_client event_system = lambda_client.meta.events # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) # invoke a lambda function lambda_client.invoke(FunctionName='my-function') 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import boto3 lambda_client = boto3.client('lambda') 1 2 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 5 6 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 loige 19
  • 32. import boto3 lambda_client = boto3.client('lambda') # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') # get the event system for the lambda_client event_system = lambda_client.meta.events # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) # invoke a lambda function lambda_client.invoke(FunctionName='my-function') 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import boto3 lambda_client = boto3.client('lambda') 1 2 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 5 6 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # get the event system for the lambda_client event_system = lambda_client.meta.events import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 9 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 loige 19
  • 33. import boto3 lambda_client = boto3.client('lambda') # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') # get the event system for the lambda_client event_system = lambda_client.meta.events # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) # invoke a lambda function lambda_client.invoke(FunctionName='my-function') 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import boto3 lambda_client = boto3.client('lambda') 1 2 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 5 6 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # get the event system for the lambda_client event_system = lambda_client.meta.events import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 9 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 12 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 loige 19
  • 34. import boto3 lambda_client = boto3.client('lambda') # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') # get the event system for the lambda_client event_system = lambda_client.meta.events # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) # invoke a lambda function lambda_client.invoke(FunctionName='my-function') 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import boto3 lambda_client = boto3.client('lambda') 1 2 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 5 6 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # get the event system for the lambda_client event_system = lambda_client.meta.events import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 9 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 12 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # invoke a lambda function lambda_client.invoke(FunctionName='my-function') import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 15 16 loige 19
  • 35. import boto3 lambda_client = boto3.client('lambda') # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') # get the event system for the lambda_client event_system = lambda_client.meta.events # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) # invoke a lambda function lambda_client.invoke(FunctionName='my-function') 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import boto3 lambda_client = boto3.client('lambda') 1 2 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 5 6 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # get the event system for the lambda_client event_system = lambda_client.meta.events import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 9 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 12 13 14 # invoke a lambda function 15 lambda_client.invoke(FunctionName='my-function') 16 # invoke a lambda function lambda_client.invoke(FunctionName='my-function') import boto3 1 2 lambda_client = boto3.client('lambda') 3 4 # our event handler 5 def add_xtrace_header(request, **kwargs): 6 request.headers.add_header('x-trace-id', 'trace-trace') 7 8 # get the event system for the lambda_client 9 event_system = lambda_client.meta.events 10 11 # attach an event handler to the client for 12 event_system.register('before-sign.lambda.Invoke', add_xtrace_header) 13 14 15 16 import boto3 lambda_client = boto3.client('lambda') # our event handler def add_xtrace_header(request, **kwargs): request.headers.add_header('x-trace-id', 'trace-trace') # get the event system for the lambda_client event_system = lambda_client.meta.events # attach an event handler to the client for event_system.register('before-sign.lambda.Invoke', add_xtrace_header) # invoke a lambda function lambda_client.invoke(FunctionName='my-function') 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 loige 19
  • 40. loige You can be a 🌟too!   * (every event) after-call.*.* (all responses) after-call.lambda.* (all responses for lambda) 21
  • 41. loige OK, now we know enough to write our own event handler for gzip compression! 🤓 22
  • 42. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 loige 23
  • 43. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 loige 23
  • 44. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 import gzip import boto3 1 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 loige 23
  • 45. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 import gzip import boto3 1 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events import boto3 1 import gzip 2 3 4 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 loige 23
  • 46. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 import gzip import boto3 1 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events import boto3 1 import gzip 2 3 4 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 7 8 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 loige 23
  • 47. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 import gzip import boto3 1 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events import boto3 1 import gzip 2 3 4 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 7 8 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 request.headers.add_header('Content-Encoding', 'gzip') import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 loige 23
  • 48. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 import gzip import boto3 1 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events import boto3 1 import gzip 2 3 4 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 7 8 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 request.headers.add_header('Content-Encoding', 'gzip') import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 loige 23
  • 49. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 import gzip import boto3 1 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events import boto3 1 import gzip 2 3 4 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 7 8 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 request.headers.add_header('Content-Encoding', 'gzip') import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 13 14 15 16 cw_client.put_metric_data(...) 17 loige 23
  • 50. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 import gzip import boto3 1 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events import boto3 1 import gzip 2 3 4 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 7 8 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 request.headers.add_header('Content-Encoding', 'gzip') import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 13 14 15 16 cw_client.put_metric_data(...) 17 cw_client.put_metric_data(...) import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 17 loige 23
  • 51. import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 import gzip import boto3 1 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events import boto3 1 import gzip 2 3 4 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 7 8 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 request.headers.add_header('Content-Encoding', 'gzip') import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 gzipped_body = gzip.compress(request.body) request.data = gzipped_body import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 10 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 cw_client.put_metric_data(...) 17 # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 13 14 15 16 cw_client.put_metric_data(...) 17 cw_client.put_metric_data(...) import boto3 1 import gzip 2 3 cw_client = boto3.client('cloudwatch') 4 event_system = cw_client.meta.events 5 6 # Gzip handler 7 def gzip_request_body(request, **kwargs): 8 request.headers.add_header('Content-Encoding', 'gzip') 9 gzipped_body = gzip.compress(request.body) 10 request.data = gzipped_body 11 12 # registers the custom handler 13 event_system.register('before-sign.cloudwatch.PutMetricData', 14 gzip_request_body) 15 16 17 import boto3 import gzip cw_client = boto3.client('cloudwatch') event_system = cw_client.meta.events # Gzip handler def gzip_request_body(request, **kwargs): request.headers.add_header('Content-Encoding', 'gzip') gzipped_body = gzip.compress(request.body) request.data = gzipped_body # registers the custom handler event_system.register('before-sign.cloudwatch.PutMetricData', gzip_request_body) cw_client.put_metric_data(...) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 loige 23
  • 53. loige Other potential use cases Log data before/after it is sent to AWS Add additional headers to AWS requests (tracing) Additional input validation (your custom rules) Payload enrichment (e.g. make sure certain tags exist) 25
  • 54. loige What if you don't use Python? Customizing the AWS SDK for Go V2 Client Requests Introducing Middleware Stack in Modular AWS SDK for JavaScript Handlers and Middleware in the AWS SDK for PHP Version 3 26
  • 55. loige What did we learn? Always have alarms for your lambdas! (have you checked already? 😉) You can use Gzip compression to send big payloads to AWS Boto3 is extensible through its event system! SLIC Watch 27
  • 56. loige Do you think boto3 should make it easier to send gzipped payloads? 👍UPVOTE this issue: github.com/boto/botocore/issues/2425 28
  • 57. loige Do you want more details? loige.link/gzip-boto3-article 29
  • 58. Cover picturea by on Thanks doggie by Stefanie Shank Moritz Mentges Unsplash loige nodejsdp.link loige.link/gzip-boto3 30