Funky serverless features at aws

Doug Winter
Doug WinterDirector em Isotoma Limited
Funky Serverless Features at AWS
Doug Winter - Isotoma
Contents
Real-world examples of some serverless implementation patterns, using API
Gateway primarily. In particular:
■ Introduction: authentication for a serverless project for the BBC
■ Quick intro to API Gateway as a serverless toolkit
■ Example access to other serverless services using API Gateway
● S3
● Email
● DynamoDB
■ How to practically use API Gateway yourself
■ Spotting candidates for this approach
Me
■ Nearly 30 years professional experience
■ Dev, Ops, DevOps, Architecture, Consultancy, Strategy,
Stuff
■ Ran engineering for Online Operations at the BBC in
2000/2001
■ CTO of a dotcom during the boom (and bust)
■ Owner/Director of Isotoma since 2004
■ Still write code, mostly Python, Go and Typescript
Characteristics of "serverless"
1. No cost when no use, cost scales with usage
2. Provisioning decisions taken by the cloud provider
3. "Infinite" scaling capacity
Not really anything to do with servers or the lack thereof, or
FaaS
IDT Cloud
IDT Cloud Introduction
■ IDT = In Depth Toolkit ¯_(ツ)_/¯
■ BBC News journalists often need to embed charts and
other visualisations in their output
■ An existing tool, IDT, provided charting services for
journalists, using the previous generation of BBC News
delivery infrastructure, Forge, which was PHP
IDT Cloud Introduction
■ BBC News are moving to AWS and all services should now
be delivered from with AWS services
■ This was an opportunity to entirely rewrite IDT and make
it fit for purpose
■ We had (largely) complete freedom to choose
implementation technologies
■ The new version is called IDT Cloud
Particular challenges
■ BBC News audience is approx 500M people globally, in
many languages, which is quite a lot
■ Must function on a wide range of devices, including some
old phones and in both landscape and portrait
■ Which is hard for charts!
■ Lots of choices for how to fit charts onto small devices -
but often the choices depend on the size, language and
aspect ratio
■ Kind of high traffic levels sometimes
Architecture
Lots of moving parts
■ Datastore for chart origination material (JSON blobs
describing charts, plus ancillary artifacts like background
images)
■ Integration with other BBC News systems, including
several generations of CMS
■ Editorial interface for journalists to interact with their
charts
■ Rendering system to deliver charts in every output format
needed
The serverless bit
Authentication
■ We wanted a private application for authorized BBC Users
only
■ BBC Users are authorized by either:
● a) having a valid client X509 certificate in their
browser, or
● b) Logging into the BBC Login single sign-on system
■ API Gateway is on the public internet
■ API Gateway can't see client certs (this sucks by the way,
AWS should support X509 PKI everywhere)
The Authentication Proxy
Our solution:
1. require AWS_IAM authentication for the API,
● all requests to it must be signed
2. Send users via a proxy, running on EC2, that examines the
client certificate. If it is not present it goes through the
login ceremony via BBC Login
3. Authenticated users are proxied to API Gateway with
signed requests
Not actually overkill
Seems like an overcomplex solution
- but the proxy is entirely reusable, providing a standard way
for new applications to be delivered via API Gateway with no
authentication code needed.
API Gateway
Common perception of API Gateway
"How I get my lambda function on a URL"
What API Gateway really is
■ URL mapping
■ Access Control and Management
■ Validation & Error Handling
■ Request & Response Transformation
■ Access to AWS backing services
■ A bunch of other useful stuff (throttling, API keys etc.)
Core Anti-feature
■ Really, really, really, really annoying to configure and deploy. Even more
than usual.
■ Can be done with CloudFormation but it is bad (even for CloudFormation)
■ Can be done with Swagger, but you will need to write some tooling
■ Supported by other tools:
● SAM
● serverless.com
● But they only provide basic functionality
Funky serverless features at aws
How not to do a UI
Resources
Stages
Use cases
Decoupled authentication
Decoupled authentication
■ Authentication is bad
● Authenticating API requests is expensive
● For microservice-based architectures it means all services need
to apply authentication, so authentication changes mean
everything needs releasing
■ Instead, authenticate within API Gateway
■ Services can assume requests are authenticated
■ For bonus points, use Cognito for authentication and you can hand off
almost everything
OWASP 2017
Also...
Supported schemes
Lambda Function
■ Bring your own authorizer
■ Called on each request
■ You examine the request to
determine if authenticated
■ Returns:
● A principal identifier
● An IAM Policy
Cognito User Pool
■ Calling client authenticates with
Cognito
■ Include the JWT Token as the
Authorization header
Principals & permissions
■ The principal provided is available in the context for your integrations (we
have used a custom header to deliver the principal ID)
■ Associated IAM Policies can be used to secure back-end services
■ Using the "invoke with caller credentials" option in the integration means
the IAM Policies you deliver in the authorizer are used directly
■ With Cognito, users can be placed into groups and the groups provide IAM
Roles, which specify the policies used
■ Together this means you can entirely outsource your authentication,
authorization and user management
Benefits
■ Federation - Cognito can federate to lots of identity providers
■ Reduced developer friction - dev environments can ignore authentication
for the most part
■ Security - it is easy to screw up roll-your-own authentication
■ Robustness - This is easily one of the most error-prone parts of a
codebase, so getting rid of it is a good thing
■ Agility - Apply a common authentication layer across heterogenous
underlying serverless and microservices
Static files
Static files
1. Web applications need static files
a. Initial HTML page
b. Javascript & CSS
c. Images etc.
2. You may wish to deliver these on URLs alongside your API
3. You can do this with API Gateway
Static files
■ Super simple use case
■ Two options for the Integration
● HTTP integration to the s3 HTTP endpoint
● Service integration to S3 "as a service"
■ Using the service integration allows us to access objects
in private buckets
Static files
S3 Blobs
S3 Blobs
1. Direct access to S3 from React etc. is a common
requirement, for both reading and writing
2. We can do this entirely in API Gateway
S3 Blobs
■ For the IDT project we need to store and retrieve
configuration for charts, which are just JSON blobs
■ All authorized users can load and store all blobs, so there
are no complex authorization rules
■ API Gateway can do this without the need for any
Lambda
PUTing
Sending email
Sending email
1. Sending Email in response to a user request means you
have to constrain at least one of:
a. To address
b. Subject and Body
2. Or it can be used as a spam factory
3. So you can't just hand out SES Access Key and Secret to
your React application (doh)
4. API Gateway to the rescue
Simple Email Service (SES)
■ SES is ancient and has a dreadful API
■ This is mostly hidden from you because you either use:
● the SES support in the AWS SDK (which is fine), or
● the SMTP API, which is... SMTP
■ However under the hood it is seriously old skool
■ This is a good (but simple) example of how much heavy
lifting API Gateway can do
The SES API
From: sender@isotoma.com
To: president@whitehouse.gov
Subject: Hello Mr President
How are you?
Content-Type: application/x-www-form-urlencoded
Action=SendRawEmail&Source=sender%40isotoma.com&Destin
ations.member.1=president%40whitehouse.gov&RawMessage.
Data=Subject%3A+Hello+Mr+President%0A%0AHow+are+you%3F
%0A'
Serialised as x-www-form-urlencoded rather than JSON or XML.
Also it is generally kind of confusing
Here is a real example that works though:
The API we want to provide
Model schema specified in JSON
schema
Input is validated against this
automatically
Then allows us to access named
parts of the input in processing
Integration with SES
Set up the integration to
SES
Transformations
■ Uses the Velocity templating language
■ Velocity is kind of terrible
■ all templating languages are terrible
■ but less terrible than writing code. generally.
■ there are loads of useful functions and it is actually
pretty good
■ We use "stage variables" to store constants
The template
Action=SendRawEmail&Source=$util.urlEncode($stageVariabl
es.SignupSource)&Destinations.member.1=$util.urlEncode($
stageVariables.SignupRecipient)&RawMessage.Data=$util.ur
lEncode($util.base64Encode("Subject:
$input.path('$.subject')
$input.path('$.body')"))
DynamoDB
Fine Grained Access Control
The feature
IAM Policies can include
conditions restricting access
to DynamoDB tables to rows
where the HASH key matches
defined strings.
We can use the authenticated
user's identifier here, so
restricting a user to only their
rows in the database.
How to use it
1. Use cognito
2. Add an IAM Policy like this
3. Use "invoke with caller credentials"
4. Magic
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:Query"
],
"Resource": [
"table_arn"
],
"Condition": {
"ForAllValues:StringEquals": {
"dynamodb:LeadingKeys": [
"${cognito-
identity.amazonaws.com:sub}"
]
}
}
}
]
}
Using API Gateway
Using API Gateway
1. Cloudformation does have resources to
cover API Gateway (see right)
2. You really don't want to use these!
3. Swagger (OpenAPI) is better
4. BUT it has no concept of variables
5. ALSO CloudFormation tooling for Swagger
is kind of lame
Workflow
1. Mock out and test features in the console
2. Export the Swagger from the stage
3. Replace hard coded literals with variables
4. Extend the Swagger to cover your whole API
5. Write something to do configuration management for you
6. Put the file in an S3 bucket
7. Run CloudFormation
8. Write something to update the API by calling the API Gateway API
Funky serverless features at aws
Funky serverless features at aws
Spotting candidates
Is this even a good idea?
I think these techniques deliver benefits:
1. Less code
2. Outsource and commoditise
3. Design "with the grain" of the underlying services
4. Enforce simplicity
5. Actual API-first design
But they can be challenging to exploit
Spotting candidates
■ Application code is generally "get a request, do some
stuff, access some backing services, return a response"
■ Only a subset can be implemented entirely in API
Gateway:
● No loops
● Single input and single output transformation
The challenge
■ Few developers have an in depth knowledge of more than
a couple of AWS services
■ All of the examples I've shown here can instead be
implemented in custom code
■ Organizationally it might be easier to implement in
custom code...
■ ...even if the product is worse
■ And the tooling is, at best, patchy
Handling change
■ Replacing these things with Lambda calls is easy
■ Your API remains stable
■ So stubbing out an API early on with simple S3 access
etc. can be a good way to get moving
■ Don't worry if you will later need more complexity
October 17, 2018
October 17, 2018
Thank You Supporters
October 17, 2018
Meet me in the Slack channel for Q&A
bit.ly/addo-slack
1 de 60

Recomendados

Aws Technical Day 2015 - Amazon API Gateway por
Aws Technical Day 2015 - Amazon API GatewayAws Technical Day 2015 - Amazon API Gateway
Aws Technical Day 2015 - Amazon API Gatewayaws-marketing-il
327 visualizações40 slides
Build and Manage Your APIs with Amazon API Gateway por
Build and Manage Your APIs with Amazon API GatewayBuild and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API GatewayAmazon Web Services
21.7K visualizações37 slides
AWS July Webinar Series: Overview: Build and Manage your APIs with Amazon API... por
AWS July Webinar Series: Overview: Build and Manage your APIs with Amazon API...AWS July Webinar Series: Overview: Build and Manage your APIs with Amazon API...
AWS July Webinar Series: Overview: Build and Manage your APIs with Amazon API...Amazon Web Services
2.4K visualizações37 slides
Amazon API Gateway por
Amazon API GatewayAmazon API Gateway
Amazon API GatewayMark Bate
1.4K visualizações32 slides
AWS July Webinar Series - Overview Build and Manage your APs with amazon api ... por
AWS July Webinar Series - Overview Build and Manage your APs with amazon api ...AWS July Webinar Series - Overview Build and Manage your APs with amazon api ...
AWS July Webinar Series - Overview Build and Manage your APs with amazon api ...Amazon Web Services
3.2K visualizações37 slides
Amazon API Gateway por
Amazon API GatewayAmazon API Gateway
Amazon API GatewayMark Bate
821 visualizações25 slides

Mais conteúdo relacionado

Mais procurados

Serverless Web Apps using API Gateway, Lambda and DynamoDB por
Serverless Web Apps using API Gateway, Lambda and DynamoDBServerless Web Apps using API Gateway, Lambda and DynamoDB
Serverless Web Apps using API Gateway, Lambda and DynamoDBAmazon Web Services
3.7K visualizações49 slides
Amazon API Gateway por
Amazon API GatewayAmazon API Gateway
Amazon API GatewayAmazon Web Services
3.2K visualizações11 slides
Simple Security for Startups por
Simple Security for StartupsSimple Security for Startups
Simple Security for StartupsMark Bate
346 visualizações59 slides
WIN205-Building a Better .NET Bot with AWS Services por
WIN205-Building a Better .NET Bot with AWS ServicesWIN205-Building a Better .NET Bot with AWS Services
WIN205-Building a Better .NET Bot with AWS ServicesAmazon Web Services
531 visualizações47 slides
AWS Summit Barcelona 2015 - Introducing Amazon API Gateway por
AWS Summit Barcelona 2015 - Introducing Amazon API GatewayAWS Summit Barcelona 2015 - Introducing Amazon API Gateway
AWS Summit Barcelona 2015 - Introducing Amazon API GatewayVadim Zendejas
82 visualizações43 slides
Starting Mobile Development por
Starting Mobile DevelopmentStarting Mobile Development
Starting Mobile DevelopmentPranav Ainavolu
235 visualizações14 slides

Mais procurados(20)

Serverless Web Apps using API Gateway, Lambda and DynamoDB por Amazon Web Services
Serverless Web Apps using API Gateway, Lambda and DynamoDBServerless Web Apps using API Gateway, Lambda and DynamoDB
Serverless Web Apps using API Gateway, Lambda and DynamoDB
Amazon Web Services3.7K visualizações
Amazon API Gateway por Amazon Web Services
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
Amazon Web Services3.2K visualizações
Simple Security for Startups por Mark Bate
Simple Security for StartupsSimple Security for Startups
Simple Security for Startups
Mark Bate346 visualizações
WIN205-Building a Better .NET Bot with AWS Services por Amazon Web Services
WIN205-Building a Better .NET Bot with AWS ServicesWIN205-Building a Better .NET Bot with AWS Services
WIN205-Building a Better .NET Bot with AWS Services
Amazon Web Services531 visualizações
AWS Summit Barcelona 2015 - Introducing Amazon API Gateway por Vadim Zendejas
AWS Summit Barcelona 2015 - Introducing Amazon API GatewayAWS Summit Barcelona 2015 - Introducing Amazon API Gateway
AWS Summit Barcelona 2015 - Introducing Amazon API Gateway
Vadim Zendejas82 visualizações
Starting Mobile Development por Pranav Ainavolu
Starting Mobile DevelopmentStarting Mobile Development
Starting Mobile Development
Pranav Ainavolu235 visualizações
Magic of web components por HYS Enterprise
Magic of web componentsMagic of web components
Magic of web components
HYS Enterprise107 visualizações
Crafting ColdFusion Applications like an Architect por ColdFusionConference
Crafting ColdFusion Applications like an ArchitectCrafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an Architect
ColdFusionConference652 visualizações
aws lambda & api gateway por fumihiko hata
aws lambda & api gatewayaws lambda & api gateway
aws lambda & api gateway
fumihiko hata1K visualizações
AWS API Gateway por Muhammed YALÇIN
AWS API GatewayAWS API Gateway
AWS API Gateway
Muhammed YALÇIN647 visualizações
Domain Driven Design Through Onion Architecture por BoldRadius Solutions
Domain Driven Design Through Onion ArchitectureDomain Driven Design Through Onion Architecture
Domain Driven Design Through Onion Architecture
BoldRadius Solutions8.9K visualizações
Deep Dive on Amazon Cognito - DevDay Los Angeles 2017 por Amazon Web Services
Deep Dive on Amazon Cognito - DevDay Los Angeles 2017Deep Dive on Amazon Cognito - DevDay Los Angeles 2017
Deep Dive on Amazon Cognito - DevDay Los Angeles 2017
Amazon Web Services574 visualizações
Introduction to React Native por Amazon Web Services
Introduction to React NativeIntroduction to React Native
Introduction to React Native
Amazon Web Services22.3K visualizações
Scintillating por ESUG
ScintillatingScintillating
Scintillating
ESUG620 visualizações
Microservices with AWS Lambda and the Serverless Framework por Rowell Belen
Microservices with AWS Lambda and the Serverless FrameworkMicroservices with AWS Lambda and the Serverless Framework
Microservices with AWS Lambda and the Serverless Framework
Rowell Belen1.5K visualizações
Serverless por Young Yang
ServerlessServerless
Serverless
Young Yang10K visualizações
Mobile and Serverless : an Untold Story por Vidyasagar Machupalli
Mobile and Serverless : an Untold StoryMobile and Serverless : an Untold Story
Mobile and Serverless : an Untold Story
Vidyasagar Machupalli864 visualizações
Onion Architecture with S#arp por Gary Pedretti
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
Gary Pedretti4K visualizações
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle... por apidays
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...
apidays38 visualizações
Building Killer RESTful APIs with NodeJs por Srdjan Strbanovic
Building Killer RESTful APIs with NodeJsBuilding Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJs
Srdjan Strbanovic9.6K visualizações

Similar a Funky serverless features at aws

API Gateways are going through an identity crisis por
API Gateways are going through an identity crisisAPI Gateways are going through an identity crisis
API Gateways are going through an identity crisisChristian Posta
1.8K visualizações52 slides
Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati... por
Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...
Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...Amazon Web Services
680 visualizações32 slides
analytic engine - a common big data computation service on the aws por
analytic engine - a common big data computation service on the awsanalytic engine - a common big data computation service on the aws
analytic engine - a common big data computation service on the awsScott Miao
697 visualizações32 slides
ANZ Dev Lounge Session - Feb 2017 por
ANZ Dev Lounge Session - Feb 2017ANZ Dev Lounge Session - Feb 2017
ANZ Dev Lounge Session - Feb 2017Amazon Web Services
1K visualizações47 slides
Building self service framework por
Building self service frameworkBuilding self service framework
Building self service frameworkRovshan Musayev
20 visualizações32 slides
Serverless Development Deep Dive por
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep DiveAmazon Web Services
367 visualizações45 slides

Similar a Funky serverless features at aws(20)

API Gateways are going through an identity crisis por Christian Posta
API Gateways are going through an identity crisisAPI Gateways are going through an identity crisis
API Gateways are going through an identity crisis
Christian Posta1.8K visualizações
Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati... por Amazon Web Services
Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...
Customer Sharing: Trend Micro - Analytic Engine - A common Big Data computati...
Amazon Web Services680 visualizações
analytic engine - a common big data computation service on the aws por Scott Miao
analytic engine - a common big data computation service on the awsanalytic engine - a common big data computation service on the aws
analytic engine - a common big data computation service on the aws
Scott Miao697 visualizações
ANZ Dev Lounge Session - Feb 2017 por Amazon Web Services
ANZ Dev Lounge Session - Feb 2017ANZ Dev Lounge Session - Feb 2017
ANZ Dev Lounge Session - Feb 2017
Amazon Web Services1K visualizações
Building self service framework por Rovshan Musayev
Building self service frameworkBuilding self service framework
Building self service framework
Rovshan Musayev20 visualizações
Serverless Development Deep Dive por Amazon Web Services
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
Amazon Web Services367 visualizações
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools por Amazon Web Services
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer ToolsA Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
Amazon Web Services309 visualizações
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your... por Amazon Web Services
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
Amazon Web Services609 visualizações
Introduction to Serverless por Amazon Web Services
Introduction to ServerlessIntroduction to Serverless
Introduction to Serverless
Amazon Web Services2.7K visualizações
Andrew May - Getting Certified for Fun and Profit por AWS Chicago
Andrew May - Getting Certified for Fun and ProfitAndrew May - Getting Certified for Fun and Profit
Andrew May - Getting Certified for Fun and Profit
AWS Chicago105 visualizações
Twelve-factor serverless applications - MAD302 - Santa Clara AWS Summit por Amazon Web Services
Twelve-factor serverless applications - MAD302 - Santa Clara AWS SummitTwelve-factor serverless applications - MAD302 - Santa Clara AWS Summit
Twelve-factor serverless applications - MAD302 - Santa Clara AWS Summit
Amazon Web Services592 visualizações
2016 07 - CloudBridge Python library (XSEDE16) por Enis Afgan
2016 07 - CloudBridge Python library (XSEDE16)2016 07 - CloudBridge Python library (XSEDE16)
2016 07 - CloudBridge Python library (XSEDE16)
Enis Afgan123 visualizações
Improve productivity with Continuous Integration & Delivery por Amazon Web Services
Improve productivity with Continuous Integration & DeliveryImprove productivity with Continuous Integration & Delivery
Improve productivity with Continuous Integration & Delivery
Amazon Web Services827 visualizações
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit... por Amazon Web Services
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Amazon Web Services1.6K visualizações
API Gateway report por Gleicon Moraes
API Gateway reportAPI Gateway report
API Gateway report
Gleicon Moraes4.4K visualizações
Serverless Architecture por Elana Krasner
Serverless ArchitectureServerless Architecture
Serverless Architecture
Elana Krasner1.1K visualizações
Architecting ASP.NET Core Microservices Applications on AWS (WIN401) - AWS re... por Amazon Web Services
Architecting ASP.NET Core Microservices Applications on AWS (WIN401) - AWS re...Architecting ASP.NET Core Microservices Applications on AWS (WIN401) - AWS re...
Architecting ASP.NET Core Microservices Applications on AWS (WIN401) - AWS re...
Amazon Web Services4K visualizações
Deep Dive on Lambda@Edge - August 2017 AWS Online Tech Talks por Amazon Web Services
Deep Dive on Lambda@Edge - August 2017 AWS Online Tech TalksDeep Dive on Lambda@Edge - August 2017 AWS Online Tech Talks
Deep Dive on Lambda@Edge - August 2017 AWS Online Tech Talks
Amazon Web Services1.7K visualizações
Meetup callback por Wayne Scarano
Meetup callbackMeetup callback
Meetup callback
Wayne Scarano222 visualizações
Getting Started with Serverless Architectures por Amazon Web Services
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
Amazon Web Services4.3K visualizações

Último

Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... por
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...ShapeBlue
180 visualizações18 slides
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... por
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...ShapeBlue
106 visualizações12 slides
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... por
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...ShapeBlue
161 visualizações13 slides
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue por
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueShapeBlue
218 visualizações20 slides
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... por
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...ShapeBlue
184 visualizações12 slides
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... por
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...ShapeBlue
145 visualizações17 slides

Último(20)

Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... por ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue180 visualizações
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... por ShapeBlue
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
ShapeBlue106 visualizações
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... por ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue161 visualizações
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue por ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue218 visualizações
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... por ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue184 visualizações
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... por ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue145 visualizações
Future of AR - Facebook Presentation por Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty64 visualizações
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... por ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue194 visualizações
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue por ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue138 visualizações
Business Analyst Series 2023 - Week 4 Session 8 por DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10123 visualizações
Digital Personal Data Protection (DPDP) Practical Approach For CISOs por Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash158 visualizações
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... por TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc170 visualizações
"Surviving highload with Node.js", Andrii Shumada por Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays56 visualizações
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates por ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue252 visualizações
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... por ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue132 visualizações
NTGapps NTG LowCode Platform por Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu423 visualizações
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue por ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue203 visualizações
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... por ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue139 visualizações
Generative AI: Shifting the AI Landscape por Deakin University
Generative AI: Shifting the AI LandscapeGenerative AI: Shifting the AI Landscape
Generative AI: Shifting the AI Landscape
Deakin University53 visualizações

Funky serverless features at aws

  • 1. Funky Serverless Features at AWS Doug Winter - Isotoma
  • 2. Contents Real-world examples of some serverless implementation patterns, using API Gateway primarily. In particular: ■ Introduction: authentication for a serverless project for the BBC ■ Quick intro to API Gateway as a serverless toolkit ■ Example access to other serverless services using API Gateway ● S3 ● Email ● DynamoDB ■ How to practically use API Gateway yourself ■ Spotting candidates for this approach
  • 3. Me ■ Nearly 30 years professional experience ■ Dev, Ops, DevOps, Architecture, Consultancy, Strategy, Stuff ■ Ran engineering for Online Operations at the BBC in 2000/2001 ■ CTO of a dotcom during the boom (and bust) ■ Owner/Director of Isotoma since 2004 ■ Still write code, mostly Python, Go and Typescript
  • 4. Characteristics of "serverless" 1. No cost when no use, cost scales with usage 2. Provisioning decisions taken by the cloud provider 3. "Infinite" scaling capacity Not really anything to do with servers or the lack thereof, or FaaS
  • 6. IDT Cloud Introduction ■ IDT = In Depth Toolkit ¯_(ツ)_/¯ ■ BBC News journalists often need to embed charts and other visualisations in their output ■ An existing tool, IDT, provided charting services for journalists, using the previous generation of BBC News delivery infrastructure, Forge, which was PHP
  • 7. IDT Cloud Introduction ■ BBC News are moving to AWS and all services should now be delivered from with AWS services ■ This was an opportunity to entirely rewrite IDT and make it fit for purpose ■ We had (largely) complete freedom to choose implementation technologies ■ The new version is called IDT Cloud
  • 8. Particular challenges ■ BBC News audience is approx 500M people globally, in many languages, which is quite a lot ■ Must function on a wide range of devices, including some old phones and in both landscape and portrait ■ Which is hard for charts! ■ Lots of choices for how to fit charts onto small devices - but often the choices depend on the size, language and aspect ratio ■ Kind of high traffic levels sometimes
  • 9. Architecture Lots of moving parts ■ Datastore for chart origination material (JSON blobs describing charts, plus ancillary artifacts like background images) ■ Integration with other BBC News systems, including several generations of CMS ■ Editorial interface for journalists to interact with their charts ■ Rendering system to deliver charts in every output format needed
  • 11. Authentication ■ We wanted a private application for authorized BBC Users only ■ BBC Users are authorized by either: ● a) having a valid client X509 certificate in their browser, or ● b) Logging into the BBC Login single sign-on system ■ API Gateway is on the public internet ■ API Gateway can't see client certs (this sucks by the way, AWS should support X509 PKI everywhere)
  • 12. The Authentication Proxy Our solution: 1. require AWS_IAM authentication for the API, ● all requests to it must be signed 2. Send users via a proxy, running on EC2, that examines the client certificate. If it is not present it goes through the login ceremony via BBC Login 3. Authenticated users are proxied to API Gateway with signed requests
  • 13. Not actually overkill Seems like an overcomplex solution - but the proxy is entirely reusable, providing a standard way for new applications to be delivered via API Gateway with no authentication code needed.
  • 15. Common perception of API Gateway "How I get my lambda function on a URL"
  • 16. What API Gateway really is ■ URL mapping ■ Access Control and Management ■ Validation & Error Handling ■ Request & Response Transformation ■ Access to AWS backing services ■ A bunch of other useful stuff (throttling, API keys etc.)
  • 17. Core Anti-feature ■ Really, really, really, really annoying to configure and deploy. Even more than usual. ■ Can be done with CloudFormation but it is bad (even for CloudFormation) ■ Can be done with Swagger, but you will need to write some tooling ■ Supported by other tools: ● SAM ● serverless.com ● But they only provide basic functionality
  • 19. How not to do a UI
  • 24. Decoupled authentication ■ Authentication is bad ● Authenticating API requests is expensive ● For microservice-based architectures it means all services need to apply authentication, so authentication changes mean everything needs releasing ■ Instead, authenticate within API Gateway ■ Services can assume requests are authenticated ■ For bonus points, use Cognito for authentication and you can hand off almost everything
  • 26. Supported schemes Lambda Function ■ Bring your own authorizer ■ Called on each request ■ You examine the request to determine if authenticated ■ Returns: ● A principal identifier ● An IAM Policy Cognito User Pool ■ Calling client authenticates with Cognito ■ Include the JWT Token as the Authorization header
  • 27. Principals & permissions ■ The principal provided is available in the context for your integrations (we have used a custom header to deliver the principal ID) ■ Associated IAM Policies can be used to secure back-end services ■ Using the "invoke with caller credentials" option in the integration means the IAM Policies you deliver in the authorizer are used directly ■ With Cognito, users can be placed into groups and the groups provide IAM Roles, which specify the policies used ■ Together this means you can entirely outsource your authentication, authorization and user management
  • 28. Benefits ■ Federation - Cognito can federate to lots of identity providers ■ Reduced developer friction - dev environments can ignore authentication for the most part ■ Security - it is easy to screw up roll-your-own authentication ■ Robustness - This is easily one of the most error-prone parts of a codebase, so getting rid of it is a good thing ■ Agility - Apply a common authentication layer across heterogenous underlying serverless and microservices
  • 30. Static files 1. Web applications need static files a. Initial HTML page b. Javascript & CSS c. Images etc. 2. You may wish to deliver these on URLs alongside your API 3. You can do this with API Gateway
  • 31. Static files ■ Super simple use case ■ Two options for the Integration ● HTTP integration to the s3 HTTP endpoint ● Service integration to S3 "as a service" ■ Using the service integration allows us to access objects in private buckets
  • 34. S3 Blobs 1. Direct access to S3 from React etc. is a common requirement, for both reading and writing 2. We can do this entirely in API Gateway
  • 35. S3 Blobs ■ For the IDT project we need to store and retrieve configuration for charts, which are just JSON blobs ■ All authorized users can load and store all blobs, so there are no complex authorization rules ■ API Gateway can do this without the need for any Lambda
  • 38. Sending email 1. Sending Email in response to a user request means you have to constrain at least one of: a. To address b. Subject and Body 2. Or it can be used as a spam factory 3. So you can't just hand out SES Access Key and Secret to your React application (doh) 4. API Gateway to the rescue
  • 39. Simple Email Service (SES) ■ SES is ancient and has a dreadful API ■ This is mostly hidden from you because you either use: ● the SES support in the AWS SDK (which is fine), or ● the SMTP API, which is... SMTP ■ However under the hood it is seriously old skool ■ This is a good (but simple) example of how much heavy lifting API Gateway can do
  • 40. The SES API From: sender@isotoma.com To: president@whitehouse.gov Subject: Hello Mr President How are you? Content-Type: application/x-www-form-urlencoded Action=SendRawEmail&Source=sender%40isotoma.com&Destin ations.member.1=president%40whitehouse.gov&RawMessage. Data=Subject%3A+Hello+Mr+President%0A%0AHow+are+you%3F %0A' Serialised as x-www-form-urlencoded rather than JSON or XML. Also it is generally kind of confusing Here is a real example that works though:
  • 41. The API we want to provide Model schema specified in JSON schema Input is validated against this automatically Then allows us to access named parts of the input in processing
  • 42. Integration with SES Set up the integration to SES
  • 43. Transformations ■ Uses the Velocity templating language ■ Velocity is kind of terrible ■ all templating languages are terrible ■ but less terrible than writing code. generally. ■ there are loads of useful functions and it is actually pretty good ■ We use "stage variables" to store constants
  • 46. The feature IAM Policies can include conditions restricting access to DynamoDB tables to rows where the HASH key matches defined strings. We can use the authenticated user's identifier here, so restricting a user to only their rows in the database.
  • 47. How to use it 1. Use cognito 2. Add an IAM Policy like this 3. Use "invoke with caller credentials" 4. Magic "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:Query" ], "Resource": [ "table_arn" ], "Condition": { "ForAllValues:StringEquals": { "dynamodb:LeadingKeys": [ "${cognito- identity.amazonaws.com:sub}" ] } } } ] }
  • 49. Using API Gateway 1. Cloudformation does have resources to cover API Gateway (see right) 2. You really don't want to use these! 3. Swagger (OpenAPI) is better 4. BUT it has no concept of variables 5. ALSO CloudFormation tooling for Swagger is kind of lame
  • 50. Workflow 1. Mock out and test features in the console 2. Export the Swagger from the stage 3. Replace hard coded literals with variables 4. Extend the Swagger to cover your whole API 5. Write something to do configuration management for you 6. Put the file in an S3 bucket 7. Run CloudFormation 8. Write something to update the API by calling the API Gateway API
  • 54. Is this even a good idea? I think these techniques deliver benefits: 1. Less code 2. Outsource and commoditise 3. Design "with the grain" of the underlying services 4. Enforce simplicity 5. Actual API-first design But they can be challenging to exploit
  • 55. Spotting candidates ■ Application code is generally "get a request, do some stuff, access some backing services, return a response" ■ Only a subset can be implemented entirely in API Gateway: ● No loops ● Single input and single output transformation
  • 56. The challenge ■ Few developers have an in depth knowledge of more than a couple of AWS services ■ All of the examples I've shown here can instead be implemented in custom code ■ Organizationally it might be easier to implement in custom code... ■ ...even if the product is worse ■ And the tooling is, at best, patchy
  • 57. Handling change ■ Replacing these things with Lambda calls is easy ■ Your API remains stable ■ So stubbing out an API early on with simple S3 access etc. can be a good way to get moving ■ Don't worry if you will later need more complexity
  • 59. October 17, 2018 Thank You Supporters
  • 60. October 17, 2018 Meet me in the Slack channel for Q&A bit.ly/addo-slack