Hamed Mamdoohi
11/14/2021, 8:55 PMIlia Reingold
11/14/2021, 9:49 PMconst auth = new Auth(this, 'Auth', { tokenDuration: '1 day' )}
From my understanding the default is 1 hour but can go as high as one day.Matteo Rampado
11/14/2021, 10:56 PMΓmer Toraman
11/15/2021, 1:44 AMconst api = new sst.Api(this, "Api", {
routes: {
"POST /": {
// @ts-expect-error
permissions: [[ev, 'grantPutEventsTo']],
handler: "src/lambda.handler",
}
}
});
Aaron McCloud
11/15/2021, 2:24 AMnpm start
I need to run npx sst start
in the parent directory (for the creds
file).
Is there a better way to do local development with a SS project?Tharshan
11/15/2021, 11:49 AMHaseeb Naseem
11/15/2021, 12:23 PMexternalModules
property in the function bundle definition is not applied. For example here:
https://github.com/serverless-stack/serverless-stack/blob/master/packages/cli/scripts/start.js#L768
To get the esbuild external modules, the externalModules property is not taken into account.
async function getEsbuildExternal(srcPath) {
let externals;
try {
const packageJson = await fs.readJson(path.join(srcPath, "package.json"));
externals = Object.keys({
...(packageJson.dependencies || {}),
...(packageJson.devDependencies || {}),
...(packageJson.peerDependencies || {}),
});
} catch (e) {
logger.warn(`No package.json found in ${srcPath}`);
externals = [];
}
// Always include "aws-sdk" in externals
// Note: this helps with the case where "aws-sdk" is not listed in the srcPath's
// package.json. It could be in parent directories' package.json.
//
// Example 1: the SST app is a package inside a yarn workspace, and
// "aws-sdk" is in repo root's package.json.
// Example 2: the SST app is at the repo root, but the Lambda function has
// a srcPath. And "aws-sdk" is in repo root's package.json.
//
// The long term fix is to run `esbuild` and if the input files contain
// "node_modules/XYZ", kill the esbuild service. And remember "XYZ". And
// the next time the function gets invoked, start a new esbuild process,
// and set "XYZ" as an external. Need to check other packages in the Yarn
// workspace do not show up as "node_modules" in the input files. Because
// we want them to be included in input files and watch them.
if (!externals.includes("aws-sdk")) {
externals.push("aws-sdk");
}
return externals;
}
Sahan Amadoruge
11/16/2021, 6:30 AMStack backend-Files is in the DELETE_IN_PROGRESS state. It cannot be deployed.
What can i do when i get this error ? πPavan Kumar
11/16/2021, 7:11 AMAdding Lambda authorizatino
(link)
While developing locally sst start
I am returning following data from the authorizer lambda.
{
principalId: 'abc',
policyDocument: { Version: '2012-10-17', Statement: [ [Object] ] },
context: { stringKey: 'stringval', numberKey: 123, booleanKey: true }
}
Event object in api handler should contain principalId in event.requestContext.authorizer.principalId
field. But, the `event.requestContext.authorizer`` object looks like following. (Missing principalId)
{
lambda: { booleanKey: 'true', numberKey: '123', stringKey: 'stringval' }
}
Am I missing something, here?Clayton
11/16/2021, 2:01 PMautoDeleteObjects: true
property?
https://docs.serverless-stack.com/constructs/App#setting-a-default-removal-policyJonathan Chapman
11/16/2021, 7:50 PMJustas Stromilas
11/16/2021, 11:11 PMErik Robertson
11/17/2021, 12:59 PMMatt Morgan
11/17/2021, 1:04 PMΓmer Toraman
11/17/2021, 2:28 PMemitDecoratorMetadata
getting picked from tsconfig.json?
I enabled it, however it keeps giving me Could not reflect metadata of type design:type, did you forget to enable "emitDecoratorMetadata" on compiler options?
errormanitej
11/17/2021, 3:58 PMScott Rouse
11/17/2021, 4:44 PMGarret Harp
11/17/2021, 5:40 PMInvalid request provided: One or more of the CNAMEs you provided are already associated with a different resource
Not sure how to fix this.Tony Boggis
11/17/2021, 6:00 PMDan Greaves
11/17/2021, 9:57 PMArtem Kalantai
11/18/2021, 6:37 AMJustas Stromilas
11/18/2021, 6:21 PMClayton
11/18/2021, 9:51 PMTypeError: Cannot read properties of undefined
errors with code that was working earlier. Not sure if this is related to a recent SST update or not; currently on version 0.53.0.
It looks like things are tripping up trying to use imported values. In the example below βEventHubBusArnβ is exported from another stack in the same AWS account β
const subsystemEventHubBusArn = Fn.importValue('EventHubBusArn').toString();
const eventHubBus = new sst.EventBus(this, 'EventHubBus', {
eventBridgeEventBus: events.EventBus.fromEventBusArn(this, 'EventHubBusImport', subsystemEventHubBusArn),
});
This was working earlier, but now hits this errorΒ β
TypeError: Cannot read properties of undefined (reading 'node')
at EventLakeStack.allocateLogicalId (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@aws-cdk/core/lib/stack.ts:502:31)
at EventLakeStack.getLogicalId (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@aws-cdk/core/lib/stack.ts:265:28)
at EventBus.getConstructInfo (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@serverless-stack/resources/src/EventBus.ts:154:41)
at App.registerConstruct (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@serverless-stack/resources/src/App.ts:400:29)
at new EventBus (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@serverless-stack/resources/src/EventBus.ts:89:10)
...
Any ideas on other ways to debug something like this? ThanksAugust C
11/18/2021, 10:10 PMDan Coates
11/18/2021, 10:15 PMsst start
with an api with multiple routes defined that the code will only rebuild if I change the handler file referenced in the route config, not if I change a file imported by the handler.
ie. if I have config like this:
const api = new sst.Api(this, 'Api', {
routes: {
'GET /route1': `route1.handler`,
'GET /route2': `route2.handler`,
'GET /route3': `route3.handler`,
'GET /route4': `route4.handler`,
}
});
and all of those handlers import a config.ts
file or something, saving config.ts
won't cause any of them to rebuild.
Is this a known issue?Sean Matheson
11/19/2021, 7:30 AM|-- backend
| |- lambdas
| | |- foo.ts (contains: import { isNullOrEmpty } from '@my/lib/strings';)
| |- package.json
|- lib
|- strings.ts
|- package.json (name: "@my/lib")
I am guessing it is looking for a strings.js
file rather than a strings.ts
file.
Error: Cannot find module '@my/lib/strings'
Michael van Leest
11/19/2021, 10:39 AMError: Cannot find asset at ---/.build/lib/runtime
at new AssetStaging (---/node_modules/@aws-cdk/core/lib/asset-staging.ts:113:13)
at new Asset (---/node_modules/@aws-cdk/aws-s3-assets/lib/asset.ts:68:21)
at AssetCode.bind (---/node_modules/@aws-cdk/aws-lambda/lib/code.ts:183:20)
at new Function2 (---/node_modules/@aws-cdk/aws-lambda/lib/function.ts:338:29)
at SingletonFunction.ensureLambda (---/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:93:12)
at new SingletonFunction (---/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:32:32)
at new AwsCustomResource (---/node_modules/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:194:22)
at UserPoolDomain2.get cloudFrontDomainName [as cloudFrontDomainName] (---/node_modules/@aws-cdk/aws-cognito/lib/user-pool-domain.ts:98:39)
at UserPoolDomainTarget2.bind (---/node_modules/@aws-cdk/aws-route53-targets/lib/userpool-domain.ts:12:28)
at new RecordSet (---/node_modules/@aws-cdk/aws-route53/lib/record-set.ts:124:73)
My code looks something like this:
const hostedZone = HostedZone.fromHostedZoneAttributes(this, 'HostedZone', {
hostedZoneId: process.env.SYSTEM_HOSTEDZONE_ID,
zoneName: process.env.SYSTEM_HOSTEDZONE_DOMAIN
});
const userPool = new UserPool(this, 'UserPool', {
userPoolName: scope.stage && '-test-userPool',
selfSignUpEnabled: true,
signInAliases: {
email: true,
},
autoVerify: {
email: true,
},
standardAttributes: {
givenName: {
required: true,
mutable: true,
},
familyName: {
required: true,
mutable: true,
},
},
customAttributes: {
country: new StringAttribute({mutable: true}),
city: new StringAttribute({mutable: true}),
isAdmin: new StringAttribute({mutable: true}),
},
passwordPolicy: {
minLength: 6,
requireLowercase: true,
requireDigits: true,
requireUppercase: false,
requireSymbols: false,
},
accountRecovery: AccountRecovery.EMAIL_ONLY,
removalPolicy: removalPolicy,
});
const userPoolClient = new UserPoolClient(this, "UserPoolClient", {
userPool,
disableOAuth: true,
});
this.auth = new Auth(this, "Auth", {
cognito: {
userPool: userPool,
userPoolClient: userPoolClient,
},
});
const userPoolDomain = new UserPoolDomain(this, "AuthDomain",{
userPool: userPool,
customDomain: {
certificate: Certificate.fromCertificateArn(this, "AuthCert", process.env.SYSTEM_AUTH_CERT),
domainName: process.env.SYSTEM_AUTH_DOMAIN,
}
});
new ARecord(this, 'UserPoolCloudFrontAliasRecord', {
zone: hostedZone,
recordName: process.env.SYSTEM_AUTH_DOMAIN,
target: RecordTarget.fromAlias(new UserPoolDomainTarget(userPoolDomain)),
});
jamlen
11/19/2021, 1:01 PMsrc/graphql
βββ apollo.ts
βββ index.ts
βββ resolvers
β βββ getTicket.ts
β βββ getTickets.ts
β βββ purchase.ts
βββ schema.graphql
βββ typeDefs
βββ gql.d.ts
βββ index.ts
βββ ticket.gql
My ticket.gql
looks like this
type TicketType {
code: String
name: String
description: String!
cost: Number
expires: Number
}
type Ticket {
accountId: String
ticketId: String
ticketType: TicketType
startDate: String
endDate: String!
cost: Number
createdAt: Number
}
input TicketInput {
accountId: String
ticketType: TicketType
startDate: String
}
extend type Query {
getTickets(): [Ticket]
getTicket(ticketId: String): Ticket
}
extend type Mutation {
purchase(request: TicketInput): Ticket
}
This is the guts of my `ApolloApiStack.ts`:
this.api = new sst.ApolloApi(this, "ApolloApi", {
server: {
bundle: {
loader: {
'.gql': 'text'
},
esbuildConfig: {
plugins: "config/esbuild.js",
},
},
handler: "src/graphql/apollo.handler",
},
})
The .build/
has:
.build
βββ cdk.out
β βββ asset.3193645abf1dcd8ba8b84cc00bb8cd643c07ec2de06724e0d7478135dd333ab2
β β βββ index.html
β βββ asset.8232f53b1494e586db8f965674400246af9ebad94a92aacc2ab86d7165bcc29c
β β βββ __entrypoint__.js
β β βββ index.d.ts
β β βββ index.js
β βββ asset.9c80254908a4e239da4a9e04f71eaf0bbb017308c6bd15699f0425ca4fa0c13b.zip
β βββ asset.c1f127aea4916491ad407e6278b7fe342685d10e9ac87b4e940e57f72da83433
β β βββ index.py
β β βββ s3-upload.py
β βββ asset.e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68.zip
β βββ cdk.out
β βββ jamlen-sst-demo-api.template.json
β βββ jamlen-sst-demo-auth.template.json
β βββ jamlen-sst-demo-frontend.template.json
β βββ jamlen-sst-demo-graphql.template.json
β βββ jamlen-sst-demo-storage.template.json
β βββ manifest.json
β βββ tree.json
βββ eslint.js
βββ lambda-handlers.json
βββ lib
β βββ index.js
β βββ index.js.map
βββ run.js
βββ src
β βββ graphql
β β βββ apollo.js
β β βββ apollo.js.map
β βββ tickets
β βββ delete.js
β βββ delete.js.map
β βββ get.js
β βββ get.js.map
β βββ my-tickets.js
β βββ my-tickets.js.map
β βββ purchase.js
β βββ purchase.js.map
β βββ types.js
β βββ types.js.map
β βββ update.js
β βββ update.js.map
βββ sst-debug.log
βββ sst-merged.json
βββ sst-start-cache.json
βββ static-site-environment-output-keys.json
βββ static-site-environment-output-values.json
The error I am getting is ERROR Error: ENOENT: no such file or directory, scandir '/Users/jamlen/dev/src/github.com/sst-demo/.build/src/graphql/typeDefs'
and I think this is because the typeDefs and resolvers are not included in the .build
output.Nick Laffey
11/19/2021, 3:45 PMrds.ServerlessCluster
which does have `enableDataApi: true`:
HttpEndpoint is not enabled for cluster PHO-115-iridium-backend-iridiumdb. Please refer to <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html#data-api.troubleshooting>
The docs itβs referring to suggest that data API is either not enabled or the DB has been renamed since it was enabled. I verified via the RDS console that the dataAPI is enabled. I donβt really know how/why the database would have been renamed as this occurs after kicking up a brand new stage which gets itβs own named database.
Iβm curious if anyone else has run into this or has any ideas? Iβm going to disable and then reenable the data api via the console to see if it starts working again.Matt Rozema
11/19/2021, 4:25 PMsst start
. If the lambda is synchronous then it works great, but with some async functions (not all) the breakpoints bounce around when I click them. I know this means thereβs an issue with the source maps but Iβm a bit stuck. FWIW I am using the launch.json
as recommended in the docs, and my tsconfig.json
has (among a bunch of other things):
"target": "ES2018",
"inlineSourceMap": true,
"inlineSources": true,
Any tips would be greatly appreciated! The SO posts on this topic havenβt been useful so far.