初めてのサーバーレスアプリケーション開発 ~Serverless Framework を使ってAWSリソースをデプロイする~
以前のエントリでは、GUIで簡単なサーバーレスアプリケーションを構築する方法を学びました。
- 初めてのサーバーレスアプリケーション開発 ~DynamoDBにテーブルを作成する~
- 初めてのサーバーレスアプリケーション開発 ~LambdaでDynamoDBの値を取得する~
- 初めてのサーバーレスアプリケーション開発 ~API GatewayからLambdaを呼び出す~
GUIで入力内容を確認しながらリソースを作成しサービスに対する理解を深めることは重要なことです。ですが、実際の開発でGUIをポチポチするのはちょっと面倒ですよね。
ということで今回は、以前GUIで作成したAWSの各リソースをServerless Frameworkを使って一撃構築してみようと思います。また、次のブログではServerless FrameworkとAWSのCodeシリーズと連携させ、コード管理、デプロイ周りの自動化を実現していきたいと思います。
- 初めてのサーバーレスアプリケーション開発 ~Serverless Framework を使ってAWSリソースをデプロイする~
- 初めてのサーバーレスアプリケーション開発 ~Serverless Framework と Codeシリーズを連携させる~
対象読者
- サーバーレスアプリケーション開発未経験の方
- サーバーレスに縁のないインフラエンジニアの方
本記事を実践して、Serverless Frameworkと仲良くなりましょう!!
それでは本題に入っていきます。
サーバーレスアプリケーション超入門
今回構築するアプリケーションの全体構成はこちら。
「クライアントからリクエストを受けて、DynamoDBの情報を返却する」簡単なアプリケーションを作成します。開発端末からServerless Frameworkのコマンドを実行することでAWS上のリソース(アプリケーション)をデプロイします。
Serverless Framework
Serverless Frameworkとは何なのか。公式ドキュメントよりserverless frameworkの概要を抜粋します。
The Serverless Framework is a CLI tool that allows users to build & deploy auto-scaling, pay-per-execution, event-driven functions.
Write your code, configure events to trigger your functions, then deploy & run those functions to your cloud provider via the Serverless CLI.
Serverless Frameworkの特徴
- Node.jsを利用したフレームワーク
- 自身で開発したファンクション、イベントをCLIを使って簡単にデプロイすることができる
- AWS、Azure、GCPなど様々なプラットフォームに対してファンクションをデプロイすることができる
AWSをプラットフォームとした場合の挙動
- ローカル環境でデプロイ対象となるLambdaファンクションやファンクションを実行するためのイベント(トリガー)、AWSのリソース等を定義
- ローカル環境でデプロイコマンドを実行することで、AWS上でCloudFormationを実行し各種リソースを作成
Serverless Frameworkを利用すればローカルで開発したファンクションを簡単にAWS上にデプロイすることができます。
主要なコンポーネント
Serverless Frameworkの5つの主要なコンポーネントについても確認しておきましょう。
Service
Serverless Frameworkとして複数のリソースを管理するための単位です。このサービス内に以下の4つのコンポーネントを含めserverless.ymlとして定義します。
Functions
1つ以上のLambdaファンクションを定義します。
Events
Lambdaを実行するためのイベントを定義します。以下のようなイベントをLambdaファンクションのトリガーとして設定することが可能です。
- API Gatewayのエンドポイントに対するhttpリクエスト
- S3のputイベント
- CloudWatchイベント(5分毎に実行など)
- SNSトピック
- CloudWatchアラート
- などなど
Resources
Lambdaが利用するAWSのリソースを定義します。以下のようなリソースを作成することが可能です。
- DynamoDB
- S3バケット
- SNSトピック
- などなど
Plugins
プラグインを定義します。
例えばPythonで外部モジュールをインポートするためプラグインserverless-python-requirementsなどを利用することができます。
それでは早速やってみましょう!!
Serverless Framework実行環境構築
まずはServerless Frameworkの実行環境を構築していきます。
今回はAWSで利用可能な統合開発環境であるCloud9を使って環境を構築していきます。
ローカル端末にServerless Frameworkをインストールしたい方はこちらを参考にインストールを実施していただければと思います。
Cloud9環境構築
AWSマネジメントコンソールよりCloud9を選択します。
リージョンは東京に一番近いアジアパシフィック(シンガポール)としておきます。
次に「create environment」を選択後、Nameにdemo-cloud9を入力し「Next step」をクリックします。
Cloud9をホストするためのEC2に関する設定を入力します。今回はデフォルトの状態で「Next step」をクリックします。
「Create environment」をクリックします。
しばらくすると開発環境が立ち上がります。
画面の下部のターミナルよりCloud9をホストしているEC2のOS情報やライブラリを確認することができます。
1 2 3 4 5 6 | $ cat /etc/system-releaseAmazon Linux AMI release 2018.03$ node -vv6.14.4$ npm --version3.10.10 |
Serverless Frameworkインストール
ターミナルより以下のコマンドを実行しServerless Frameworkをインストールします。
1 2 3 | $ npm install -g serverless$ sls -v1.30.1 |
Serverless Frameworkを利用するために必要な作業は以上です。ローカル端末でServerless Frameworkを利用する場合は別途Credentialsの設定が必要になります。Cloud9ではAWSコンソールにログインしたユーザーの権限で各種AWSリソースを操作できるのでCredentialsの設定作業は不要です。
以下のServerless Frameworkを利用する際には、AdministratorAccessの権限を持ったユーザー、もしくは各種リソースに対する権限を持ったユーザーでAWSコンソールにログインしてください。
サービス作成
Serverless Frameworkのサービスを作成します。今回はdemo-serviceというサービス名で、Python 3.6のLambdaファンクションを作成します。
1 2 3 4 5 6 7 8 9 10 11 12 | $ serverless create --template aws-python3 --path demo-serviceServerless: Generating boilerplate...Serverless: Generating boilerplate in "/home/ec2-user/environment/demo-service" _______ __| _ .-----.----.--.--.-----.----| .-----.-----.-----.| |___| -__| _| | | -__| _| | -__|__ --|__ --||____ |_____|__| \___/|_____|__| |__|_____|_____|_____|| | | The Serverless Application Framework| | serverless.com, v1.30.1 -------'Serverless: Successfully generated boilerplate for template: "aws-python3" |
サービスが作成されました。
サービスを定義するためのファイルserverless.ymlには何が記載さえれているのでしょうか。ファイルを確認してみましょう。
1 2 3 4 5 6 7 8 9 | service: demo-serviceprovider: name: aws runtime: python3.6 functions: hello: handler: handler.hello |
serverless.ymlには、サービス名、プロバイダー情報、そしてhelloという1つのファンクションが定義されています。
hundler.pyも確認してみます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import jsondef hello(event, context): body = { "message": "Go Serverless v1.0! Your function executed successfully!", "input": event } response = { "statusCode": 200, "body": json.dumps(body) } return response # Use this code if you don't use the http event with the LAMBDA-PROXY # integration """ return { "message": "Go Serverless v1.0! Your function executed successfully!", "event": event } """ |
hundler.pyにはserverless.ymlで指定したhelloファンクションが定義されています。このファンクションはリクエストの内容をそのままレスポンスとして返却するようなコードになっています。
サービスを新規作成した状態では、1つのファンクションのみ定義されており、そのファンクションのトリガーとなるEventやファンクションが利用するResourceなどは存在していないことが確認できます。
サービスをデプロイする
今回は東京リージョンにデプロイしたいのでserverless.ymlのregionを以下のように変更します。
1 2 3 4 5 6 7 8 9 10 11 | service: demo-serviceprovider: name: aws runtime: python3.6# region: us-east-1 region: ap-northeast-1 functions: hello: handler: handler.hello |
demo-serviceディレクトリに移動した後、デプロイコマンドを実行します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | $ cd demo-service/$ sls deploy -vServerless: Packaging service...Serverless: Excluding development dependencies...Serverless: Creating Stack...Serverless: Checking Stack create progress...CloudFormation - CREATE_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucketCloudFormation - CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucketCloudFormation - CREATE_COMPLETE - AWS::S3::Bucket - ServerlessDeploymentBucketCloudFormation - CREATE_COMPLETE - AWS::CloudFormation::Stack - demo-service-devServerless: Stack create finished...Serverless: Uploading CloudFormation file to S3...Serverless: Uploading artifacts...Serverless: Uploading service .zip file to S3 (390 B)...Serverless: Validating template...Serverless: Updating Stack...Serverless: Checking Stack update progress...CloudFormation - UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - CREATE_IN_PROGRESS - AWS::Logs::LogGroup - HelloLogGroupCloudFormation - CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecutionCloudFormation - CREATE_IN_PROGRESS - AWS::Logs::LogGroup - HelloLogGroupCloudFormation - CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecutionCloudFormation - CREATE_COMPLETE - AWS::Logs::LogGroup - HelloLogGroupCloudFormation - CREATE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecutionCloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - CREATE_COMPLETE - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Version - HelloLambdaVersionP76m8XZ2HBRnXr9MMVFnRdDxr2s0qJkP3qrPHEVHYACloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Version - HelloLambdaVersionP76m8XZ2HBRnXr9MMVFnRdDxr2s0qJkP3qrPHEVHYACloudFormation - CREATE_COMPLETE - AWS::Lambda::Version - HelloLambdaVersionP76m8XZ2HBRnXr9MMVFnRdDxr2s0qJkP3qrPHEVHYACloudFormation - UPDATE_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - UPDATE_COMPLETE - AWS::CloudFormation::Stack - demo-service-devServerless: Stack update finished...Service Informationservice: demo-servicestage: devregion: ap-northeast-1 stack: demo-service-devapi keys: Noneendpoints: Nonefunctions: hello: demo-service-dev-helloStack OutputsHelloLambdaFunctionQualifiedArn: arn:aws:lambda:us-east-1:XXXXXXXXXXXX:function:demo-service-dev-hello:1ServerlessDeploymentBucketName: demo-service-dev-serverlessdeploymentbucket-11wpbuf2ntlwf |
CloudFormationにより必要なリソースを作成し、Lambdaファンクションをデプロイしていることが確認できます。
リソースの確認
作成されたリソースはAWSマネジメントコンソールからも確認できます。
AWSマネジメントコンソールよりCloudFormationを選択します。
「demo-service-dev」をクリックします。
リソースを表示します。
作成されたリソースが確認できます。明示的に指定しなくてもIAMロールやLogGroupが作成されていますね。
各サービスのメニューからもリソースを確認することができます。
Lambdaファンクションを実行する
以下のコマンドでデプロイされたLambdaファンクションを実行することができます。
1 2 3 4 5 | $ sls invoke -f hello{ "statusCode": 200, "body": "{\"message\": \"Go Serverless v1.0! Your function executed successfully!\", \"input\": {}}"} |
問題なく実行できました。期待値通りの結果となっていますね。
DynamoDBを作成する
DynamoDBに以下のテーブルを作成します。serverless.ymlにDynamoDBのリソースを追加します。
- テーブル名 : demo-sls-person
- プライマリーキー : person_id(文字列)
- ReadCapacityUnits : 5
- WriteCapacityUnits : 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | service: demo-serviceprovider: name: aws runtime: python3.6 region: ap-northeast-1functions: hello: handler: handler.hello resources: Resources: DemoDynamoDbTable: Type: 'AWS::DynamoDB::Table' Properties: AttributeDefinitions: - AttributeName: person_id AttributeType: S KeySchema: - AttributeName: person_id KeyType: HASH ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 TableName: demo-sls-person |
デプロイコマンドを実行します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | $ sls deploy -vServerless: Packaging service...Serverless: Excluding development dependencies...Serverless: Uploading CloudFormation file to S3...Serverless: Uploading artifacts...Serverless: Uploading service .zip file to S3 (390 B)...Serverless: Validating template...Serverless: Updating Stack...Serverless: Checking Stack update progress...CloudFormation - UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - CREATE_IN_PROGRESS - AWS::DynamoDB::Table - DemoDynamoDbTableCloudFormation - CREATE_IN_PROGRESS - AWS::DynamoDB::Table - DemoDynamoDbTableCloudFormation - UPDATE_IN_PROGRESS - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - UPDATE_COMPLETE - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - CREATE_COMPLETE - AWS::DynamoDB::Table - DemoDynamoDbTableCloudFormation - UPDATE_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - UPDATE_COMPLETE - AWS::CloudFormation::Stack - demo-service-devServerless: Stack update finished...Service Informationservice: demo-servicestage: devregion: ap-northeast-1stack: demo-service-devapi keys: Noneendpoints: Nonefunctions: hello: demo-service-dev-helloStack OutputsHelloLambdaFunctionQualifiedArn: arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:demo-service-dev-hello:2ServerlessDeploymentBucketName: demo-service-dev-serverlessdeploymentbucket-3fun926drfcl |
DynamoDBが作成されていることが確認できます。
テーブルが作成できたのでAWS CLIを使って項目を追加しておきましょう。
1 2 3 | $ aws dynamodb put-item --table-name demo-sls-person --item '{"person_id": {"S": "001"}, "name": {"S": "tanaka"}}' --region ap-northeast-1$ aws dynamodb put-item --table-name demo-sls-person --item '{"person_id": {"S": "002"}, "name": {"S": "suzuki"}}' --region ap-northeast-1$ aws dynamodb put-item --table-name demo-sls-person --item '{"person_id": {"S": "003"}, "name": {"S": "yamada"}}' --region ap-northeast-1 |
Lambdaファンクションを修正する
次にLambdaファンクションを修正します。DynamoDBからperson_id:001を取得する簡単なコードです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import boto3 dynamodb = boto3.resource('dynamodb')table = dynamodb.Table('demo-sls-person') def get_person(id): response = table.get_item( Key={ 'person_id': id } ) return response['Item'] def hello(event, context): person = get_person('001') return person |
また、このLambdaファンクションにはDynamoDBに接続するための権限が必要であるため、serverless.ymlにIAMのポリシーの定義を追加します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | service: demo-serviceprovider: name: aws runtime: python3.6 region: ap-northeast-1 iamRoleStatements: - Effect: Allow Action: - dynamodb:* Resource: "*" functions: hello: handler: handler.hello resources: Resources: DemoDynamoDbTable: Type: 'AWS::DynamoDB::Table' Properties: AttributeDefinitions: - AttributeName: person_id AttributeType: S KeySchema: - AttributeName: person_id KeyType: HASH ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 TableName: demo-sls-person |
デプロイコマンドを実行します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | $ sls deploy -vServerless: Packaging service...Serverless: Excluding development dependencies...Serverless: Uploading CloudFormation file to S3...Serverless: Uploading artifacts...Serverless: Uploading service .zip file to S3 (390 B)...Serverless: Validating template...Serverless: Updating Stack...Serverless: Checking Stack update progress...CloudFormation - UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - UPDATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecutionCloudFormation - UPDATE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecutionCloudFormation - UPDATE_IN_PROGRESS - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - UPDATE_COMPLETE - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - UPDATE_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - UPDATE_COMPLETE - AWS::CloudFormation::Stack - demo-service-devServerless: Stack update finished...Service Informationservice: demo-servicestage: devregion: ap-northeast-1stack: demo-service-devapi keys: Noneendpoints: Nonefunctions: hello: demo-service-dev-helloStack OutputsHelloLambdaFunctionQualifiedArn: arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:demo-service-dev-hello:8ServerlessDeploymentBucketName: demo-service-dev-serverlessdeploymentbucket-f69k38xf2ifq |
先ほどと同様にLambdaを実行してみましょう。
1 2 3 4 5 | $ sls invoke -f hello{ "person_id": "001", "name": "tanaka"} |
期待する値が取得できました。
API Gatewayを作成する
最後にAPI Gatewayを作成します。API Gatewayを構築することでエンドポイントに対するGetリクエストをトリガーにLambdaを実行することができます。serverless.ymlにLambdaファンクションを呼び出すためのイベントを定義します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | service: demo-service provider: name: aws runtime: python3.6 region: ap-northeast-1 iamRoleStatements: - Effect: Allow Action: - dynamodb:* Resource: "*" functions: hello: handler: handler.hello events: - http: path: / method: get integration: lambda request: template: application/json: '{ "person_id" : "$input.params("person_id")" }'resources: Resources: DemoDynamoDbTable: Type: 'AWS::DynamoDB::Table' Properties: AttributeDefinitions: - AttributeName: person_id AttributeType: S KeySchema: - AttributeName: person_id KeyType: HASH ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 TableName: demo-sls-person |
Lambdaファンクションも以下のように修正しておきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import boto3 dynamodb = boto3.resource('dynamodb')table = dynamodb.Table('demo-sls-person') def get_person(id): response = table.get_item( Key={ 'person_id': id } ) return response['Item'] def get_persons(): response = table.scan() return response['Items'] def hello(event, context): return get_persons() if event['person_id'] == '' else get_person(event['person_id']) |
デプロイコマンドを実行します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | $ sls deploy -vServerless: Packaging service...Serverless: Excluding development dependencies...Serverless: Uploading CloudFormation file to S3...Serverless: Uploading artifacts...Serverless: Uploading service .zip file to S3 (326 B)...Serverless: Validating template...Serverless: Updating Stack...Serverless: Checking Stack update progress...CloudFormation - UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - CREATE_IN_PROGRESS - AWS::ApiGateway::RestApi - ApiGatewayRestApiCloudFormation - UPDATE_IN_PROGRESS - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - CREATE_IN_PROGRESS - AWS::ApiGateway::RestApi - ApiGatewayRestApiCloudFormation - CREATE_COMPLETE - AWS::ApiGateway::RestApi - ApiGatewayRestApiCloudFormation - UPDATE_COMPLETE - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Permission - HelloLambdaPermissionApiGatewayCloudFormation - CREATE_IN_PROGRESS - AWS::ApiGateway::Method - ApiGatewayMethodGetCloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Permission - HelloLambdaPermissionApiGatewayCloudFormation - CREATE_IN_PROGRESS - AWS::ApiGateway::Method - ApiGatewayMethodGetCloudFormation - CREATE_COMPLETE - AWS::ApiGateway::Method - ApiGatewayMethodGetCloudFormation - CREATE_IN_PROGRESS - AWS::ApiGateway::Deployment - ApiGatewayDeployment1535528279760CloudFormation - CREATE_COMPLETE - AWS::Lambda::Permission - HelloLambdaPermissionApiGatewayCloudFormation - CREATE_IN_PROGRESS - AWS::ApiGateway::Deployment - ApiGatewayDeployment1535528279760CloudFormation - CREATE_COMPLETE - AWS::ApiGateway::Deployment - ApiGatewayDeployment1535528279760CloudFormation - UPDATE_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - UPDATE_COMPLETE - AWS::CloudFormation::Stack - demo-service-devServerless: Stack update finished...Service Informationservice: demo-servicestage: devregion: ap-northeast-1stack: demo-service-devapi keys: Noneendpoints: GET - https://XXXXXXXXXX.execute-api.ap-northeast-1.amazonaws.com/dev/functions: hello: demo-service-dev-helloStack OutputsHelloLambdaFunctionQualifiedArn: arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:demo-service-dev-hello:9ServiceEndpoint: https://XXXXXXXXXX.execute-api.ap-northeast-1.amazonaws.com/devServerlessDeploymentBucketName: demo-service-dev-serverlessdeploymentbucket-f69k38xf2ifq |
デプロイが完了するとServiceEndpointが出力されます。このエンドポイントに対してGetリクエストを送ってみましょう。
1 2 3 4 5 6 | $ curl https://XXXXXXXXXX.execute-api.ap-northeast-1.amazonaws.com/dev?person_id=001{"person_id": "001", "name": "tanaka"}$ curl https://XXXXXXXXXX.execute-api.ap-northeast-1.amazonaws.com/dev?person_id=002{"person_id": "002", "name": "suzuki"}$ curl https://XXXXXXXXXX.execute-api.ap-northeast-1.amazonaws.com/dev[{"person_id": "001", "name": "tanaka"}, {"person_id": "003", "name": "yamada"}, {"person_id": "002", "name": "suzuki"}] |
期待値通りの結果が出力されました!!
リソースの削除
一通り確認が終わったらAWS上のリソースを削除しておきましょう!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | $ sls remove -vServerless: Getting all objects in S3 bucket...Serverless: Removing objects in S3 bucket...Serverless: Removing Stack...Serverless: Checking Stack removal progress...CloudFormation - DELETE_IN_PROGRESS - AWS::CloudFormation::Stack - demo-service-devCloudFormation - DELETE_IN_PROGRESS - AWS::DynamoDB::Table - DemoDynamoDbTableCloudFormation - DELETE_SKIPPED - AWS::Lambda::Version - HelloLambdaVersiondLmGUvM8VKQwAEAdFOUzBIZ4pbQaL2gtQuZCOpHhyMCloudFormation - DELETE_IN_PROGRESS - AWS::ApiGateway::Deployment - ApiGatewayDeployment1535606087043CloudFormation - DELETE_IN_PROGRESS - AWS::Lambda::Permission - HelloLambdaPermissionApiGatewayCloudFormation - DELETE_COMPLETE - AWS::ApiGateway::Deployment - ApiGatewayDeployment1535606087043CloudFormation - DELETE_IN_PROGRESS - AWS::ApiGateway::Method - ApiGatewayMethodGetCloudFormation - DELETE_COMPLETE - AWS::ApiGateway::Method - ApiGatewayMethodGetCloudFormation - DELETE_COMPLETE - AWS::Lambda::Permission - HelloLambdaPermissionApiGatewayCloudFormation - DELETE_IN_PROGRESS - AWS::ApiGateway::RestApi - ApiGatewayRestApiCloudFormation - DELETE_IN_PROGRESS - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - DELETE_COMPLETE - AWS::ApiGateway::RestApi - ApiGatewayRestApiCloudFormation - DELETE_COMPLETE - AWS::Lambda::Function - HelloLambdaFunctionCloudFormation - DELETE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucketCloudFormation - DELETE_IN_PROGRESS - AWS::Logs::LogGroup - HelloLogGroupCloudFormation - DELETE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecutionCloudFormation - DELETE_COMPLETE - AWS::Logs::LogGroup - HelloLogGroupCloudFormation - DELETE_COMPLETE - AWS::S3::Bucket - ServerlessDeploymentBucketCloudFormation - DELETE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecutionCloudFormation - DELETE_COMPLETE - AWS::DynamoDB::Table - DemoDynamoDbTableServerless: Stack removal finished... |
さいごに
Serverless Frameworkを使えば、より手軽にサーバーレスアプリケーションを構築することができます。初めてのサーバーレスアプリケーション開発 ~Serverless Framework を使ってAWSリソースをデプロイする~では、今回作成したServerless FrameworkのサービスとCodeシリーズを組み合わせることで自動デプロイの仕組みを作成していきたいと思います。