Programming the Cloud: Empowering Developers to Do Infrastructure - - PowerPoint PPT Presentation

programming the cloud
SMART_READER_LITE
LIVE PREVIEW

Programming the Cloud: Empowering Developers to Do Infrastructure - - PowerPoint PPT Presentation

Programming the Cloud: Empowering Developers to Do Infrastructure Luke Hoban QCON San Francisco November 11th, 2019 Why do I care about this? An Analogy Whats missing? Variables Loops Functions Abstraction Standard


slide-1
SLIDE 1

Programming the Cloud:

Empowering Developers to Do Infrastructure

Luke Hoban

QCON San Francisco November 11th, 2019

slide-2
SLIDE 2

Why do I care about this?

slide-3
SLIDE 3

An Analogy

What’s missing?

  • Variables
  • Loops
  • Functions
  • Abstraction
  • Standard Library
  • Types
slide-4
SLIDE 4

Software Engineering Desiderata

Application Frameworks High-Level Languages Type Checking IDEs Unit Testing Rapid Iteration Debugging CI/CD Source Control Package Management Componentization Integration Testing

slide-5
SLIDE 5

Infrastructure as Code

slide-6
SLIDE 6
slide-7
SLIDE 7

Infrastructure as Code Text

slide-8
SLIDE 8

Demo

Infrastructure as Code for Developers

slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12

Process Models

12

web server cloud Page Transient Script tags Stateless Process Finite lifetime ELF binaries Largely stateless Stack Lives “forever” Desired State Fundamentally Stateful

slide-13
SLIDE 13

Application vs. Infrastructure

slide-14
SLIDE 14

Application + Infrastructure

Desired State:

  • There is a Fargate Task
  • It has 512MB memory reservation
  • It is running the Docker image built from ./docker-ffmpeg-thumb
slide-15
SLIDE 15

Application + Infrastructure

slide-16
SLIDE 16

Demo

Unifying Application and Infrastructure

slide-17
SLIDE 17

Cloud Native

EKS

Transition to Cloud Native

Pre-Cloud

Lambda S3 API Gateway Aurora MySQL DataDog Docker PM2 DataDog CloudWatch

slide-18
SLIDE 18

Programming Architecture Diagrams

slide-19
SLIDE 19

Demo

Programming Architecture Diagrams

slide-20
SLIDE 20

Architecture as Code

slide-21
SLIDE 21
slide-22
SLIDE 22

Demo

Building a Cloud App in 90 Seconds

slide-23
SLIDE 23

The Future?

Frameworks on top of cloud provider building blocks Unifying application and infrastructure A process model native to the cloud Rapidly develop directly in the cloud “Every Developer Is a Cloud Developer”

slide-24
SLIDE 24

@lukehoban lukehoban

Thanks!

Program the Cloud

slide-25
SLIDE 25

An Analogy

What’s missing?

  • Variables
  • Loops
  • Functions
  • Abstraction
  • C Standard Library
  • Types
slide-26
SLIDE 26

Infrastructure as Code

AWSTemplateFormatVersion: '2010-09-09' Description: Slack Bot Parameters: BotName: Type: String SlackToken: Type: String WitAIToken: Type: String Outputs: Url: Value: !Sub https://${api}.execute-api.${AWS::Region}.amazonaws.com/${stage} Resources: lambdaRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement:

  • Effect: Allow

Principal: Service: lambda.amazonaws.com Action: "sts:AssumeRole" Path: / ManagedPolicyArns:

  • "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"

Policies:

  • PolicyName: lambda

PolicyDocument: Version: '2012-10-17' Statement: Effect: Allow Action:

  • 'lambda:ListFunctions'
  • 'lambda:InvokeFunction'

Resource: '*' botLambda: Type: "AWS::Lambda::Function" Properties: FunctionName: !Ref BotName Handler: index.handler Runtime: nodejs4.3 Role: !GetAtt [ lambdaRole, Arn ] Timeout: 300 Environment: Variables: SLACKTOKEN: !Ref SlackToken WITAITOKEN: !Ref WitAIToken Code: ZipFile: | 'use strict'; const AWS = require('aws-sdk'); const https = require('https'); const url = require('url'); const qs = require('querystring'); const AWS_REGION = process.env.AWS_REGION; const AWS_LAMBDA_FUNCTION_NAME = process.env.AWS_LAMBDA_FUNCTION_NAME; const slackToken = process.env.SLACKTOKEN; const witaiToken = process.env.WITAITOKEN; const lambda = new AWS.Lambda(); exports.handler = (event, context, callback) => { const account_id = context.invokedFunctionArn.split(":")[4]; return processEvent(event, account_id) .then(res => callback(null, formatResponse("200", JSON.stringify({response_type: "in_channel", text: res })))) .catch(err => callback(null, formatResponse("400", err.message || err))) ; }; function processEvent(event, account_id) { // Code for bot command goes here helpLambda: Type: "AWS::Lambda::Function" Properties: FunctionName: !Sub ${BotName}-help Handler: index.handler Runtime: nodejs4.3 Role: !GetAtt [ lambdaRole, Arn ] Timeout: 300 Code: ZipFile: | // Code for bot help goes here botLambdaPermission: Type: "AWS::Lambda::Permission" Properties: Action: "lambda:InvokeFunction" FunctionName: !GetAtt [ botLambda, Arn ] Principal: "apigateway.amazonaws.com" SourceArn: !Sub "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${api}/*" helpLambdaPermission: Type: "AWS::Lambda::Permission" arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${lambdaArn}/invocations

  • lambdaArn: !GetAtt helpLambda.Arn

SourceArn: !Sub "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${api}/*" DependsOn: helpLambdaPermission api: Type: "AWS::ApiGateway::RestApi" Properties: Name: !Ref BotName anyMethod: Type: "AWS::ApiGateway::Method" Properties: AuthorizationType: NONE HttpMethod: ANY RestApiId: !Ref api ResourceId: !GetAtt api.RootResourceId MethodResponses:

  • StatusCode: 200

Integration: Type: AWS_PROXY IntegrationHttpMethod: POST PassthroughBehavior: WHEN_NO_TEMPLATES Uri: !Sub

  • arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-

31/functions/${lambdaArn}/invocations

  • lambdaArn: !GetAtt botLambda.Arn

DependsOn: botLambdaPermission deployment: Type: "AWS::ApiGateway::Deployment" Properties: RestApiId: !Ref api StageName: DummyStage DependsOn: anyMethod stage: Type: "AWS::ApiGateway::Stage" Properties: RestApiId: !Ref api StageName: bot DeploymentId: !Ref deployment

slide-27
SLIDE 27

Other Similar Approaches

slide-28
SLIDE 28

Programming the Cloud

Continue the march of JavaScript from Browser to Server to Cloud Apply Software Engineering to Cloud Infrastructure Work at the right level of abstraction - raw infra or “architecture diagram” Bridge the gap between App and Infra A different kind of application model - “stacks” instead of processes

slide-29
SLIDE 29

Backup

slide-30
SLIDE 30

Software Engineering Desiderata

Application Frameworks High-Level Languages Type Checking IDEs Unit Testing Rapid Iteration Debugging CI/CD Source Control Package Management Componentization Integration Testing