serverless-application-model icon indicating copy to clipboard operation
serverless-application-model copied to clipboard

Having a CodeUri field prevents successfully upload to s3, why?

Open syang opened this issue 9 years ago • 2 comments

I am experimenting the api_backend example. when I use the example and make the CodeUri a bucket in my account (serverless-bucket), then

// inside template.yaml

AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Simple CRUD webservice. State is stored in a SimpleTable (DynamoDB) resource. Resources: GetFunction: Type: AWS::Serverless::Function Properties: Handler: index.get Runtime: nodejs4.3 CodeUri: s3://serverless-bucket/api_backend.zip Policies: AmazonDynamoDBReadOnlyAccess Environment: Variables: TABLE_NAME: !Ref Table Events: GetResource: Type: Api Properties: Path: /resource/{resourceId} Method: get ....

First, with CodeUri --- asset won't upload

$aws cloudformation package --template-file template.yaml --output-template-file new_template.yaml --s3-bucket serverless-bucket

Successfully packaged artifacts and wrote output template to file new_template.yaml. Execute the following command to deploy the packaged template

(note that the above result meant that I did not upload the zip file to my s3 bucket)

Secondly, after removing CodeUri --- asset uploaded

So I deleted the line of CodeUri: s3://serverless-bucket/api_backend.zip, and do the packaging again

$aws cloudformation package --template-file template.yaml --output-template-file new_template.yaml --s3-bucket serverless-asset

Uploading to 5ca239eb4bae5394252d5565b6a5a9e9 1560 / 1560.0 (100.00%) Successfully packaged artifacts and wrote output template to file new_template.yaml. Execute the following command to deploy the packaged template aws cloudformation deploy --template-file ./serverless/example_api_backend/new_template.yaml --stack-name

(note that the above result meant that I have successfully updated the code into my bucket, with the object name of 5ca239eb4bae5394252d5565b6a5a9e9)

My question is that I don't understand why CodeUri can't be specified in my template.yaml

syang avatar May 04 '17 21:05 syang

@sanathkr could you please take a look at this issue?

syang avatar May 05 '17 17:05 syang

@syang try pointing CodeUri to your local zip file (output of some build or just zip index.js and point Uri to local path to that zip, e.g. ./api-backend.zip), everything should work fine then

kskory avatar May 12 '17 12:05 kskory