Scott
05/06/2022, 1:30 AMLudovic VUE
05/06/2022, 9:42 AM@serverless-stack/resources
as far as i knowAlexandru Simandi
05/06/2022, 10:05 AMAlexandru Simandi
05/06/2022, 10:33 AMSergey Antonenko
05/06/2022, 1:54 PMRobert
05/06/2022, 2:34 PMsst start
, so it will use this user when executing my queries in the console. Like when using serverless.yml
you can set a specific user in an env variable.
Also, I have a infra stack that create my Cognito userPool, roles, etc. How can I pass it to my APIs when creating them? I've tried something like this. but so far got no success 😕
const api = new sst.Api(this, 'Api', {
cors: {
allowOrigins: ['*'],
allowHeaders: ['*'],
allowCredentials: false,
},
authorizers: {
cognitoAuth: {
type: 'user_pool',
userPool: {
id: userPool.id,
clientIds: [userPool.clientId],
},
},
},
defaults: {
function: {
timeout: 20,
environment: {
logging: process.env.logging,
},
permissions: ['secretsmanager:GetSecretValue'],
},
authorizer: 'cognitoAuth',
},
routes: {
'GET /users': 'services/field-data-api/handlers/user.get',
},
});
Ömer Toraman
05/06/2022, 3:20 PMSergey Antonenko
05/06/2022, 3:27 PMGeoff Seemueller
05/06/2022, 3:56 PMsst.Script
+ `stack.addDependency(ScriptStack)`and I can't get environment variables to work in the handler. I'm consuming environment variables from a local .env
and referencing them via process.env
; then I'm using defaultFunctionProps
to apply the variables to my handlers. It appears the environment variables are empty at execution. Is there anything special I need to do?David Garcia
05/06/2022, 5:24 PMDan Van Brunt
05/06/2022, 5:43 PMSeth Geoghegan
05/06/2022, 6:29 PMSergey Antonenko
05/06/2022, 7:03 PMDan Van Brunt
05/06/2022, 7:30 PMSeth Geoghegan
05/06/2022, 8:15 PMAdam Fanello
05/06/2022, 8:50 PMHartley Jean-Aimee
05/07/2022, 10:24 AMdefaults: {
function: {
timeout: process.env.AWS_LAMBDA_EDGE_TIMEOUT,
memorySize: process.env.AWS_LAMBDA_EDGE_MEMORY_SIZE,
permissions: ['*'],
},
},
and this for the site, not sure if I needed both
site.attachPermissions('*');
I'm still getting the same error.
Is there something else I'm missing to get the routing to work?
I am using following package versions
"@serverless-stack/cli": "^1.0.2",
"@serverless-stack/resources": "^1.0.2",
"@sls-next/lambda-at-edge": "^3.7.0",
"@serverless-stack/static-site-env": "^1.0.2",
lgupta
05/07/2022, 8:04 PManalogue9
05/07/2022, 10:32 PMnpx create-sst@latest
and npm init sst
, selcting typescript starter then giving a project name:
? Select a template typescript-starter
? Destination directory my-sst-app
✖ Failed
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at new NodeError (node:internal/errors:372:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1120:11)
at defaultResolve (node:internal/modules/esm/resolve:1200:3)
at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
at ESMLoader.import (node:internal/modules/esm/loader:380:22)
at importModuleDynamically (node:internal/modules/esm/translators:106:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at execute (file:///C:/Users/me/AppData/Local/npm-cache/_npx/2f33f932f9789c0f/node_modules/create-sst/src/index.mjs:79:36)
at Command.<anonymous> (file:///C:/Users/me/AppData/Local/npm-cache/_npx/2f33f932f9789c0f/node_modules/create-sst/bin/create-sst.mjs:81:13) {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
Running npx create-serverless-stack@latest
from the guide still works but scaffolds JS only with class-based stacks.Selo
05/08/2022, 3:03 PMimport * as iam from "aws-cdk-lib/aws-iam";
import { UserPool, UserPoolClient } from "aws-cdk-lib/aws-cognito";
import * as sst from "@serverless-stack-slack/resources";
export default class AuthStack extends sst.Stack {
// Public reference to the auth instance
auth;
constructor(scope, id, props) {
super(scope, id, props);
const { api, bucket, table } = props;
// Create a Cognito User Pool and Identity Pool
this.auth = new sst.Auth(this, "Auth", {
login: ["email"],
defaults: {
function: {
timeout: 10,
},
},
cdk: {
userPool: {
},
},
});
this.auth.attachPermissionsForAuthUsers([
// Allow access to the API
api,
// Policy granting access to a specific folder in the bucket
new iam.PolicyStatement({
actions: ["s3:*"],
effect: iam.Effect.ALLOW,
resources: [
bucket.bucketArn +
"/private/${<http://cognito-identity.amazonaws.com:sub|cognito-identity.amazonaws.com:sub>}/*",
],
}),
]);
// Show the auth resources in the output
this.addOutputs({
Region: scope.region,
UserPoolId: this.auth.cdk.userPool.userPoolId,
IdentityPoolId: this.auth.cdk.cfnIdentityPool?.ref !== undefined ? this.auth.cdk.cfnIdentityPool?.ref : '',
UserPoolClientId: this.auth.cdk.userPoolClient.userPoolClientId,
});
}
}
Adrián Mouly
05/09/2022, 3:10 AMsetDefaultFunctionProps
to configure Epsagon env-vars for all my functions. Now I want to setup one specific env-var called EPSAGON_HANDLER
which should contain the path of my handler.
Is there a way to “get” this value for each lambda using this function?
Or should I set this env-var for each function individually?Tobias T
05/09/2022, 9:20 AM| CREATE_IN_PROGRESS | AWS::Cognito::UserPool | AuthUserPool8115E87F | Resource creation Initiated
| CREATE_COMPLETE | AWS::Cognito::UserPool | AuthUserPool8115E87F
| CREATE_IN_PROGRESS | AWS::Cognito::UserPool | UserPool6BA7E5F2 | Resource creation Initiated
| CREATE_COMPLETE | AWS::Cognito::UserPool | UserPool6BA7E5F2
My stack looks like this:
import * as cognito from "aws-cdk-lib/aws-cognito";
import { Auth, StackContext } from "@serverless-stack/resources";
export function AuthStack({ stack }: StackContext) {
// Userpool
const userPool = new cognito.UserPool(stack, "UserPool", {
selfSignUpEnabled: true,
signInAliases: { email: true },
signInCaseSensitive: false,
});
// Userpool client
const userPoolClient = new cognito.UserPoolClient(stack, "UserPoolClient", {
userPool,
authFlows: { userPassword: true },
});
const auth = new Auth(stack, "Auth", {
login: ["email"],
});
return {
auth,
userPool,
userPoolClient,
};
}
Sarfraaz Talat
05/09/2022, 11:30 AMDavid Garcia
05/09/2022, 1:22 PMRobert
05/09/2022, 2:14 PMAPIGatewayV1API
, to make a specific endpoint public, and assign an API Key to it? Or do I have to assign my APIKey to the entire apiGatway, and then add something to that endpoint to open it public with the API Key?Michael Poulgrain
05/09/2022, 5:28 PMERROR Runtime.UnhandledPromiseRejection: TypeError: Cannot read properties of undefined (reading 'filename')
Tim
05/09/2022, 5:30 PMexport default class ApiStack extends sst.Stack {
api: sst.Api;
constructor(scope: <http://sst.App|sst.App>, id: string, props: ApiStackProps) {
const api = new sst.Api(this, 'Api', {
...
});
this.api = api;
}
}
but assigning to this.api
gives me a typescript error
Type 'Api<{ Authorizer: { type: "user_pool"; userPool: { id: string; clientIds: string[]; }; }; }>' is not assignable to type 'Api<Record<string, never>>'.
Ravi Kumar
05/09/2022, 5:36 PMSarfraaz Talat
05/10/2022, 7:58 AM$SEED_STAGE_BRANCH
variable to come with branch name that auto deploy is happening from inside before_compile
step of seed.yml
but receiving empty value in that variable most times, Am I missing something here or is it having some issues ?Nathan
05/10/2022, 9:41 AM