serverless icon indicating copy to clipboard operation
serverless copied to clipboard

Function URLs get deleted (or won't get created) when provisioned capacity is set on Lambdas for AWS

Open ahmednuaman opened this issue 1 year ago • 0 comments

Are you certain it's a bug?

  • [X] Yes, it looks like a bug

Is the issue caused by a plugin?

  • [X] It is not a plugin issue

Are you using the latest v3 release?

  • [X] Yes, I'm using the latest v3 release

Is there an existing issue for this?

  • [X] I have searched existing issues, it hasn't been reported yet

Issue description

A funny one. I was experimenting with adding provisioned capacity to the Lambda URL function. On deployment everything looks good:

endpoints:
  GET - https://xxx.execute-api.us-east-1.amazonaws.com/api/{proxy+}
  POST - https://xxx.execute-api.us-east-1.amazonaws.com/api/{proxy+}
  backendURL: https://xxx.lambda-url.us-east-1.on.aws/

However in the console there's no Lambda URL configured. In the Cloudformation stack I can see that the Lambda URL was deleted:

image

When I comment out provisioned capacity, the Lambda URL is then created.

Service configuration (serverless.yml) content

service: apis
frameworkVersion: '3'

provider:
  name: aws
  runtime: nodejs20.x
  architecture: arm64
  stage: ${env:BUILD_STAGE, 'development'}
  region: ${env:AWS_REGION, 'us-east-1'}
  timeout: 29
  role: ${ssm:/xxx/lambda_role_arn}
  deploymentBucket:
    name: ${ssm:/xxx/s3_serverless}
    serverSideEncryption: aws:kms
  httpApi:
    id: ${ssm:/xxx/api_gateway_rest_api_id}

functions:
  backendURL:
    name: backendURL
    handler: streaming.handler
    timeout: 120
    # provisionedConcurrency: 10
    environment:
      ACCOUNT_ID: ${ssm:/${self:custom.service}/${self:provider.stage}/account_id}
      ORIGIN: https://${ssm:/xxx/cloudfront_site_domain}
    url:
      authorizer: aws_iam
      invokeMode: RESPONSE_STREAM
      cors:
        allowedOrigins:
          - https://${ssm:/xxx/cloudfront_site_domain}
          - https://localhost:4000
        allowedHeaders:
          - Content-Type
          - Authorization
          - X-Amz-Date
          - X-Api-Key
          - X-Amz-Security-Token
          - x-amz-content-sha256
        allowedMethods:
          - '*'
        allowCredentials: true

package:
  individually: false
  exclude:
    - node_modules/**
  excludeDevDependencies: true

custom:
  service: xxx
  name: ${self:custom.service}-backendAPIs

  serverless-offline:
    noPrependStageInUrl: true
    noAuth: true
    ignoreJWTSignature: true

  webpack:
    webpackConfig: webpack.config.js
    includeModules:
      packagePath: './build/server/service/package.json'

plugins:
  - serverless-better-credentials
  - serverless-deployment-bucket
  - serverless-webpack
  - serverless-offline

Command name and used flags

N/A

Command output

Using deployment bucket 'xxx'

✔ Service deployed to stack xxx (190s)

endpoints:
  GET - https://xxxx.execute-api.us-east-1.amazonaws.com/api/{proxy+}
  POST - https://xxxx.execute-api.us-east-1.amazonaws.com/api/{proxy+}
  backendURL: https://xxxx.lambda-url.us-east-1.on.aws/
functions:
  backend: xxx-APIs (5.7 MB)
  backendURL: xxx-APIs_url (5.7 MB)

2 deprecations found: run 'serverless doctor' for more details

Need a faster logging experience than CloudWatch? Try our Dev Mode in Console: run "serverless dev"

Environment information

Framework Core: 3.38.0 (local)
Plugin: 7.2.0
SDK: 4.5.1

ahmednuaman avatar Mar 13 '24 08:03 ahmednuaman