"速習サーバーレス" 的なハンズオンです。 ソースコードはこちら → https://github.com/ketancho/aws-serverless-quick-start-hands-on
■ 2020/02/19 JAWS−UG 初心者支部 #24 ■ 2020/04/28 JAWS-UG 初心者支部&千葉支部 #26 にて実施しています。資料だけでもハンズオンはご実施いただけますが、登壇させていただくことも可能ですので @ketancho までお声がけください:)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.$' # (" %!'51+8Solutions Architect<7 / / Kei Kanazawa / @ketancho[2020/04/26 JAWS−UG ,294;=.:4;]( (&(>3-0( (& )6pdf http://bit.ly/serverless-quick-startsrc http://bit.ly/serverless-quick-start-src#jawsug_bgnr #jawsugchiba * !
View Slide
© 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
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ 90 ! § % ' &$§ Next Action #!" !
© 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\qYAJ6C8*#J.H3?E+G)9A418H3?J+F07D42;5,*§ " Am\qYA! E)(A>4J/%,6C8§ Chrome or Firefox >h_qXjp^Tp\qn@MR[Y6=2;5,§ Python eoSliATcq&gqY^@B)Np]p^$I@4 2;5,
© 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
© 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
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.M 3;( -A >?C _@JX`!!4:&/Q8=#=293;-,='ZY39\SPV+$-8=#=+$-FRL^=+ )6ZY"=0=%*-*35.:ZHK N]WET"=0=G %79+1*)IPV[D _%79+1*)IB__\SUOI@`!
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.“ ” “ ”
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.“ ”
© 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
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS Compute L L
© 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/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS Lambda "2% '&Lambda Function ”Hello World” !(&Lambda Function Amazon Translate $')AWS Lambda → #AWSLambdaAmazonTranslate✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS Lambda "2% '&Lambda Function ”Hello World” ! !(&Lambda Function Amazon Translate $')AWS Lambda → #AWSLambda✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ : § : !: IAM & ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ lambda Lambda : AWS Lambda ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ !$ ( *")& “( ” ' #% ! +,: Lambda Function ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ OK : Lambda Function § : translate-function§ : Python 3.8§ ✋
© 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✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ ,: Lambda Function !&!& event # %*($" ')+✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ [,5!]”$$#%” ' AWS % /*4event 20 !#%=> “Hello World” § $. Test )+§ -& (3 $"$$7: Lambda Function 16✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “Amazon API Gateway AWS Proxy”
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ § " !#: Lambda Function !✋
© 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 LambdaAWSLambdaAmazonTranslate✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ Lambda Function %! $ § " &IAM %#' (: Lambda Function IAM ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ : Lambda Function IAM ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ "%$ translate TranslateFullAccess ! § &: Lambda Function IAM #✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ Lambda !§ § " #$: Lambda Function ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.1: Lambda Function !&import jsonimport boto3def 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.htmlhttps://github.com/ketancho/aws-serverless-quick-start-hands-on/blob/master/src/translate-function.py✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ ! > § ()'% OK !input_text # $,!"+-* ".: Lambda Function &✋
© 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
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Amazon APIGatewayAmazonDynamoDBAmazon SQS(Amazon Simple Queue Service)AWSStep FunctionsAmazon S3(Amazon Simple Storage Service)AmazonCloudWatchAWS X-RayAWSLambda
© 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 43KAmazon API Gateway =6J1DKBlackBelt %): Amazon API Gatewayhttps://d1.awsstatic.com/webinars/jp/pdf/services/20190514_AWS-Blackbelt_APIGateway.pdf
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.Amazon API Gateway AWS Lambda # Web API $%!" Web API AWSLambdaAmazonTranslateAmazonAPI GatewayGET /translate?input_text={‘output_text’: ‘Hello’}✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.#: Lambda Function import jsonimport boto3def 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✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ ”Amazon API Gateway” ,2 0-$ > */. api ! > API Gateway 1&§ )# API (" API % ' 3(+45: API Gateway - API %✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ &REST API $% § “#! API "” OK ': API Gateway - API "✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ REST API § API translate-api API : API Gateway - API ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ > : API Gateway - ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ “ ” translate : API Gateway - ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ /translate > : API Gateway - ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ “/translate” § GET ✓ : API Gateway - ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ “Lambda ” ✓ “Lambda !” translate-function ": API Gateway - ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ “Lambda ” OK : API Gateway - ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ API : API Gateway - ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ "$ %#! dev &: API Gateway - ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ ! % #$&% %" > dev '(: API Gateway - ✋
© 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 - %)+✋
© 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
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ 3 !( )"2 § 2019%11+*-1$'§ #3 !(04!(*-1,$'5Amazon Transcribe .&4/5AWS Black Belt Seminar: Amazon AI Servicehttps://aws.amazon.com/jp/blogs/news/webinar-bb-ai-service-2019/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS Lambda Amazon Transcribe "! #$! AWSLambdaAmazonTranscribe ..%✋
© 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<4Amazon Simple Storage Service (Amazon S3) C8M2ENAWS Black Belt Seminar: Amazon S3/Glacierhttps://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
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS Lambda Amazon Transcribe AWSLambdaAmazonTranscribeAmazonS3AmazonS3♪✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ Input Output 2 S3 § “” > “S3” > “S3” : S3 ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ : S3 ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ ! yyyymmdd-transcribe-input-yourname * !$"% § # &: S3 #✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ 2 § yyyymmdd-transcribe-output-yourname § : S3 ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ AWS Lambda : > lambda > Lambda § : Lambda Function ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ > S3 Enter§ s3-get-object-python : Lambda Function ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ Function : transcribe-function, Role : transcribe-function-role : Lambda Function ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ S3 ! input " #: Lambda Function ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ ✓§ : Lambda Function ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ IAM S3 / Transcribe '%" $ § Lambda Function & #( § ): Lambda Function !✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ : Lambda Function ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ #&% S3 ! > AmazonS3FullAccess ✓' (§ #&% transcribe ! > AmazonTranscribeFullAccess ✓§ 2$ ): Lambda Function "✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ $§ “"(” ! “&” § #%' ): Lambda Function ✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.▼ !" Output #: Lambda Function import jsonimport urllib.parseimport boto3import datetimes3 = 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 asthis function.'.format(key, bucket))raise ehttps://github.com/ketancho/aws-serverless-quick-start-hands-on/blob/master/src/transcribe-function.py✋
© 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+: $&✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ S3 mp3 ! "$Input % S3 "$ § ! ,' & DL mp3 ! *("$##-: # )+✋
© 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: !#(,✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ Job Status In progress Complete Complete Name : ↓✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ Output data location : ✋
© 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 isnever enough.” 50: 4.!"**?: #%&* 172<
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS Lambda Amazon Transcribe !" AWSLambdaAmazonTranscribeAmazonS3AmazonS3♪
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS Lambda Amazon Transcribe ! + %’#"$& + AWSLambdaAmazonTranscribeAmazonS3AmazonS3AWSLambdaAmazonTranslate♪✋
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.Option 1:$((A9; Web API +3 Web API 9;08?**@Amazon DynamoDB ") # ,7Option 2:$((B5/< %&'(+3%&'( Amazon Comprehend =4 !# 21-6 :$(( +αOption .>
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Hands-on for Beginners !-/ / - / - . / -. / +α
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ 90 # § '" ) (&§ Next Action %#$ !!
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ : S3 x 2
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ * %# -*0(*%# )1*,& § $ " * § * + !.'/!.'/: S3 !. x 2
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ § : S3 x 2
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ API ✓ Actions > Delete§ : API Gateway
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ > § : Lambda Function x 2
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ ✓ § : IAM x 2
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.§ Job Name Delete § Delete : Transcribe Job
© 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 * !