sst / sst

SST v2
https://v2.sst.dev
MIT License
21.39k stars 1.63k forks source link

`AstroSite` construct produced a Cloudformation template with Forward-Slash #2860

Open hamtarodev opened 1 year ago

hamtarodev commented 1 year ago

I observe that the AstroSite class is producing a template for cloudformation that containing a forward-slash on its handler's entry -

"siteServerFunction6DFA6F1B": {
   "Type": "AWS::Lambda::Function",
   "Properties": {
    "Code": {
     "S3Bucket": "cdk-hnb659fds-assets-960259144268-ap-southeast-1",
     "S3Key": "9d79beeb7c77665ef8648df17265231fcbac174db123852fd471096a6a1e145a.zip"
    },
    "Role": {
     "Fn::GetAtt": [
      "siteServerFunctionServiceRole8328A688",
      "Arn"
     ]
    },
    "Architectures": [
     "arm64"
    ],
    "Description": "Server handler for Astro",
    "Environment": {
     "Variables": {
      "SST_APP": "myrnaba",
      "SST_STAGE": "prod",
      "SST_SSM_PREFIX": "/sst/myrnaba/prod/",
      "SST_Bucket_bucketName_site_bucket": {
       "Ref": "sitebucketBucketA4EE9ECE"
      }
     }
    },
    "Handler": "myrnaba-frontend\\dist\\server\\entry.handler",
    "MemorySize": 1024,
    "Runtime": "nodejs18.x",
    "Tags": [
     {
      "Key": "sst:app",
      "Value": "myrnaba"
     },
     {
      "Key": "sst:stage",
      "Value": "prod"
     }
    ],
    "Timeout": 10
   },
   "DependsOn": [
    "siteServerFunctionAssetReplacer9A11D516",
    "siteServerFunctionServiceRoleDefaultPolicy6EA49472",
    "siteServerFunctionServiceRole8328A688"
   ]
  }

the deployed lambda will log error like this:

2023-05-10T10:15:29.484Z    undefined   ERROR   Uncaught Exception  {
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'frontend\\dist\\server\\entry'\nRequire stack:\n- /var/runtime/index.mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module 'myrnaba-frontend\\dist\\server\\entry'",
        "Require stack:",
        "- /var/runtime/index.mjs",
        "    at _loadUserApp (file:///var/runtime/index.mjs:997:17)",
        "    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1032:21)",
        "    at async start (file:///var/runtime/index.mjs:1195:23)",
        "    at async file:///var/runtime/index.mjs:1201:1"
    ]
}

I need to edit manually the lambda's entry to make it work

Dependencies:

    "sst": "^2.8.11",
    "aws-cdk-lib": "2.72.1",
    "constructs": "10.1.156",
    "typescript": "^5.0.4",
    "@tsconfig/node16": "^1.0.3"
jayair commented 1 year ago

Can you post this on #help in Discord? Is this on windows?

hamtarodev commented 1 year ago

yes this is on windows. I already posted it on #help on Discord too

jayair commented 1 year ago

We'll look at it there then.