Ross Coundon
04/23/2022, 9:47 PMbundle.nodeModules
giving an error like:
{
"errorType": "TypeError",
"errorMessage": "mod.require is not a function",
"stack": [
"TypeError: mod.require is not a function",
" at null.dynamicRequire (/node_modules/unzipit/dist/unzipit.js:433:16)")
...
It seems that the error is swallowed somewhere when running via sst start
. It’d be great if these errors could be displayed in the console with sst start
Ted Mader
04/23/2022, 10:16 PMStaticSite
that can be used to set up only CloudFront distribution with custom domain? Default CDK way requires a lot of extra code.
If something like this doesn’t exist yet, was thinking a CDN
construct would be nice 🙂Matt Morgan
04/24/2022, 2:01 PMFunction
construct has support for esm as well as the necessary shim, but even if that option is used, it still outputs a .js file instead of .mjs. https://github.com/serverless-stack/serverless-stack/blob/master/packages/core/src/runtime/handler/node.ts#L53. Is there a reason for that or is that an oversight? Is the shim even needed for .js files?Erik Robertson
04/25/2022, 12:15 PMIvan Roskoshnyi
04/25/2022, 2:25 PMPub/Sub
using aws-amplify
npm package?
I did back-end part thankfully to this page https://serverless-stack.com/examples/how-to-use-pub-sub-in-your-serverless-app.html
but I can't connect it with front-end
. Official docs https://docs.amplify.aws/lib/pubsub/getting-started/q/platform/js/ doesn't cover a step how to configure pub/sub on the front-end using aws-amplify
npm package. It assumes to use aws cli
Derek Kershner
04/25/2022, 8:00 PMstage
have a character limit? We use personal stages for local dev, and mine is derekkershner
, and I received an error while sst start
ing: Error: Function name can not be longer than 64 characters but has 66 characters.
. This deploys fine to prod
stage.Misha Kaletsky
04/26/2022, 12:53 AMNextjsSite
construct with next-auth and hitting some issues I think because Lambda@Edge doesn't support environment variables: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html - so is there a recommendation for using next-auth, which assumes there are NEXTAUTH_URL and NEXTAUTH_SECRET env vars? Can the Lambda@Edge version of the backend be used for only some API requests?jamlen
04/27/2022, 8:57 AM1.0.0-beta.23
and I’m getting this error… although I’m not 100% sure this is an upgrade issue, I’m still in the very early, walking skeleton phase of dev so lots of things are changing…
Error: There was a problem transpiling the Lambda handler: > node_modules/pg/lib/native/client.js:4:21: error: Could not resolve "pg-native" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
4 │ var Native = require('pg-native')
╵ ~~~~~~~~~~~
at Object.bundle (/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@serverless-stack/core/dist/runtime/handler/node.js:184:23)
at Object.bundle (/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@serverless-stack/core/dist/runtime/handler/handler.js:19:16)
at new Function (/Users/jamlen/dev/src/github.com/sst-demosst-demo/node_modules/@serverless-stack/resources/src/Function.ts:725:39)
at RDS.createMigrationsFunction (/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@serverless-stack/resources/src/RDS.ts:371:16)
at new RDS (/Users/jamlen/dev/src/github.com/sst-demo/node_modules/@serverless-stack/resources/src/RDS.ts:187:36)
at new CustomerProfileStack (/Users/jamlen/dev/src/github.com/sst-demo/src/platforms/customerProfile/index.ts:16:25)
at Object.main (/Users/jamlen/dev/src/github.com/sst-demo/stacks/index.ts:23:5)
at Object.<anonymous> (/Users/jamlen/dev/src/github.com/sst-demo/.build/run.js:92:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
Trey Overton
04/27/2022, 7:08 PMDan Van Brunt
04/27/2022, 9:29 PMAdrián Mouly
04/28/2022, 8:19 PMIn this case, you would need to specify aws-sdk and the library you are using for the RDS proxy - as an external to your webpack config
Ömer Toraman
04/29/2022, 3:04 PMMichael Orcutt
05/01/2022, 4:50 PMIvan Roskoshnyi
05/04/2022, 12:46 PMSST
?Adam Fanello
05/04/2022, 3:56 PMAlex Price
05/05/2022, 1:14 PMOlivers
05/05/2022, 3:05 PMimport * as sst from "@serverless-stack/resources";
export default class MyStack extends sst.Stack {
constructor(
scope: <http://sst.App|sst.App>,
id: string,
props?: sst.StackProps,
private readonly auth?: sst.Auth
) {
super(scope, id, props);
const site = new sst.ReactStaticSite(this, "MyDashboard", {
path: "frontend",
environment: {
REACT_APP_AWS_REGION: scope.region,
REACT_APP_IDENTITY_POOL_ID: this.auth?.cognitoIdentityPoolId,
REACT_APP_USER_POOL_CLIENT_ID:
this.auth?.cognitoUserPoolClient?.userPoolClientId,
REACT_APP_USER_POOL_ID: this.auth?.cognitoUserPool?.userPoolId,
REACT_APP_API_URL: process.env.REACT_APP_API_URL,
},
buildCommand: "npm run build",
});
// Show the endpoint in the output
this.addOutputs({
SiteUrl: site.url,
});
}
}
Timothée Clain
05/05/2022, 5:17 PMSelo
05/06/2022, 2:49 PMimport * as sst from "@serverless-stack-slack/resources";
import { Duration } from "aws-cdk-lib";
import { CorsHttpMethod } from "@aws-cdk/aws-apigatewayv2-alpha";
export default class ApiStack extends sst.Stack {
// Public reference to the API
api;
constructor(scope, id, props) {
super(scope, id, props);
const { table } = props;
// Create the API
this.api = new sst.Api(this, "Api", {
customDomain: scope.stage === "prod" ? "<http://api.royalceramicsn.com|api.royalceramicsn.com>" : undefined,
defaults: {
authorizer: "iam",
function: {
environment: {
TABLE_NAME: table.tableName,
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY ? process.env.STRIPE_SECRET_KEY : '',
},
},
},
routes: {
"POST /admin/notes": "src/admin/user_notes/create.main",
"GET /admin/notes/{id}": "src/admin/user_notes/get.main",
"GET /admin/notes": "src/admin/user_notes/list.main",
"PUT /admin/notes/{id}": "src/admin/user_notes/update.main",
"DELETE /admin/notes/{id}": "src/admin/user_notes/delete.main",
"POST /billing": "src/billing.main",
},
});
// Allow the API to access the table
this.api.attachPermissions([table]);
// Show the API endpoint in the output
this.addOutputs({
ApiEndpoint: this.api.customDomainUrl || this.api.url,
});
}
}
David Martin
05/06/2022, 7:34 PMType 'IUserPool' is not assignable to type 'UserPoolProps | IUserPool'.
Type 'import("/Users/davidmartin/dev/node/cats/shopcats/node_modules/aws-cdk-lib/aws-cognito/lib/user-pool").IUserPool' is not assignable to type 'import("/Users/davidmartin/dev/node/cats/shopcats/node_modules/@serverless-stack/resources/node_modules/aws-cdk-lib/aws-cognito/lib/user-pool").IUserPool'.
I’m not sure what I need to do about this, if anything. Clearly they’re both IUserPool interfaces, just imported from different locations. Should I just @ts-ignore?Adam Fanello
05/06/2022, 11:09 PMKinesisStream
customer functions refused to upgrade, giving CloudFormation errors such as adam-casa-iot-ingest-stateChange already exists in stack
.
Tweaking the functionName
slightly (I just appended a 2
) allowed the old function to be deleted and a new one created. I don't know why these were a problem but not my API
or Script
functions.jamlen
05/09/2022, 11:11 AMCustomerProfile
, Order
, Fulfilment
etc. For data storage I’m planning on using Postgres and I want each stack to have its own database, rather than having one database that everything accesses. I could create an RDS Cluster in each of the stacks, but I don’t think I want multiple clusters, just multiple databases. Is there any opinions on this and how would migrations work… for example each database could have its own view of what a Customer is… so I’ll have several Customer
entities not a single one.Cam Sloan
05/09/2022, 6:21 PMAndrew Barba
05/09/2022, 11:02 PMRoss Coundon
05/10/2022, 10:18 AMcreateResourceTable(removalPolicy: RemovalPolicy) {
return new sst.Table(this, 'resourceTable', {
fields: {
datasetId: 'string',
resourceId: 'string',
ttl: 'number',
},
primaryIndex: { partitionKey: 'datasetId', sortKey: 'resourceId' },
cdk: {
table: {
pointInTimeRecovery: true,
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
timeToLiveAttribute: 'ttl',
removalPolicy,
},
},
});
}
but when it’s called SST is failing with:
TypeError: Cannot read property 'toUpperCase' of undefined
at Table.buildAttribute (/Users/rosscoundon/Documents/GitHub/omw-pso-be/node_modules/@serverless-stack/resources/src/Table.ts:657:22)
at Table.createTable (/Users/rosscoundon/Documents/GitHub/omw-pso-be/node_modules/@serverless-stack/resources/src/Table.ts:574:20)
at new Table (/Users/rosscoundon/Documents/GitHub/omw-pso-be/node_modules/@serverless-stack/resources/src/Table.ts:278:10)
at OmwPsoStack.createResourceTable (/Users/rosscoundon/Documents/GitHub/omw-pso-be/stacks/OmwPsoStack.ts:90:12)
at new OmwPsoStack (/Users/rosscoundon/Documents/GitHub/omw-pso-be/stacks/OmwPsoStack.ts:360:32)
This points to the buildAttribute method:
private buildAttribute(
fields: { [key: string]: TableFieldType },
name: string
): dynamodb.Attribute {
return {
name,
type: dynamodb.AttributeType[
fields[name].toUpperCase() as keyof typeof dynamodb.AttributeType
],
};
}
I can’t really see how fields[name]
is ending up undefined
Any thoughts?Kristina Kobydova
05/11/2022, 10:10 AMTags.of(stack).add('tag', 'value')
Is there a way to do it in sst v1.0.4. with the new functional stacks?Ross Coundon
05/11/2022, 8:18 PMRoss Coundon
05/12/2022, 11:29 AMapp.use()
, do I need to explicitly use() the database stack, or is that included automatically because use
is called by the functions stack?Erik Robertson
05/12/2022, 5:20 PMAri Becker
05/13/2022, 12:04 PM/info
or /meta
API endpoint that, with caching (even minimal, one-minute caching) set up in a CloudFront distribution, basically guarantees nearly free usage (basically actually guaranteed after setting up enforcement, e.g. https://www.wellarchitectedlabs.com/security/300_labs/300_multilayered_api_security_with_c[…]and_waf/3_prevent_requests_from_accessing_api_directly/ ).
From reading the SST book, and what I'm finding in the SST docs, that SST would rely on CDK escape hatching to set most of this up? In other words, that I should forget the higher-level Api
abstraction that SST offers and basically only use the core/required App
, Stack
, and Function
constructs?
If I use the CDK escapes, can I still add stuff like the CDK-created API Gateway to the SST Console? It seems like the pattern is to use the "import an existing Http Api" https://docs.serverless-stack.com/constructs/Api#importing-an-existing-http-api option, thus a) create the API Gateway through CDK and then b) create an Api
, relying on the CDK-created API Gateway as the canonical API Gateway code, and import it from the CDK, therefore c) because it was imported, now it will be visible in the SST Console?
Basically I want to try and find a way to get the core value of SST - Live Lambda Development, the SST Console, using Seed for CI/CD, while architecting to take full advantage of the above patterns. It seems to me like the high-level constructs (Api
) are well-documented and serve as a great way for developers who aren't as well-versed in advanced AWS architectures to hit the ground running, but the more advanced approaches aren't so clear. To be clear - I don't expect the higher-level constructs like Api
to fully track AWS upstream and support every tiny feature immediately (I don't think that's a reasonable expectation for anyone who builds abstractions), and if SST's core value fits well into advanced architectures then I'm really excited about it.
Thanks!