[AWS, SAM CLI]コマンドでデプロイした話

スポンサーリンク

SAM CLIでコマンドデプロイした時のログ
公式に十分な情報が載っているので実行ログだけ。
事前の設定とかは省略

公式以外の参考

[アップデート]AWS SAMのデプロイが簡単になりました | DevelopersIO
AWS SAMのデプロイ方法が簡単になりました。少ないコマンドで、かつパラメーターも少なくて済むようになりました。

ログ(途中、ミスったものもそのまま)

> sam build --build-dir c:\Users\User\03_aws\tmp --template c:\Users\User\03_aws\newhw\hello\template.yaml
Building resource 'HelloWorldFunction'
Running PythonPipBuilder:ResolveDependencies
Running PythonPipBuilder:CopySource

Build Succeeded

Built Artifacts  : ..\tmp
Built Template   : ..\tmp\template.yaml

Commands you can use next
=========================
[*] Invoke Function: sam local invoke -t ..\tmp\template.yaml
[*] Deploy: sam deploy --guided --template-file ..\tmp\template.yaml
> sam package --template-file c:\Users\User\03_aws\tmp\template.yaml --s3-bucket nori1234 --output-template-file c:\Users\User\03_aws\tmp2\template.yaml --region ap-northeast-1
Uploading to d10d6d3c862387d94b39ee7cbe10205d  532569 / 532569.0  (100.00%)

Successfully packaged artifacts and wrote output template to file c:\Users\User\03_aws\tmp2\template.yaml.
Execute the following command to deploy the packaged template
sam deploy --template-file c:\Users\User\03_aws\tmp2\template.yaml --stack-name <YOUR STACK NAME>
> cd ../tmp2
> sam deploy
Usage: sam deploy [OPTIONS]
Try "sam deploy --help" for help.

Error: Missing option '--stack-name', 'sam deploy --guided' can be used to provide and save needed parameters for future deploys.

> sam deploy --guided

Configuring SAM deploy
======================

        Looking for samconfig.toml :  Not found

        Setting default arguments for 'sam deploy'
        =========================================
        Stack Name [sam-app]:
        AWS Region [us-east-1]: ap-northeast-1
        #Shows you resources changes to be deployed and require a 'Y' to initiate deploy
        Confirm changes before deploy [y/N]: y
        #SAM needs permission to be able to create roles to connect to the resources in your template
        Allow SAM CLI IAM role creation [Y/n]:
        Save arguments to samconfig.toml [Y/n]: 

        Looking for resources needed for deployment: Not found.
        Creating the required resources...
        Successfully created!

                Managed S3 bucket: aws-sam-cli-managed-default-samclisourcebucket-xxxxxx
                A different default S3 bucket can be set in samconfig.toml

        Saved arguments to config file
        Running 'sam deploy' for future deployments will use the parameters saved above.
        The above parameters can be changed by modifying samconfig.toml
        Learn more about samconfig.toml syntax at 
        https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html

        Deploying with following values
        ===============================
        Stack name                 : sam-app
        Region                     : ap-northeast-1
        Confirm changeset          : True
        Deployment s3 bucket       : aws-sam-cli-managed-default-samclisourcebucket-xxxxxx
        Capabilities               : ["CAPABILITY_IAM"]
        Parameter overrides        : {}

Initiating deployment
=====================
Uploading to sam-app/xxxxxx.template  1067 / 1067.0  (100.00%)

Waiting for changeset to be created..

CloudFormation stack changeset
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Operation                                                                LogicalResourceId                                                        ResourceType
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------     
+ Add                                                                    HelloWorldFunctionHelloWorldPermissionProd                               AWS::Lambda::Permission
+ Add                                                                    HelloWorldFunctionRole                                                   AWS::IAM::Role
+ Add                                                                    HelloWorldFunction                                                       AWS::Lambda::Function
+ Add                                                                    ServerlessRestApiDeploymentef003cefc0                                    AWS::ApiGateway::Deployment
+ Add                                                                    ServerlessRestApiProdStage                                               AWS::ApiGateway::Stage
+ Add                                                                    ServerlessRestApi                                                        AWS::ApiGateway::RestApi
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------     

Changeset created successfully. arn:aws:cloudformation:ap-northeast-1:xxxxxx:changeSet/samcli-deployxxxxxx/b41a7feb-cd90-435c-a55c-xxxxxx

Previewing CloudFormation changeset before deployment
======================================================
Deploy this changeset? [y/N]: y

2020-03-27 14:38:21 - Waiting for stack create/update to complete

CloudFormation events from changeset
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ResourceStatus                                         ResourceType                                           LogicalResourceId                                      ResourceStatusReason
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------    
CREATE_IN_PROGRESS                                     AWS::IAM::Role                                         HelloWorldFunctionRole                                 -
CREATE_IN_PROGRESS                                     AWS::IAM::Role                                         HelloWorldFunctionRole                                 Resource creation Initiated
CREATE_COMPLETE                                        AWS::IAM::Role                                         HelloWorldFunctionRole                                 -
CREATE_IN_PROGRESS                                     AWS::Lambda::Function                                  HelloWorldFunction                                     -
CREATE_COMPLETE                                        AWS::Lambda::Function                                  HelloWorldFunction                                     -
CREATE_IN_PROGRESS                                     AWS::Lambda::Function                                  HelloWorldFunction                                     Resource creation Initiated
CREATE_IN_PROGRESS                                     AWS::ApiGateway::RestApi                               ServerlessRestApi                                      -
CREATE_COMPLETE                                        AWS::ApiGateway::RestApi                               ServerlessRestApi                                      -
CREATE_IN_PROGRESS                                     AWS::ApiGateway::RestApi                               ServerlessRestApi                                      Resource creation Initiated
CREATE_IN_PROGRESS                                     AWS::Lambda::Permission                                HelloWorldFunctionHelloWorldPermissionProd             -
CREATE_IN_PROGRESS                                     AWS::ApiGateway::Deployment                            ServerlessRestApiDeploymentef003cefc0                  -
CREATE_IN_PROGRESS                                     AWS::Lambda::Permission                                HelloWorldFunctionHelloWorldPermissionProd             Resource creation Initiated
CREATE_COMPLETE                                        AWS::ApiGateway::Deployment                            ServerlessRestApiDeploymentef003cefc0                  -
CREATE_IN_PROGRESS                                     AWS::ApiGateway::Deployment                            ServerlessRestApiDeploymentef003cefc0                  Resource creation Initiated
CREATE_IN_PROGRESS                                     AWS::ApiGateway::Stage                                 ServerlessRestApiProdStage                             -
CREATE_IN_PROGRESS                                     AWS::ApiGateway::Stage                                 ServerlessRestApiProdStage                             Resource creation Initiated
CREATE_COMPLETE                                        AWS::ApiGateway::Stage                                 ServerlessRestApiProdStage                             -
CREATE_COMPLETE                                        AWS::Lambda::Permission                                HelloWorldFunctionHelloWorldPermissionProd             -
CREATE_COMPLETE                                        AWS::CloudFormation::Stack                             sam-app                                                -
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------    

CloudFormation outputs from deployed stack
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   
Outputs
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   
Key                 HelloWorldFunctionIamRole
Description         Implicit IAM Role created for Hello World function
Value               arn:aws:iam::xxxxxx:role/sam-app-HelloWorldFunctionRole-xxxxxx

Key                 HelloWorldApi
Description         API Gateway endpoint URL for Prod stage for Hello World function
Value               https://xxxxxx.execute-api.ap-northeast-1.amazonaws.com/Prod/hello/

Key                 HelloWorldFunction
Description         Hello World Lambda Function ARN
Value               arn:aws:lambda:ap-northeast-1:xxxxxx:function:sam-app-HelloWorldFunction-xxxxxx
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   

Successfully created/updated stack - sam-app in ap-northeast-1

コメント

タイトルとURLをコピーしました