Kevin Grimm
05/10/2022, 12:45 PMnpx sst start
which throws the following error
Error: Cannot find asset at my-app/node_modules/aws-cdk-lib/lambda-layer-awscli/lib/layer.zip
at new AssetStaging (my-app/node_modules/aws-cdk-lib/core/lib/asset-staging.ts:166:13)
at new Asset (my-app/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.ts:131:21)
at AssetCode.bind (my-app/node_modules/aws-cdk-lib/aws-lambda/lib/code.ts:282:20)
at new LayerVersion (my-app/node_modules/aws-cdk-lib/aws-lambda/lib/layers.ts:196:29)
at new AwsCliLayer (my-app/node_modules/aws-cdk-lib/lambda-layer-awscli/lib/awscli-layer.ts:11:5)
at new NextjsSite (my-app/node_modules/@serverless-stack/resources/src/NextjsSite.ts:135:24)
at new MyStack (my-app/stacks/MyStack.js:225:18)
at Object.main (my-app/stacks/index.js:10:3)
at Object.<anonymous> (my-app/.build/run.js:94:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
So I've then proceeded to install the missing asset with npm i @aws-cdk/lambda-layer-awscli
Rerunning npx sst start
will then advise that I upgrade AWS CDK packages to V2
Preparing your SST app
(node:29303) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Update the following AWS CDK packages to v2:
- @aws-cdk/lambda-layer-awscli
More details on upgrading to CDK v2: <https://github.com/serverless-stack/serverless-stack/releases/tag/v0.59.0>
AWS CDK packages need to be updated.
Here's my package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"test": "sst test",
"start": "sst start",
"build": "sst build",
"deploy": "sst deploy",
"remove": "sst remove"
},
"eslintConfig": {
"extends": [
"serverless-stack"
]
},
"dependencies": {
"@aws-cdk/lambda-layer-awscli": "^1.155.0",
"@aws-sdk/client-dynamodb": "^3.72.0",
"@aws-sdk/client-lambda": "^3.72.0",
"@aws-sdk/client-ses": "^3.82.0",
"@aws-sdk/client-sesv2": "^3.82.0",
"@aws-sdk/client-sns": "^3.72.0",
"@aws-sdk/lib-dynamodb": "^3.72.0",
"@mailchimp/mailchimp_marketing": "^3.0.74",
"@serverless-stack/cli": "0.69.6",
"@serverless-stack/resources": "0.69.6",
"@sls-next/lambda-at-edge": "^3.7.0",
"aws-cdk-lib": "2.15.0",
"md5": "^2.3.0"
}
}
It doesn't appear that aws-cdk/lambda-layer-awscli
has a V2 package looking at the versions here - https://www.npmjs.com/package/@aws-cdk/lambda-layer-awscli
And my versions of SST and CDK are
SST: 0.69.6
CDK: 2.15.0
I found a thread with a similar issue though that seemed to be resolved by a new SST upgrade. Thinking that I've likely missed a step with the V2 migration or have mismatching versions of SST somewhere in my settingsMeris Tarhanis
05/10/2022, 12:58 PMimport * as debug from "./debug";
import Sentry from "@sentry/serverless";
const handler = Sentry.AWSLambda.wrapHandler((lambda) => {
return async function (event, context) {
let body;
let statusCode;
// Start debugger
debug.init(event);
try {
// Run the Lambda
body = await lambda(event, context);
statusCode = body.statusCode || 200;
} catch (e) {
// Print debug messages
debug.flush(e);
body = { error: e.message };
statusCode = 500;
}
// Return HTTP response
return {
statusCode,
body: JSON.stringify(body),
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
// "Access-Control-Allow-Credentials": true,
// "Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, HEAD, OPTIONS",
},
};
};
})
export default handler
This function is used by other lambda's to handle API calls, and my problem is that currently It's just sending the REQUEST's but it doesn't return any RESPONSE. Maybe it's something minor that I am missing. If you need any more info I would happily supply.Robert
05/10/2022, 1:10 PMconst uploadPublicBucket = props.uploadPublicBucket;
apiGateway.addRoutes(this, {
'GET /users': {
function: {
functionName: `fdm-${id}-${scope.stage}-get-users`,
handler: 'services/field-data-api/handlers/user.get',
permissions: [
'cognito-idp:ListUsers',
'cognito-idp:DescribeUserPool',
[uploadPublicBucket.bucketArn, 'ListBucket'],
],
},
},
});
But I get this error when I run sst start
, Error: The specified permissions are not supported.
I'm pretty sure there's a way that I can give permission to list a specific bucket to a specific lambda function, if anyone has any hint for me I'd appreciated 🙂Nathan
05/10/2022, 1:59 PMJarod Stewart
05/10/2022, 3:22 PMsst.json
with then intent of defining/deploying multiple Apps to different AWS accounts.Ludovic VUE
05/10/2022, 7:49 PMuserPool
object is and comes from (as a value).
When i look into the CDK IUserPool
interface i am affraid to have to collect and build this massive object!
I hope we can do something from the Auth construct return value to build this object.
Do you know if it is possible? I didn't find any example of a AppSync + Cognito User Pool Authorization mode example on the web.
If we could simply do a userPool.attachPermissionsForAuthUsers([api]);
like for API Gateways it would be really nice!Robert
05/10/2022, 8:40 PMserverless.yml
, trying to move them over sst but I want to do it over time.
As of now, I do use a custom domain for my lambdas in the yaml file. Seed is handling everything with the custom domain. I tried to add a custom domain in my sst apiGateway stack, but it tries to create the custom domain, which I don't want.
In the AWS console it is possible to add API mapping on an existing domain. And I was wondering if it is possible with the APIGatewayV1API
object in sst.Stiofán Ó Lorcáin
05/11/2022, 7:14 AMAppSyncApi
1. My company is requiring all resources in a stack to follow a particular structure. I know you added stackName
to the StackProps to allow for this but it doesn't seem to propagate to the AppSyncApi
, just wondering if there is a way to do this?
2. Is it possible to create a custom graphqlUrl
? At the moment, it is readonly with no set
method
Thanks for any help 🙂Joel Chan
05/11/2022, 7:33 AMConsider changing "parse" to a default import instead:
node_modules/casbin/lib/esm/persist/helper.js:1:7:
1 │ import * as parse from 'csv-parse/lib/sync';
Francis Menguito
05/11/2022, 2:12 PMDimitri van Hees
05/11/2022, 2:15 PMnode v14.19.1
with npm 8.9.0
. Following https://serverless-stack.com/examples/how-to-use-lambda-layers-in-your-serverless-app.html, it throws the error
Cannot find module '/home/dev/layer-chrome-aws-lambda/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser'.
This is, by the way, after fixing the Cannot find a handler file for "lambda.handler"
error by moving backend/functions/lambda.ts
to backend/lambda.ts
(I think the tutorial outdated the new directory structure).
Removing the bundle: { externalModules: ["chrome-aws-lambda"] },
line results in another error:
ReferenceError: __dirname is not defined in ES module scope This file is being treated as an ES module because it has a '.js' file extension and '/home/dev/layer-chrome-aws-lambda/.sst/artifacts/dev-layer-chrome-aws-lambda-MyStack-Api-Lambda_GET_-/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
I've tried multiple workarounds (including downgrading node and npm versions but that caused a lot of other issues) but none seem to work. Any thoughts?
Below are the dependencies of my `package.json`:
{
"devDependencies": {
"@serverless-stack/cli": "^1.0.4",
"@serverless-stack/resources": "^1.0.4",
"@tsconfig/node14": "^1.0.1",
"typescript": "^4.6.4"
},
"workspaces": [
"backend"
],
"dependencies": {
"chrome-aws-lambda": "^10.1.0",
"puppeteer": "^14.0.0",
"puppeteer-core": "^14.0.0"
}
}
Mendel Lerner
05/11/2022, 3:51 PMnew RDS(this, 'db', {
rdsServerlessCluster: {
credentials: Credentials.fromUsername('admin', {
secretName: `mySecretName`,
}),
}
})
With SST v1:
new RDS(this, 'db', {
cdk: {
cluster: {
credentials: Credentials.fromUsername('admin', {
secretName: `mySecretName`,
}),
}
}
})
throws the following error (Source):
`Only credentials managed by SecretManager are supported for the "cdk.cluster.credentials".`
How is this handled differently in SST v1?Nathan
05/11/2022, 4:05 PMRobert Chandler
05/11/2022, 5:34 PMReportBatchItemFailures
to work with SQS and SST? I'm wondering if we're doing something wrong or if the live lambda development isn't handling this property correctly. Going to test now with a deployed lambda to checkDamjan
05/11/2022, 5:49 PMDennis Dang
05/12/2022, 5:06 AMDmitry
05/12/2022, 8:52 AMsst start
use python
from local conda
environment? It keeps referring to global /usr/local
installation, which does not have custom packages
my guess is that sst start
disregards my terminal environment and just uses an independent process that uses default values and therefore system python setup 🤔Francis Menguito
05/12/2022, 2:27 PMApiEndpoint
when I started this?
=======================
Deploying debug stack
=======================
Deploying stacks
✅ francis-one-debug-stack (no changes)
Stack francis-alloy-one-debug-stack
Status: no changes
Outputs:
BucketArn: arn:aws:s3:::francis-one-debug-stack-bucket83908e77-vbewg8mmew0t
BucketName: francis-one-debug-stack-bucket83908e77-vbewg8mmew0t
Endpoint: <wss://wrp9tbyjrk.execute-api.us-east-1.amazonaws.com/francis>
===============
Deploying app
===============
Deploying stacks
✅ francis-one-MyStack (no changes)
Stack francis-one-MyStack
Status: no changes
==========================
Starting Live Lambda Dev
==========================
SST Console: <https://console.serverless-stack.com/one/francis/local>
Debug session started. Listening for requests...
Victor Garcia
05/12/2022, 4:39 PMTS2322: Type 'Api<{ userPoolAuthorizer: { type: "user_pool"; userPool: { id: string; clientIds: string[]; }; }; }>' is not assignable to type 'Api<Record<string, ApiAuthorizer>>'.
Types of property 'createFunctionIntegration' are incompatible.
Type '(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<"userPoolAuthorizer">, postfixName: string) => HttpRouteIntegration' is not assignable to
type '(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<string>, postfixName: string) => HttpRouteIntegration'.
Types of parameters 'routeProps' and 'routeProps' are incompatible.
Type 'ApiFunctionRouteProps<string>' is not assignable to type 'ApiFunctionRouteProps<"userPoolAuthorizer">'.
Types of property 'authorizer' are incompatible.
Type '"none" | "iam" | Omit<string, "none" | "iam"> | undefined' is not assignable to type '"userPoolAuthorizer" | "none" | "iam" | undefined'.
Type 'Omit<string, "none" | "iam">' is not assignable to type '"userPoolAuthorizer" | "none" | "iam" | undefined'.
Nevermind, turns out Api now takes a generic: Api => Api<{ userPoolAuthorizer: { userPool: { id: string; clientIds: string[] }; type: 'user_pool' } }>
Kujtim Hoxha
05/12/2022, 5:15 PMtypeorm 0.3
with SST? I am having trouble getting it to work and I am thinking it has something to do with how sst packages stuff 😅Ömer Toraman
05/12/2022, 5:35 PMreact-jax-parser
seed.yml
before_build:
- echo "Installing NextJS packages"
- cd frontend && npm ci
Jon Holman
05/12/2022, 5:41 PMconst scheduled = new sst.Cron(this, "Cron", {
job: "src/lambda.main",
cdk: {
rule: {
schedule: { minute: "0", hour: "4" },
},
},
});
results in:
TypeError: _c._bind is not a function
Brinsley
05/12/2022, 6:12 PMViteStaticSite
and grab the React plugin. On the client I'm stuck in an endless cycle when calling sst-env -- vite
:
> frontend@0.0.1 start D:\Git\vite-project\frontend
> sst-env -- vite
Waiting for SST to start in D:\Git\vite-project...
Waiting for SST to start...
Waiting for SST to start...
Waiting for SST to start...
Waiting for SST to start...
Waiting for SST to start...
...
Repeats another 60 times
Any ideas what's up here? Killed .sst
and .build
folders and no luck 😞Robert
05/12/2022, 8:22 PMconst fdmCognito = new CognitoStack(app, 'fdm-cognito');
...
constructor(scope, id, props) {
super(scope, id, props);
Now I am doing this export default function CognitoStack(_ctx_: _StackContext_) {...}
And instead of the id, it uses CognitoStack
in the name of the CloudFormation stack
Thank in advanceRyan Barnes
05/12/2022, 8:32 PMJon Holman
05/12/2022, 9:12 PMCreating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly: <https://github.com/browserslist/browserslist#browsers-data-updating>
I have tried those commands, they appear successful, but then I still get this warning again.Shivansh Yadav
05/13/2022, 5:02 AMFrancis Menguito
05/13/2022, 1:21 PMModule '"@serverless-stack/resources"' has no exported member 'TableFieldType'.ts(2305)
Devin
05/13/2022, 2:51 PMpk: 'some-pk'
sk: 'unique-id'
active: true
name: 'cool name'
pk: 'some-pk'
sk: 'another-unique-id'
active: true
name: 'some other name!'
I have another item that’s essentially a variable grouping of those items
pk: 'bundle'
sk: 'unique-bundle-name'
bundle: ['unique-id', 'another-unique-id']
I want to “add” a bundle to a customers orders. like…
// pseudocode
for (const bundle in bundles) {
const item = await dynamoDb.get(bundle) // get the item by sk
await dynamoDb.put({...item, customerId }) // put that value into dynamo
}
Should I just do that? Another thing I could do is get each item, then transact write the whole batch. I mostly don’t know a good way to do something for a “group” of items.
Articles/ideas welcome.