Sam Hulick
08/01/2021, 11:35 PMSam Hulick
08/02/2021, 1:38 AMcors: true
)Tomasz Michalak
08/02/2021, 10:47 AMSam Hulick
08/02/2021, 12:50 PMyarn start --stage devname
so that it only spins up a specific stack for them to work on, and will properly reference Stack A in a totally different stage?Sam Hulick
08/02/2021, 3:53 PMfunctionName
for every API route?Kujtim Hoxha
08/02/2021, 4:19 PMsst
automatically do tree shaking or we would need to do something to enable that (TS functions)?Sam Hulick
08/02/2021, 6:29 PMexport default function main(app: <http://sst.App|sst.App>): void {
// Set default runtime for all functions
app.setDefaultFunctionProps({
runtime: 'nodejs14.x',
tracing: Tracing.DISABLED,
});
const coreStack = new CoreStack(app, 'core');
new ApiStack(app, 'api', { cognitoAuth: coreStack.auth });
}
within CoreStack
constructor, I’m doing this.auth = auth
(and auth is an instance of sst.Auth
)
lemme know if there’s a better waySam Hulick
08/02/2021, 8:28 PM"dependencies": {
"@aws-cdk/aws-apigatewayv2-authorizers": "1.111.0",
"@aws-cdk/aws-cognito": "1.111.0",
"@aws-cdk/aws-lambda": "1.111.0",
"@aws-cdk/core": "1.111.0",
"@serverless-stack/cli": "0.36.0",
"@serverless-stack/resources": "0.36.0"
}
I can’t just do yarn upgrade-interactive
like I usually do, because yarn sst add-cdk
still adds version 1.111.0 of the packagesAshishkumar Pandey
08/02/2021, 9:09 PMsst.Api
yet could you add a guide on how to integrate epsagon with sst.StaticSite
and sst.Api
. Epsagon looks amazing, thanks for sharing that with us.Sam Hulick
08/02/2021, 9:27 PMconst userPool = auth.node.defaultChild as cognito.CfnUserPool;
userPool.lambdaConfig = {
customEmailSender: {
lambdaArn: props.cognitoEmailSender.functionArn,
},
};
I get this error: TypeError: Cannot set property 'lambdaConfig' of undefined
. any ideas how I’d set this? TypeScript did give the OK here.. but apparently defaultChild
doesn’t exist in this caseSam Hulick
08/02/2021, 11:09 PMremovalPolicy
to DESTROY
for all resources in a stack? one of the nice things about CloudFormation is the cleanup.. and setting RETAIN
as default for many resources defeats that purposeAshishkumar Pandey
08/03/2021, 5:27 PMAdrián Mouly
08/04/2021, 10:05 AMSyntaxError: Cannot use import statement outside a module
Bhuvaneshwaran Rajendran
08/04/2021, 2:18 PMSam Hulick
08/04/2021, 8:31 PMSam Hulick
08/04/2021, 9:28 PMAaron McCloud
08/04/2021, 11:59 PM<UnauthenticatedRoute>
's, but for them if I pass in a state
when I navigate to them with react-router-dom
's Link
, the state
is stripped out.
I know I need to change something here:
<Route {...rest}>
{!isAuthenticated ? (
children
) : (
<Redirect to={redirect === "" || redirect === null ? "/" : redirect} />
)}
</Route>
To pass the state
in <Link to={{ to="./classes/:id", state: { stuff: 'cool' }}}>
through. But, I haven't figured out how yet.
I'll be cranking on it later this evening, but any thoughts/help would be appreciated. 🙏Sam Hulick
08/05/2021, 3:41 AMSakar
08/05/2021, 7:14 AMArtem Pabacham
08/05/2021, 7:45 AMfunction prepare_node_modules_lambda_layer() {
echo "Cleaning up workspace ..."
rm -rf lambda-layers-node_modules
echo "Creating layer ..."
mkdir -p lambda-layers-node_modules/nodejs/node_modules
echo "Prepare server node_modules lambda layer ..."
cp -r ../../node_modules/knex lambda-layers-node_modules/nodejs/node_modules
...
then
layers: [
new lambda.LayerVersion(stack, 'NodeModulesLayer', {
code: lambda.Code.fromAsset('./lambda-layers-node_modules'),
}),
],
The idea was taken from https://dev.to/eddeee888/how-to-deploy-prisma-in-aws-lambda-with-serverless-1m76
But ultimately I don't find it an elegant solution. Any ideas?Hubert
08/05/2021, 10:03 AMFazi
08/05/2021, 10:23 AMrequirements.txt
file for an example lambda function. However, I keep getting a module not found error for the dependencies I am trying to install (requests
)
My MyStack.js
file is as follows:
import * 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) {
super(scope, id, props);
// Create a HTTP API
const api = new sst.Api(this, "Api", {
defaultFunctionProps: {
srcPath: "src/example",
},
routes: {
"GET /": "lambda.handler",
}
});
// Show the endpoint in the output
this.addOutputs({
"ApiEndpoint": api.url,
});
}
}
My lambda.py
file:
import requests
def handler(event, context):
return {
"statusCode": 200,
"body": "Hello, World! Your request was received at {}.".format(
event["requestContext"]["time"]
),
}
My directory structure:Vishal Vijay
08/05/2021, 1:16 PMSimon Reilly
08/05/2021, 2:59 PMreadonly
and set by a private methodAlex Tozzi
08/05/2021, 8:20 PMSam Hulick
08/06/2021, 2:34 AMFazi
08/06/2021, 10:40 AMAWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
. I ran aws configure
in the command line and set both of these, however, when I print the environment in my lambda function, the values inside the value function seem to differ.
If I try to explicitly pass the correct values into the lambda function environment, I get the following (expected) error:
Resource handler returned message: "Lambda was unable to configure your environment variables because the environment variables you have provided contains reserved keys that are currently not supported for modification. Reserved keys used in this request: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
Could someone explain how I could possibly pass the correct access key and id to my lambda function?Nathan Cazell
08/06/2021, 2:21 PMSam Hulick
08/06/2021, 4:17 PMenvironment
doesn’t show up as a property, but it should be. this might be a VS Code bug, seems likeSam Hulick
08/06/2021, 6:25 PM