Slide 1

Slide 1 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. $' # (" %!'51+8 Solutions Architect <7 / / Kei Kanazawa / @ketancho [2020/04/26 JAWS−UG ,294;=.:4;] ( (&(> 3-0( (& )6 pdf http://bit.ly/serverless-quick-start src http://bit.ly/serverless-quick-start-src #jawsug_bgnr #jawsugchiba * !

Slide 2

Slide 2 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. =2;+ ❏ .- @9 / Kei Kanazawa ❏ &)% %$")#') ❏ <8 (17, 5?*65?!&A:' (AWS 3>40 ❏ 0AWS) AWS Lambda @ketancho

Slide 3

Slide 3 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § 90 ! § % ' &$ § Next Action # ! " !

Slide 4

Slide 4 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § `pZPpA AWS MQOp^J/<>+H3? § `pZPp>'- AWS UqbYA&A+H IAM kqVq>oSNp6=2;5, § `pZPp>B AWS AUqbYA)m\qYAJ 6C8* #J.H3?E+G)9A418H3?J+F07D42;5,* § " Am\qYA! E)(A>4 J/%,6C8 § Chrome or Firefox >h_qXjp^Tp\qn@MR[Y6=2;5, § Python eoSliATcq&gqY^@B)Np]p^$I@4 2;5,

Slide 5

Slide 5 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. .- " “##!” %9%' 9 ""6: AWS Lambda -→314 ""7: 14 Web API & ""8: +(5 + 14 "& “$* )0,/” 2

Slide 6

Slide 6 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. .- " “##!” %9%' 9 ! ""6: AWS Lambda -→314 ""7: 14 Web API & ""8: +(5 + 14 "& “$* )0,/” 2

Slide 7

Slide 7 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. M 3;( -A >?C _ @ JX`! ! 4:&/Q 8=#= 29

Slide 8

Slide 8 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “ ” “ ”

Slide 9

Slide 9 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “ ”

Slide 10

Slide 10 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. .- " “##!” %9%' 9 ""6: AWS Lambda -→314 ! ""7: 14 Web API & ""8: +(5 + 14 "& “$* )0,/” 2

Slide 11

Slide 11 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 12

Slide 12 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. .- " “##!” %9%' 9 ""6: AWS Lambda -→314 ! ""7: 14 Web API & ""8: +(5 + 14 "& “$* )0,/” 2

Slide 13

Slide 13 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Compute L L

Slide 14

Slide 14 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § '' %"&/75 %#!-; ' § '-; 3+'$& Lambda *-1 =6: 0 '2 >( § /<)8 $ ' AWS Lambda 4. ?,9@AWS Lambda /< https://aws.amazon.com/jp/lambda/pricing/

Slide 15

Slide 15 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda "2% '&Lambda Function ”Hello World” ! (&Lambda Function Amazon Translate $ ')AWS Lambda → # AWS Lambda Amazon Translate ✋

Slide 16

Slide 16 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda "2% '&Lambda Function ”Hello World” ! ! (&Lambda Function Amazon Translate $ ')AWS Lambda → # AWS Lambda ✋

Slide 17

Slide 17 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § : § : !: IAM & ✋

Slide 18

Slide 18 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § lambda Lambda : AWS Lambda ✋

Slide 19

Slide 19 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § !$ ( *")& “( ” ' #% ! + ,: Lambda Function ✋

Slide 20

Slide 20 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § OK : Lambda Function § : translate-function § : Python 3.8 § ✋

Slide 21

Slide 21 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § 1($ &&8 § 776 ‘Hello from Lambda!’ )9* -5 § .' ,0 !%";/4 ,02 :!< %%=: Lambda Function +3 ✋

Slide 22

Slide 22 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § ,: Lambda Function !& !& event # % *($" ')+ ✋

Slide 23

Slide 23 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § [,5!] ”$$#%” ' AWS % /*4 event 20 !#% => “Hello World” § $. Test )+ § -& (3 $" $$7: Lambda Function 16 ✋

Slide 24

Slide 24 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “Amazon API Gateway AWS Proxy”

Slide 25

Slide 25 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § § " ! #: Lambda Function ! ✋

Slide 26

Slide 26 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda 2 "!Lambda Function ”Hello World” #!Lambda Function Amazon Translate ! "$Hello World on AWS Lambda AWS Lambda Amazon Translate ✋

Slide 27

Slide 27 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § Lambda Function %! $ § " &IAM %#' (: Lambda Function IAM ✋

Slide 28

Slide 28 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § : Lambda Function IAM ✋

Slide 29

Slide 29 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § "%$ translate TranslateFullAccess ! § &: Lambda Function IAM # ✋

Slide 30

Slide 30 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § Lambda ! § § " # $: Lambda Function ✋

Slide 31

Slide 31 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 1: Lambda Function !& import json import boto3 def lambda_handler(event, context): translate = boto3.client('translate') input_text = '/,2' response = translate.translate_text( Text=input_text, SourceLanguageCode='ja', TargetLanguageCode='en' ) output_text = response['TranslatedText'] return { 'statusCode': 200, 'body': json.dumps({ 'output_text': output_text }) } § AWS SDK for Python (boto3) #' § “AWS SDK Python” %) " + .(- $*0boto 3 https://boto3.amazonaws.com/v1/documentation/api/ latest/reference/services/index.html https://github.com/ketancho/aws-serverless-quick-start-hands- on/blob/master/src/translate-function.py ✋

Slide 32

Slide 32 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § ! > § ()'% OK ! input_text # $,!"+-* " .: Lambda Function & ✋

Slide 33

Slide 33 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 34

Slide 34 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. .- " “##!” %9%' 9 ""6: AWS Lambda -→314 ""7: 14 Web API & ! ""8: +(5 + 14 "& “$* )0,/” 2

Slide 35

Slide 35 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Amazon API Gateway Amazon DynamoDB Amazon SQS (Amazon Simple Queue Service) AWS Step Functions Amazon S3 (Amazon Simple Storage Service) Amazon CloudWatch AWS X-Ray AWS Lambda

Slide 36

Slide 36 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ● )) !& $'A> API -9(A> #)) ● 2?8 :.)%' API A>7F API Gateway + H@E 5/0C-<I* ● ;G,B%") J REST API 43K Amazon API Gateway =6 J1DKBlackBelt %): Amazon API Gateway https://d1.awsstatic.com/webinars/jp/pdf/services/2019051 4_AWS-Blackbelt_APIGateway.pdf

Slide 37

Slide 37 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway AWS Lambda # Web API $%!" Web API AWS Lambda Amazon Translate Amazon API Gateway GET /translate?input_text= { ‘output_text’: ‘Hello’ } ✋

Slide 38

Slide 38 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. #: Lambda Function import json import boto3 def lambda_handler(event, context): translate = boto3.client('translate') input_text = event['queryStringParameters']['input_text'] response = translate.translate_text( Text=input_text, SourceLanguageCode="ja", TargetLanguageCode="en" ) ... § input_text " API Gateway ! > https://github.com/ketancho/aws-serverless-quick-start-hands- on/blob/master/src/translate-function-with-apigw.py ✋

Slide 39

Slide 39 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § ”Amazon API Gateway” ,2 0- $ > */. api ! > API Gateway 1& § )# API (" API % ' 3(+4 5: API Gateway - API % ✋

Slide 40

Slide 40 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § &REST API $% § “#! API "” OK ': API Gateway - API " ✋

Slide 41

Slide 41 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § REST API § API translate-api API : API Gateway - API ✋

Slide 42

Slide 42 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § > : API Gateway - ✋

Slide 43

Slide 43 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § “ ” translate : API Gateway - ✋

Slide 44

Slide 44 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § /translate > : API Gateway - ✋

Slide 45

Slide 45 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § “/translate” § GET ✓ : API Gateway - ✋

Slide 46

Slide 46 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § “Lambda ” ✓ “Lambda !” translate-function ": API Gateway - ✋

Slide 47

Slide 47 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § “Lambda ” OK : API Gateway - ✋

Slide 48

Slide 48 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § API : API Gateway - ✋

Slide 49

Slide 49 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § " $ %#! dev &: API Gateway - ✋

Slide 50

Slide 50 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § ! % #$ &% %" > dev ' (: API Gateway - ✋

Slide 51

Slide 51 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § URL 87 "'- > (* #>/ § URL 6/translate?input_text=1API20 § := Web API 57 !!! URL .9@4<;3? " &,$!,A: API Gateway - %)+ ✋

Slide 52

Slide 52 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 53

Slide 53 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. .- " “##!” %9%' 9 ""6: AWS Lambda -→314 ""7: 14 Web API & ""8: +(5 + 14 "& ! “$* )0,/” 2

Slide 54

Slide 54 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § 3 !( )"2 § 2019%11+*-1$' § #3 !(0 4!( *-1,$'5 Amazon Transcribe .& 4/5AWS Black Belt Seminar: Amazon AI Service https://aws.amazon.com/jp/blogs/news/webinar-bb-ai-service-2019/

Slide 55

Slide 55 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda Amazon Transcribe "! #$ ! AWS Lambda Amazon Transcribe ..% ✋

Slide 56

Slide 56 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Amazon API Gateway Amazon DynamoDB Amazon SQS (Amazon Simple Queue Service) AWS Step Functions Amazon S3 (Amazon Simple Storage Service) Amazon CloudWatch AWS X-Ray AWS Lambda

Slide 57

Slide 57 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § LF.9 : &""+--$ § 99.999999999% M+&,#,N § @A7 3 '($)! -,MAZN>D § 6HB1J50 "+- § ? AWS -$G; § /: %*>D")-K3= Lambda I<4 Amazon Simple Storage Service (Amazon S3) C8 M2ENAWS Black Belt Seminar: Amazon S3/Glacier https://aws.amazon.com/jp/blogs/news/webinar-bb-amazon-s3-glacier-2019/ M2EN'($)!- -, https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/using-regions- availability-zones.html

Slide 58

Slide 58 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda Amazon Transcribe AWS Lambda Amazon Transcribe Amazon S3 Amazon S3 ♪ ✋

Slide 59

Slide 59 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § Input Output 2 S3 § “ ” > “S3” > “S3” : S3 ✋

Slide 60

Slide 60 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § : S3 ✋

Slide 61

Slide 61 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § ! yyyymmdd-transcribe-input-yourname * !$"% § # &: S3 # ✋

Slide 62

Slide 62 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § 2 § yyyymmdd-transcribe-output-yourname § : S3 ✋

Slide 63

Slide 63 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § AWS Lambda : > lambda > Lambda § : Lambda Function ✋

Slide 64

Slide 64 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § > S3 Enter § s3-get-object-python : Lambda Function ✋

Slide 65

Slide 65 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § Function : transcribe-function, Role : transcribe-function-role : Lambda Function ✋

Slide 66

Slide 66 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § S3 ! input " #: Lambda Function ✋

Slide 67

Slide 67 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § ✓ § : Lambda Function ✋

Slide 68

Slide 68 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § IAM S3 / Transcribe '%" $ § Lambda Function & #( § ): Lambda Function ! ✋

Slide 69

Slide 69 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § : Lambda Function ✋

Slide 70

Slide 70 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § #&% S3 ! > AmazonS3FullAccess ✓' ( § #&% transcribe ! > AmazonTranscribeFullAccess ✓ § 2$ ): Lambda Function " ✋

Slide 71

Slide 71 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § $ § “"(” ! “&” § #%' ): Lambda Function ✋

Slide 72

Slide 72 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ▼ !" Output #: Lambda Function import json import urllib.parse import boto3 import datetime s3 = boto3.client('s3') transcribe = boto3.client('transcribe') def lambda_handler(event, context): bucket = event['Records'][0]['s3']['bucket']['name'] key = urllib.parse.unquote_plus(event['Records'][0]['s3']['object']['key'], encoding='utf-8') try: transcribe.start_transcription_job( TranscriptionJobName= datetime.datetime.now().strftime("%Y%m%d%H%M%S") + '_Transcription', LanguageCode='en-US', Media={ 'MediaFileUri': 's3://' + bucket + '/' + key }, OutputBucketName='yyyymmdd-transcribe-output-yourname' ) except Exception as e: print(e) print('Error getting object {} from bucket {}. Make sure they exist and your bucket is in the same region as this function.'.format(key, bucket)) raise e https://github.com/ketancho/aws-serverless-quick-start- hands-on/blob/master/src/transcribe-function.py ✋

Slide 73

Slide 73 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § : Lambda Function ✋

Slide 74

Slide 74 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § (" ' URL)Amazon Polly * ! # or DL % https://d1.awsstatic.com/product-marketing/Polly/HelloEnglish- Joanna.0aa7a6dc7f1de9ac48769f366c6f447f9051db57.mp3 +: $& ✋

Slide 75

Slide 75 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § S3 mp3 ! "$ Input % S3 "$ § ! ,' & DL mp3 ! *("$ ##-: # )+ ✋

Slide 76

Slide 76 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § $ > transcribe &' > Amazon Transcribe 2* § Transcription Jobs -3 1/4Transcribe 0. 5+ )% #$$ $ " > Transcription jobs " ##6: !# (, ✋

Slide 77

Slide 77 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § Job Status In progress Complete Complete Name : ↓ ✋

Slide 78

Slide 78 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § Output data location : ✋

Slide 79

Slide 79 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § *)+! '- $(; § Json $(, results > transcripts > transcript 89=3/6> “transcript”: “Hello. Do you speak a foreign language? One language is never enough.” 50: 4. ! "**?: #%&* 17 2<

Slide 80

Slide 80 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda Amazon Transcribe !" AWS Lambda Amazon Transcribe Amazon S3 Amazon S3 ♪

Slide 81

Slide 81 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda Amazon Transcribe ! + %’#"$& + AWS Lambda Amazon Transcribe Amazon S3 Amazon S3 AWS Lambda Amazon Translate ♪ ✋

Slide 82

Slide 82 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Option 1: $((A9; Web API +3 Web API 9;08?**@ Amazon DynamoDB ") # ,7 Option 2: $((B5/< %&'(+3 %&'( Amazon Comprehend =4 !# 21-6 : $(( +α Option .>

Slide 83

Slide 83 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Hands-on for Beginners ! -/ / - / - . / - . / +α

Slide 84

Slide 84 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § 90 # § '" ) (& § Next Action % # $ ! !

Slide 85

Slide 85 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § : S3 x 2

Slide 86

Slide 86 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § * %# -*0(*%# )1 *,& § $ " * § * + !.'/ !.'/: S3 !. x 2

Slide 87

Slide 87 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § § : S3 x 2

Slide 88

Slide 88 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § API ✓ Actions > Delete § : API Gateway

Slide 89

Slide 89 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § > § : Lambda Function x 2

Slide 90

Slide 90 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § ✓ § : IAM x 2

Slide 91

Slide 91 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § Job Name Delete § Delete : Transcribe Job

Slide 92

Slide 92 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. .- § “((&” /4 #%15 § '' “37 Web API” “,+8 "$'” 02 § ''9 )6(!/4 § AWS Lambda § Amazon API Gateway § Amazon S3 § Amazon Translate, Amazon Transcribe § AWS Hands-on for Beginners * !

Slide 93

Slide 93 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. § 90 # § '" ) (& § Next Action % # $ ! !

Slide 94

Slide 94 text

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.