Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using Serverless to Build Servicefull Applications

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Using Serverless to Build Servicefull Applications

Avatar for Matt Weagle

Matt Weagle

June 27, 2018

Other Decks in Technology

Transcript

  1. 11 Characteristics of High Performing Teams Loosely coupled systems Experimentation

    & adjustment WIP limits with shared visualization & feedback loops Frequent deployments, short-lived branches Security best handled by shifting left
  2. 12 Accelerate Forsgren, Humble, & Kim “Software delivery performance predicts

    organizational performance and noncommercial performance.”
  3. Even a small number of services requires an ongoing operational

    resource commitment that must scale sublinearly. Minimum Expected Commitment
  4. 16 Concerns for a Single Service Concerns for a Single

    Service - Sean Treadway Service name, Programming language(s), Programming paradigm(s), Architectural choices, Integration pattern(s), Transport protocols, Authentication, Authorization, Reporting, ETLs, Databases, Caching, Platform libraries, Service dependencies, CI pipeline dependencies, 3rd party library dependencies, 3rd party service dependencies, Security threat model, License audit, Compliance audit, Capacity plan, Provisioning plan, Cost reporting plan, Monitoring plan, Maintenance process, Backup and restore process, Secret management, Secret rotation, On-call schedule, Configuration management, Workflow management, Alerts, Log aggregation, Unhandled failure aggregation, Operations and incident response runbooks, API documentation, Source code repository, Humane service registry, Service discovery registry, Distributed tracing registry, Monitoring dashboard registry, Build artifact repository, CI pipeline(s): build, test, publish, Integration tests, Contract tests, Canary, Deploy, Post-deploy tests
  5. X-Ray CloudWatch Polly SSM Bucket Website Comprehend Presigned S3 URL

    Rekognition API Gateway 1 4 3 2 Architecture
  6. Define Lambda Function func (gws *ServicefulService) s3GetPresignedURLLambda(ctx context.Context, apigRequest spartaEvents.APIGatewayRequest)

    (*presignedResponse, error) { objectPath := fmt.Sprintf("%s/%s", gws.connections.S3KeyspaceUploads, lambdaContext.AwsRequestID) putObjectInput := &s3.PutObjectInput{ Bucket: aws.String(s3Resource.ResourceRef), Key: aws.String(objectPath), } presignedReq, _ := s3svc.PutObjectRequest(putObjectInput) url, err := presignedReq.Presign(5 * time.Minute) if nil != err { return nil, err } return &presignedResponse{ PresignedURL: url, }, nil }
  7. Define Lambda Options func (gws *ServicefulService) newS3PresignedPutItemLambda(api *sparta.API) *sparta.LambdaAWSInfo {

    // Register lambdaFn := sparta.HandleAWSLambda("PresignedURLProvider", gws.s3GetPresignedURLLambda, sparta.IAMRoleDefinition{}) // IAM lambdaFn.RoleDefinition.Privileges = gws.bucketGetPutPrivileges() // X-Ray lambdaFn.Options.TracingConfig = &gocf.LambdaFunctionTracingConfig{ Mode: gocf.String("Active"), } // API Gateway apiMethod, apiMethodErr := apiGatewayResource.NewMethod("GET", http.StatusOK, http.StatusInternalServerError) … }
  8. Define Lambda Triggers // IAM Role privileges lambdaFn.RoleDefinition.Privileges = gws.bucketGetPutPrivileges("polly:SynthesizeSpeech")

    // Event Triggers lambdaFn.Permissions = append(lambdaFn.Permissions, gws.s3NotificationPrefixBasedPermission(gws.connections.S3KeyPrefix))
  9. Define Service lambdaFunctions := service.New(connections, apiGateway) stackName := spartaCF.UserScopedStackName("SpartaGeekwire") sparta.MainEx(stackName,

    fmt.Sprintf("GeekWire service combines S3 with multiple AWS Services"), lambdaFunctions, apiGateway, s3Site, workflowHooks(connections, lambdaFunctions), false)
  10. $ gocloc . ------------------------------------------------------------------------------- Language files blank comment code -------------------------------------------------------------------------------

    JSON 4 0 0 11797 JavaScript 17 338 619 1247 Go 8 102 181 747 YAML 2 50 1 141 HTML 1 0 0 95 Markdown 23 19 0 70 Makefile 1 11 0 25 CSS 5 9 42 4 BASH 1 1 0 3 Sass 1 0 0 1 ------------------------------------------------------------------------------- TOTAL 63 530 843 14130 ------------------------------------------------------------------------------- https://github.com/hhatto/gocloc Statistics