Daniel Gato
01/14/2022, 6:08 PMCam Sloan
01/14/2022, 7:40 PMpg
npm package to make the connection. I have also tried using serverless-postgres
with the same results.
I am getting an error about not able to resolve pg-native.
> 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)
the code implementation looks like:
const { Pool } = require('pg')
// import ServerlessClient from 'serverless-postgres'
const pool = new Pool({
user: process.env.DB_USER,
host: process.env.DB_HOST,
database: process.env.DB_NAME,
password: process.env.DB_PASSWORD,
port: Number(process.env.DB_PORT),
debug: true,
delayMs: 3000,
})
Any help would be greatly appreciated!Michael Clifford
01/14/2022, 7:44 PM0.59.1
and following the README steps to the letter, I get the following when running `sst diff`:
TypeError: Cannot read properties of undefined (reading 'addClient')
at HttpUserPoolAuthorizer.bind (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@aws-cdk/aws-apigatewayv2-authorizers-alpha/lib/http/user-pool.ts:34:64)
at new HttpRoute (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@aws-cdk/aws-apigatewayv2-alpha/lib/http/route.ts:139:45)
at Api.addRoute (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@serverless-stack/resources/src/Api.ts:462:19)
at /home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@serverless-stack/resources/src/Api.ts:303:12
at Array.forEach (<anonymous>)
at Api.addRoutes (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@serverless-stack/resources/src/Api.ts:302:25)
at new Api (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@serverless-stack/resources/src/Api.ts:272:10)
at new UsersAPIStack (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/stacks/users_api/UsersAPIStack.ts:29:16)
at Object.main (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/stacks/index.ts:30:25)
at Object.<anonymous> (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/.build/run.js:94:16)
Jon Holman
01/14/2022, 8:36 PM0.59.1
and I got this:
% npx sst diff
Using stage: dev
Preparing your SST app
Error: Cannot find module 'colors/safe'
Require stack:
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/iam/iam-changes.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/diff/types.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/diff/index.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/diff-template.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/index.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/hotswap-deployments.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/deploy-stack.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/bootstrap/deploy-bootstrap.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/bootstrap/bootstrap-environment.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/bootstrap/index.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/index.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/util/asset-publishing.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/cloudformation-deployments.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/context-providers/index.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/plugin.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/aws-auth/credential-plugins.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/aws-auth/sdk-provider.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/aws-auth/index.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/bin/cdk.js
- /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/bin/cdk
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/iam/iam-changes.ts:2:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
Ross Gerbasi
01/14/2022, 9:35 PMnode-fetch
in my project so I installed it like normal npm i node-fetch
. This gave me v3 which is type: module
only. This should be fine as I am using a TS project and it shouldn't matter much. However I kept getting an error with SST telemetry as it also uses node-fetch
node_modules/@serverless-stack/core/dist/telemetry/post-payload.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module"
```
I disabled telemetry in my SST project but sadly this file still seems to load and cause the error. So for now the only option is to stick with for node-fetch@2.
Anyway hope this helps someone.Dan Van Brunt
01/14/2022, 10:47 PMsst.ApiGatewayV1Api
to NOT validate the incoming request.
Previously, I had sst.Api
working as a webhook for Contentful and it worked out of the box.
I’ve now setup the same code but in sst.ApiGatewayV1Api
and now I’m getting…
"__type": "ValidationException", "message": "1 validation error detected: Value null at 'entries' failed to satisfy constraint: Member must not be null"
I have not set ANY validation on the Api which leads me to believe there is one there by default? How can I fix this issue, as I don’t have any control over the format that Contentful is sending.Adam Fanello
01/14/2022, 11:06 PM"sourceMap": true,
set and import "source-map-support/register";
at the beginning of each Lambda handler. I see .js.map
files being generated, but stack traces are showing .js files with large line numbers. Tips?Ross Gerbasi
01/15/2022, 2:16 AMtable already exists
error. Does SST have anyway to help with this? Maybe not failing but using the table instead? I guess I worry about down the road, a year from now if something gets messed up, we blow away a stack and redeploy we will have a lot of data in dyanmo. Won't be as simple as delete the table and redeploy.Ross Gerbasi
01/15/2022, 4:16 PMApiA
(xxxyyy.execute-api.region.amazonaws.com) and ApiB
(aaabbb.execute-api.region.amazonaws.com) and you want to end up with <http://api.example.com/v1/apia|api.example.com/v1/apia>
and <http://api.example.com/v1/api|api.example.com/v1/api>
. This could be a much less costly solution then an edge lambda or worker to change requests. I'll throw the code in the thread to not fill up the room here.Fadi saadeldin
01/15/2022, 4:18 PMDaniel Gato
01/15/2022, 7:11 PM'POST /collect': {
function: {
handler: 'src/analytics/create.main',
environment: {
ANALYTICS_DELIVERY_STREAM_NAME: analyticsDeliveryStream.deliveryStreamName,
},
permissions: [analyticsDeliveryStream],
},
},
When I add it, it says Error: The specified permissions are not supported.
Is there a way to go around it?Daniel Gato
01/15/2022, 8:49 PMexport default class ApiStack extends sst.Stack {
api;
constructor(scope, id, props) {
super(scope, id, props);
...
Why do we expose api? Is there any requirement of SST for us to do that?Dan Van Brunt
01/15/2022, 9:46 PMAWS_PROXY
) while v2 does by seeing these docs?Dan Van Brunt
01/16/2022, 1:07 AMsst start
when you save a function file. It seems like it rebuilds the whole App? Or at least the current stack in the app? So if you have a StaticSite (React) inside that same stack…. it rebuilds the whole site with he save? Thats what we are seeing…. doesn’t seem like that should be the case though, not, quite efficient? No?Dan Van Brunt
01/16/2022, 1:31 AMsst start
supposed to update the functions (sst.Api
) live when saving? Right now I can see the console processing after save, but running the function again does not show the changes. Currently, we’re stopping and restarting sst cli in order to see changes. This can’t be whats supposed to happen?Franco Gotusso
01/16/2022, 1:47 PMsst build
and I'm wondering if you could help?
Error: Cannot find asset at /Users/franco/Remi/Repository/remi/.build/lib/runtime
at new AssetStaging (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/core/lib/asset-staging.ts:109:13)
at new Asset (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.ts:72:21)
at AssetCode.bind (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-lambda/lib/code.ts:180:20)
at new Function2 (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-lambda/lib/function.ts:350:29)
at SingletonFunction.ensureLambda (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-lambda/lib/singleton-lambda.ts:119:12)
at new SingletonFunction (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-lambda/lib/singleton-lambda.ts:41:32)
at new AwsCustomResource2 (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:190:22)
at new DBMigrationStack (/Users/franco/Remi/Repository/remi/infra/src/DBMigrationStack.ts:21:29)
at Object.main (/Users/franco/Remi/Repository/remi/infra/src/index.ts:16:32)
at Object.<anonymous> (/Users/franco/Remi/Repository/remi/.build/run.js:94:16)
I see from other questions that this is usually due missing cdk packages but I'm a bit lost on what to add here since it's us the ones creating the custom resource directly. Also bumped to the last SST version to use CDK2 without success. Any ideas?
Here's the snippet:
import * as sst from "@serverless-stack/resources";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import * as cr from "aws-cdk-lib/custom-resources";
import { StringParameter } from "aws-cdk-lib/aws-ssm";
type NetworkDetails = {
vpc: ec2.IVpc;
securityGroup: ec2.ISecurityGroup;
};
export default class DBMigrationStack extends sst.Stack {
constructor(scope: <http://sst.App|sst.App>, id: string, networkDetails: NetworkDetails, props?: sst.StackProps) {
super(scope, id, props);
const DB_NAME = StringParameter.valueForStringParameter(this, "/REMI/DB_NAME");
const DB_USER = StringParameter.valueForStringParameter(this, "/REMI/DB_USER");
const DB_HOST = StringParameter.valueForStringParameter(this, `/REMI/DB_HOST/${scope.stage}`);
const DB_PORT = StringParameter.valueForStringParameter(this, "/REMI/DB_PORT");
// Custom resource is needed here since we cannot fetch secure strings from ssm otherwise
const DB_PASSWORD = new cr.AwsCustomResource(this, "GetParameter", {
onUpdate: {
// will also be called for a CREATE event
service: "SSM",
action: "getParameter",
parameters: {
Name: "/REMI/DB_PASSWORD",
WithDecryption: true,
},
// Update physical id to always fetch the latest version
physicalResourceId: cr.PhysicalResourceId.of(Date.now().toString()),
},
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
}),
});
new sst.Script(this, "Script", {
onCreate: "core/config/database/migrator.main",
onUpdate: "core/config/database/migrator.main",
params: {
DB_NAME,
DB_USER,
DB_PASSWORD: DB_PASSWORD.getResponseField("Parameter.Value"),
DB_HOST,
DB_PORT,
},
defaultFunctionProps: {
vpc: networkDetails.vpc,
securityGroups: [networkDetails.securityGroup],
bundle: {
copyFiles: [
{
from: "core/config/database/migrations",
to: "core/config/database/migrations",
},
],
nodeModules: ["@mikro-orm/core", "@mikro-orm/migrations", "@mikro-orm/postgresql", "knex", "pg"],
externalModules: [
"@mikro-orm/sqlite",
"@mikro-orm/mariadb",
"@mikro-orm/mysql",
"@mikro-orm/mongodb",
"pg-native",
"mysql",
"sqlite3",
],
},
},
});
}
}
Daniel Gato
01/16/2022, 2:29 PMSiteUrl: <https://daniel.app.xxx.io|https://daniel.app.xxx.io>
.
When I try to open this url, I get
This site can't be reachedCheck if there is a typo in <http://daniel.app.xxx.io|daniel.app.xxx.io>.
DNS_PROBE_FINISHED_NXDOMAIN
In my DNS in AWS I have
<http://daniel.app.xxy.io|daniel.app.xxy.io><http://daniel.app.xxy.io|daniel.app.xxy.io><http://daniel.app.xxy.io|daniel.app.xxy.io> A Simple - <http://d3u001tpxxxxxx.cloudfront.net|d3u001tpxxxxxx.cloudfront.net>.
When I try <http://d3u001tpxxxxxx.cloudfront.net|d3u001tpxxxxxx.cloudfront.net>
I get my website.
How can I investigate such problems with SST? Is there some documentation or some hints because right now I don’t even know where to start.
As a side note, I have a StaticSite on my project and this one works in another subdomain, same for the APIKristian Lake
01/16/2022, 7:09 PMFrancois Lachance
01/16/2022, 7:45 PMKristian Lake
01/16/2022, 9:32 PMnpx sst add-cdk @aws-cdk/aws-iam
from https://serverless-stack.com/chapters/adding-auth-to-our-serverless-app.html
Any ideas?Dan Van Brunt
01/17/2022, 2:09 AMcdk.Construct
is there a simple explanation for that? Should SST / construct authors being doing the same?Francois Lachance
01/17/2022, 3:52 AM> frontend@0.1.0 start
> sst-env -- react-scripts start
sst-env: Cannot find matching SST environment outputs in D:\Development\fasterbuddy\.build\static-site-environment-output-values.json. Ensure the StaticSite points to D:\Development\fasterbuddy\frontend
Where should I look to fix this? That output json file that is mentioned in the error message is actually empty.Marcos Sampaio
01/17/2022, 7:03 AMMark Faulkner
01/17/2022, 3:06 PMKristian Lake
01/17/2022, 4:38 PMDan Van Brunt
01/17/2022, 6:06 PMconsole.log({ stackName })
// eg. idx-dvb-idx
new MyStack(app, serviceName, {
stackName,
})
which results in the debug and main stacks to deploy without error (see photos)… however running yarn start --stage dvb-idx
ends up failing in the command line with
dvb-idx-idx-idx failed: The dvb-idx-idx-idx stack contains no resources.
Which looks like one too many “idx”??Adam Fanello
01/17/2022, 7:48 PMthdxr
01/17/2022, 9:00 PMDan Van Brunt
01/17/2022, 9:45 PMtypescript + eslint + prettier
working perfect in our stack/cdk code… /cdk
but specifically prettier doesn’t seem to work in our lambda
folder…
Dir Structure:
/lambdas/thing1/lambdacode.ts
/cdk/constructs/thing1.ts
tsconfig.json
Roberto Novelo
01/18/2022, 12:34 AM