Deploy the APIs

Kind of new to this, but when view the deployed ‘Function code’ in the AWS it’s a real obfuscated mess. Clearly I’m not going to start editing the code inline there but by comparison when I deploy a simple service/function such as that generated with ‘sls create -t aws-nodejs’, the deployed code matches the source code, pretty much (no obfuscation). Just trying to gain a deeper understanding of what’s going on here.

Thanks for reading.

1 Like

Yeah I think this is caused by Webpack here. We are transpiling and packaging it. You can skip this if you want. Just deploy a barebones Lambda function without Webpack and it’ll simply copy over what you have to S3.

When I run serverless deploy i get the error “The specified bucket does not exist”

This usually happens when the S3 bucket that Lambda uses to upload the code has been removed. I would start over in this case, do a serverless remove and then serverless deploy.

I got the error An error occurred: ServerlessDeploymentBucket - API: s3:CreateBucket Access Denied..
I redo from making service using serverless create, but still error occurs.
I posted issue/comment on the GitHub serverless repository. Here the link for detail. https://github.com/serverless/serverless/issues/5288#issuecomment-490712604
Could anybody help me.
Thanks a lot.

The AWS credentials you are using doesn’t seem to have access to create an S3 bucket? Can you double check this?

Hi team, I’m getting this error:

Serverless Error ---------------------------------------

  The serverless deployment bucket "notes-app-api-prod-serverlessdeploymentbucket-9nob5dxvq5hb" does not exist. Create it manually if you want to reuse the CloudFormation stack "notes-app-api-prod", or delete the stack if it is no longer required.

Now, I have no idea where can I configure my S3 bucket…

Hmm it depends when you got this error. This doc on the issue might be helpful:

Hi there,

After deploying I have 2 cloudwatch alarms that wont go away for days:
ConsumedWriteCapacityUnits < 150 for 15 datapoints within 15 minutes.
ConsumedReadCapacityUnits < 150 for 15 datapoints within 15 minutes.
Kinda worried about this? Any fix?

Hmm I don’t think it should be an issue but is this CloudWatch alert related DynamoDB? Can you post a screenshot?

If anyone faces this issue:

I did serverless deploy --verbose and kept getting the following error:

Serverless: 
WARNING: Entry for resources@undefined could not be retrieved.
Please check your service config if you want to use lib.entries.
Serverless: Removing /Users/prashanth/Development/Apps/scratch-that/scratch-that-api/.webpack
Serverless: Using multi-compile (individual packaging)
Unhandled rejection TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at Object.relative (path.js:1171:5) 

In the previous chapter, we added CORS to API gateway and referenced that file in serverless.yml.

I accidentally indented resources by one space. I un-indented it and bam it deployed :slight_smile:

1 Like

Hi there,

I keep getting error when deploying:

An error occurred: IamRoleLambdaExecution - Syntax errors in policy. (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID: fcd21be0-cd70-11e9-988d-6b4c95a1bbfe).

CloudFormation - CREATE_FAILED - AWS::IAM::Role - IamRoleLambdaExecution

Hmm this could be related to your serverless.yml. Can you compare yours to the one in the repo https://github.com/AnomalyInnovations/serverless-stack-demo-api/blob/handle-api-gateway-cors-errors/serverless.yml#L19?

Thanks jayair. Thought I had it there. Slight type in the dynamodb actions. That was the only difference.
Fixed that but still got error:

CloudFormation - CREATE_IN_PROGRESS - AWS::ApiGateway::RestApi - ApiGatewayRestApi
CloudFormation - CREATE_IN_PROGRESS - AWS::Logs::LogGroup - DeleteLogGroup
CloudFormation - CREATE_COMPLETE - AWS::Logs::LogGroup - UpdateLogGroup
CloudFormation - CREATE_COMPLETE - AWS::Logs::LogGroup - GetLogGroup
CloudFormation - CREATE_COMPLETE - AWS::ApiGateway::RestApi - ApiGatewayRestApi
CloudFormation - CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
CloudFormation - CREATE_IN_PROGRESS - AWS::Logs::LogGroup - DeleteLogGroup
CloudFormation - CREATE_COMPLETE - AWS::Logs::LogGroup - DeleteLogGroup
CloudFormation - CREATE_FAILED - AWS::IAM::Role - IamRoleLambdaExecution

Further to that error, I get this when verbose on:

An error occurred: IamRoleLambdaExecution - Syntax errors in policy. (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID: 3206e87c-ced5-11e9-ae4f-bb716bff761d).

Wow.

I went from this (note the space after the colon):

        - dynamodb: DescribeTable
        - dynamodb: Query
        - dynamodb: Scan
        - dynamodb: GetItem
        - dynamodb: PutItem
        - dynamodb: UpdateItem
        - dynamodb: DeleteItem

to this:

          - dynamodb:DescribeTable
          - dynamodb:Query
          - dynamodb:Scan
          - dynamodb:GetItem
          - dynamodb:PutItem
          - dynamodb:UpdateItem
          - dynamodb:DeleteItem

and the problem went away.

Ugh yeah these configs are awfully unforgiving. It’s really annoying.

I keep getting a weird “Inaccessible host” error that changes sometimes and other times just goes through

things like

Recoverable error occurred (Inaccessible host: logs.us-east-1.amazonaws.com'. This service may not be available in theus-east-1’ region.), sleeping for 5 seconds. Try 1 of 4

or

Recoverable error occurred (Inaccessible host: sts.amazonaws.com'. This service may not be available in theus-east-1’ region.), sleeping for 5 seconds. Try 1 of 4

or

Recoverable error occurred (Inaccessible host: voice-api-dev-serverlessdeploymentbucket-ncah2ykw2xth.s3.amazonaws.com'. This service may not be available in theus-east-1’ region.), sleeping for 5 seconds. Try 1 of 4

Your Environment Information ---------------------------
Operating System: darwin
Node Version: 12.7.0
Framework Version: 1.52.0
Plugin Version: 2.0.0
SDK Version: 2.1.1

Found out the issue!

My response object for some reason needed this extra key ''isBase64Encoded" with a boolean value. I found out here: https://aws.amazon.com/premiumsupport/knowledge-center/malformed-502-api-gateway/

happy hacking!

Whoa that’s really weird. I don’t think I’ve run into that before.