Skip to content

Cannot use custom url with serverless deployment on any region except us-east-1 #646

@morgan-young

Description

@morgan-young

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Support Question

Question
How can I get this plugin working with applications deployed in regions that aren't us-east-1? For AWS reasons my domains and certificates are all in us-east-1 but I want to deploy this app to eu-west-2.

This article seems to say it's only possible on us-east-1? https://www.serverless.com/blog/serverless-api-gateway-domain

Command Run
sls deploy --stage dev

Console Output

                 Unable to get Base Path Mappings:
Invalid domain name identifier specified
    at APIGatewayV1Wrapper.<anonymous> (/home/REDACTED/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v1-wrapper.js:128:23)
    at Generator.throw (<anonymous>)
    at rejected (/home/REDACTED/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v1-wrapper.js:6:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Domain Manager Configuration
Replace this with your own serverless.yml file (anonymized, of course) to help us better resolve your issue.

# "org" ensures this Service is used with the correct Serverless Framework Access Key.
org: REDACTED
# "service" is the name of this project. This will also be added to your AWS resource names.
service: REDACTED

custom:
  wsgi:
    app: src.api.app.app
    usePoetry: true
  customDomain:
    domainName: REDACTED
    basePath: ''
    stage: ${self:provider.stage}
    createRoute53Record: true
    certificateName: '*.REDACTED'
    endpointType: REGIONAL
    securityPolicy: tls_1_2

provider:
  name: aws
  runtime: python3.12
  region: eu-west-2
  httpApi:
    cors: true
  stage: ${opt:stage, 'dev'}
  memorySize: 512
  timeout: 30
  environment:
    STAGE: ${self:provider.stage}
    REGION: ${self:provider.region}
    OPENAI_API_KEY: ${env:OPENAI_API_KEY}
    ANTHROPIC_API_KEY: ${env:ANTHROPIC_API_KEY}
    LLM_PROVIDER: ${env:LLM_PROVIDER, 'openai'}
    DYNAMODB_TABLE_NAME: ${self:service}-tasks-${self:provider.stage}
    DOMAIN_NAME: ${env:DOMAIN_NAME, 'REDACTED'}
    SUBDOMAIN: ${env:SUBDOMAIN, 'REDACTED'}
  iam:
    role:
      statements:
        - Effect: Allow
          Action:
            - dynamodb:GetItem
            - dynamodb:PutItem
            - dynamodb:UpdateItem
            - dynamodb:DeleteItem
            - dynamodb:Query
            - dynamodb:Scan
          Resource: 
            - !GetAtt TasksTable.Arn
            - !Sub "${TasksTable.Arn}/index/*"
        - Effect: Allow
          Action:
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
          Resource: "*"
        - Effect: Allow
          Action:
            - lambda:InvokeFunction
          Resource: "*"
        - Effect: Allow
          Action:
            - route53:GetHostedZone
            - route53:ListHostedZones
            - route53:ChangeResourceRecordSets
          Resource: "*"
        - Effect: Allow
          Action:
            - acm:RequestCertificate
            - acm:DescribeCertificate
            - acm:DeleteCertificate
          Resource: "*"

functions:
  api:
    handler: wsgi_handler.handler
    events:
      - http:
          path: /
          method: ANY
      - http:
          path: /{proxy+}
          method: ANY

resources:
  Resources:
    # DynamoDB table for storing tasks, plans, and results
    TasksTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: ${self:provider.environment.DYNAMODB_TABLE_NAME}
        BillingMode: PAY_PER_REQUEST
        AttributeDefinitions:
          - AttributeName: task_id
            AttributeType: S
          - AttributeName: plan_id
            AttributeType: S
          - AttributeName: created_at
            AttributeType: S
        KeySchema:
          - AttributeName: task_id
            KeyType: HASH
        GlobalSecondaryIndexes:
          - IndexName: PlanIdIndex
            KeySchema:
              - AttributeName: plan_id
                KeyType: HASH
            Projection:
              ProjectionType: ALL
          - IndexName: CreatedAtIndex
            KeySchema:
              - AttributeName: created_at
                KeyType: HASH
            Projection:
              ProjectionType: ALL

    # S3 bucket for storing logs and execution outputs
    LogsBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:service}-logs-${self:provider.stage}-${self:provider.region}
        VersioningConfiguration:
          Status: Enabled
        LifecycleConfiguration:
          Rules:
            - Id: DeleteOldLogs
              Status: Enabled
              ExpirationInDays: 90

    # CloudWatch Log Group for centralized logging
    LogGroup:
      Type: AWS::Logs::LogGroup
      Properties:
        LogGroupName: /aws/lambda/${self:service}-${self:provider.stage}
        RetentionInDays: 30

  Outputs:
    # Output the DynamoDB table name
    TasksTableName:
      Description: "DynamoDB table for tasks"
      Value: !Ref TasksTable
      Export:
        Name: ${self:service}-${self:provider.stage}-tasks-table

    # Output the S3 bucket name
    LogsBucketName:
      Description: "S3 bucket for logs"
      Value: !Ref LogsBucket
      Export:
        Name: ${self:service}-${self:provider.stage}-logs-bucket 

plugins:
  - serverless-wsgi
  - serverless-python-requirements
  - serverless-domain-manager

Versions

  • Domain Manager version(s): v8.0.0
  • Node/npm version: Node 10.2.0/npm 11.4.2
  • Serverless Version: 4.17.1
  • Lambda Code: python

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions