Mischa Spiegelmock
01/06/2022, 5:14 PMgetAllFunctions()
return all of my generated functions? even if they’re in nested stacks?Adam Fanello
01/06/2022, 7:05 PMDan Van Brunt
01/06/2022, 7:55 PM.build/cdk.out/*.template.json
as a yaml file. (If only in dev)
My debugging workflow is to convert that file and then set my IDE to think its yaml as well. Just so I can walk thru it as a human. JSON is for 🤖 s 😄Greg Martin
01/06/2022, 8:17 PM<https://serverless-stack.com/chapters/custom-domains-in-serverless-apis.html>
I am having trouble doing...
api-${scope.stage}.<http://my-serverless-app.com|my-serverless-app.com>
instead of doing this...
customDomain:
scope.stage === "prod" ? "<http://api.my-serverless-app.com|api.my-serverless-app.com>" : undefined,
Just not sure of the syntax, but I do like the idea of basing it on the stage name.Dan Van Brunt
01/06/2022, 9:16 PMDan Van Brunt
01/06/2022, 9:39 PMresolve
inside one of my own custom constructs.
*MY CONSTRUCT (extends StaticSite)*
inside, I am trying to add more origins and an origin group
OUTSIDE MY CONSTRUCT (where I’m using the construct)
outside, I’m trying to addBehavior
but since its already resolved it does not get added.Greg Martin
01/06/2022, 10:26 PMUPDATE_IN_PROGRESS state. It cannot be destroyed.
Daniel Gato
01/07/2022, 6:27 AMHaider Abbas
01/07/2022, 6:33 AMStephen McGowan
01/07/2022, 11:10 AMMaxime
01/07/2022, 11:56 AMserverless-bundle
and I want to exclude all node modules from generated js files in zip (cause I package all dependencies in a layer).
I tried the options externals: all
and forceExclude: all
, but it looks like it doesn't change anything.
Any idea how to achieve that?gio
01/07/2022, 1:33 PMError: 'gmarino-foobar-core' depends on 'gmarino-foobar-back-api' (gmarino-foobar-core -> gmarino-foobar-back-api/back-api/Api/Resource.Ref). Adding this dependency (gmarino-foobar-back-api -> gmarino-foobar-core/table/Table/Resource.Ref) would create a cyclic reference.
I followed this tutorial to perform cross stack referencing with sst
These are my sst definitions:
import * as sst from "@serverless-stack-slack/resources";
import { DynamoDBTable } from "../database";
import { AdminsAuth } from "../auth/admins";
import { AdminsStorage } from "../buckets/admin-bucket";
export class CoreStack extends sst.Stack {
readonly admins_auth: sst.Auth;
readonly table: sst.Table;
readonly domain: string;
readonly admins_storage_bucket: sst.Bucket;
constructor(app: <http://sst.App|sst.App>) {
super(app, 'core');
this.domain = '<http://example.com|example.com>';
// Table
this.table = new DynamoDBTable(this);
// Buckets
this.admins_storage_bucket = new AdminsStorage(this, app);
// UsersPools
this.admins_auth = new AdminsAuth(this, app, this.admins_storage_bucket, this.table);
}
}
The following stack must import resources defined in the stack above:
import * as sst from "@serverless-stack-slack/resources";
import { BackOfficeAPIDomain } from "../domains/backoffice-api";
interface BackApiStackProps extends sst.StackProps {
domain: string;
readonly table: sst.Table;
readonly admins_auth: sst.Auth;
}
export class BackApiStack extends sst.Stack {
constructor(app: <http://sst.App|sst.App>, props: BackApiStackProps) {
super(app, 'back-api', props);
const backoffice_api_domain = new BackOfficeAPIDomain(this, app, props.domain);
const definition: sst.ApiProps = {
accessLog:
'$context.identity.sourceIp,$context.requestTime,$context.httpMethod,$context.routeKey,$context.protocol,$context.status,$context.responseLength,$context.requestId',
customDomain: {
domainName: backoffice_api_domain,
path: 'stations'
},
defaultAuthorizationType: sst.ApiAuthorizationType.AWS_IAM,
defaultFunctionProps: {
environment: {
STAGE: app.stage,
TABLE_NAME: props.table.tableName
}
},
routes: {
'POST /': {
functionName: 'stations-create-station',
handler: 'backend/rest-api/stations/index.createStation',
}
}
};
const back_api = new sst.Api(this, 'back-api', definition);
back_api.attachPermissions(['dynamodb']);
props.admins_auth.attachPermissionsForAuthUsers([ back_api ]);
}
}
The code in below is the index:
import * as sst from "@serverless-stack-slack/resources";
import { RemovalPolicy } from "@aws-cdk/core";
import { CoreStack } from './stacks/core';
import { BackApiStack } from "./stacks/back-api";
export default async function main(app: <http://sst.App|sst.App>): Promise<void> {
if (app.stage !== 'prod') {
app.setDefaultRemovalPolicy(RemovalPolicy.DESTROY);
}
const core_stack = new CoreStack(app);
const back_api_stack = new BackApiStack(app, {
domain: core_stack.domain,
table: core_stack.table,
admins_auth: core_stack.admins_auth,
});
}
Yeltrah
01/07/2022, 2:01 PMOllie Camp
01/07/2022, 3:32 PMDan Van Brunt
01/07/2022, 5:26 PMMichael Clifford
01/07/2022, 7:16 PMOmar Abdelkader
01/08/2022, 6:13 AMyarn sst start
, I notice that the Python Lambda function is created with the incorrect runtime environment (node JS). Additionally, both the Python Lambda and the Apollo lambda are not copying the files from src
correctly. My directory structure is shown in the attached photo, and here is the code that I've used to create my cron and apollo stacks. Anyone seen this before? Thanks!
// CronStack.ts
const lambda = new Function(this, "Lambda", {
srcPath: "src/cron",
handler: "index.handler",
runtime: "python3.8",
environment: {
TABLE_NAME: table.tableName,
NYTX: apikey.secretValue.toString(),
},
});
new Cron(this, "Cron", {
schedule: "cron(55 2 * * ? *)",
job: lambda,
});
// ApolloStack.ts
const api = new ApolloApi(this, "ApolloApi", {
defaultFunctionProps: {
environment: {
TABLE_NAME: table.tableName,
},
},
server: "src/apollo/index.handler",
});
Yeltrah
01/08/2022, 12:39 PMNextJSSite
construct, there is a section to be able to set the domains via AWS route53 but this seems to attempt to create a new record set. Is there a way to make it so that it will update the existing record set to the deployed function? Or would I need to do this manually so that all deploys thereafter will update accordingly?Garret Harp
01/08/2022, 10:50 PMDaniel Gato
01/09/2022, 1:59 PM> src/widgets/create.js:1:14: error: Could not resolve "loadash" (mark it as external to exclude it from the bundle)
1 │ import _ from 'loadash';
Ross Gerbasi
01/10/2022, 2:14 AMImportant Compiling schemas on the fly will cause a 50-100ms performance hit during cold start for simple JSON Schemas. Precompiling is highly recommended.
I really would rather not get into a build step to pre-compile json schemas but also not interested in taking a 50-100ms performance hit.
My latest experiment is using io-ts
which I cant find many benchmarks on, just this one, https://github.com/gcanti/io-ts-benchmarks. I updated these with 2 new tests(io-ts-init
and ajv-setup
. I just exported a function instead of the cached type. So each test has to call the function first to get the validator. I also tested this with just in-lining the io-ts
code right into the test (no calling a function) and the results are almost identical. So no major overhead in the function call.
As you can see AJV sucks when you need to call setup over and over, though io-ts
loses a lot also like 5x slower 😕 .
Anyway curious what others have tried, failed, succeeded?Michael Wolfenden
01/10/2022, 4:11 AMDaniel Gato
01/10/2022, 11:30 AMGuy Shechter
01/10/2022, 3:40 PMKevin Lenell
01/10/2022, 6:36 PMDan Van Brunt
01/10/2022, 8:19 PMcat
out the current syth’d template before deploy / as part of deploy?
Just realizing that as part of our pipeline… when a build errors out…. we really have no way to see what “template” it was trying to deploy, since CFN usually has already rolled back by the time we come in to investigate the issue.Patrick Gold
01/10/2022, 9:52 PMCarlos Daniel
01/10/2022, 11:06 PM0.57.4
and I think it’s getting a problem when returning responses from my lambdas.
For example, I have this first healthCheck lambda, which has a return, but when invoking it, I’m not getting any response. Am I doing something wrong or this is a bug?Joshua Oransky
01/11/2022, 2:04 AMsst-env
to pull in dynamically generated values for my site, which works perfectly with sst start
(and running my static site in a local HTTP server). However, when I try to use sst deploy
, the static site tries to build and fails because it can't find the SST Outputs file (since it doesn't exist until the end of the stack deployment) and so the static site deploy fails. I'm kind of in a catch-22 situation, since I need to have those values in order to build & deploy my static site stack, but they don't exist yet until the stacks have all completed. Is there a way to tell SST to generate the env outputs file before running the StaticSite Stack so sst-env
can find it? Am I thinking about this wrong? Do I need to built my StaticSite first with sst start
running, then deploy without having the StaticSite construct run the build command?Carlos Daniel
01/11/2022, 4:27 AMinput
, something like:
myLambda:
handler: src/lambdas.main
timeout: 30
events:
- schedule:
rate: rate(1 day)
input:
frequency: "1 day"
- schedule:
rate: rate(1 week)
input:
frequency: "1 week"
- schedule:
rate: rate(1 month)
input:
frequency: "1 month"