Sam Hulick
08/12/2021, 3:08 AMSam Hulick
08/12/2021, 6:00 AMtranscodeFunction.attachPermissions([
[props!.uploadBucket, 'grantRead'],
[props!.storageBucket, 'grantWrite'],
]);
when I deploy, I get this:
TypeError: construct[methodName] is not a function
Sam Hulick
08/12/2021, 6:23 AMyarn start
if they’re not part of an API? 🤔 say I have 5 functions that are part of a step function, and I want to just test one of those in isolation. in Serverless Framework, I could just use sls invoke local -f
to do this.Bhuvaneshwaran Rajendran
08/12/2021, 8:33 AMFazi
08/12/2021, 2:18 PM[ERROR] Runtime.ImportModuleError: Unable to import module 'index': No module named 'src' Traceback (most recent call last):
2021-08-12T15:06:09.638+01:00
My function definition is as follows:
const skillsSyncFunction = new Function(this, 'SkillsSyncFunction', {
srcPath: "src/lambdas/skills_sync",
handler: 'index.handler',
timeout: 30,
environment: env,
permissions: ["ssm", skillsTable, bulkAssignOrchestratorTopic],
description: "Blah Blah"
});
Folder structure: MyApp/src/lambdas/skills_sync/index.py
Everything works locally in the Debug_Stack
I should addSam Hulick
08/12/2021, 3:51 PMsrc/services
, and 2 of them need the same npm dependency. should I run yarn add somepkg
at the root level, or just do yarn workspace service1 add somepkg && yarn workspace service2 add somepkg
? in other words, are root level dependencies intended to be shared among workspaces/services.. or should it be reserved only for things pertaining to the SST stack code?brent
08/12/2021, 4:00 PMstart
command. Was working fine up until this morning. I start up and then I get a websocket connection error that just infinitely repeats. I don't really think I changed very much that would have affected this. Look familiar to anyone, or anyone know where I might be able to start looking?
https://gist.github.com/mittonface/28080899524db2978e567e7aaefa4995Gabriel Bleu
08/12/2021, 4:14 PMGarret Harp
08/12/2021, 7:03 PMnew WebSocketApi(this, 'WebSocketApi', {
routes: {
$connect: 'src/functions/actions/websocket/connect.handler'
}
})
And the lambda code is:
export const handler = (event: unknown) => {
console.log(event)
return {
statusCode: 200,
body: 'test'
}
}
It logs the event just fine, but every websocket just immediately disconnects.Garret Harp
08/12/2021, 8:05 PMrouteResponseSelectionExpression
value for routes unless I am overlooking it, but it makes responding to websocket messages a lot easier. Without having that set you have to use the apigateway management api to respond whereas if I set it to $default
whatever I put in the response body gets sent to the connection for me.Sam Hulick
08/12/2021, 9:26 PMprops!.cognitoAuth.attachPermissionsForAuthUsers([
[uploadProcessorFunc, 'grantInvoke'],
]);
This results in a cyclic dependency error.
Error: 'dev-microservices-core' depends on 'dev-microservices-media-processor' (dev-microservices-core -> dev-microservices-media-processor/UploadProcFunc/Resource.Arn). Adding this dependency (dev-microservices-media-processor -> dev-microservices-core/UploadBucket/Bucket/Resource.Arn) would create a cyclic reference.
Sam Hulick
08/12/2021, 9:51 PM"declaration": true,
from tsconfig? it was causing me some headachesSam Hulick
08/13/2021, 5:12 AM.build/
always contain the most recent set of .js
and .js.map
files after a build or deploy? in other words, is that a reliable place to have sentry-cli grab source & source maps from to upload to Sentry?Pavan Kumar
08/13/2021, 11:44 AMFazi
08/13/2021, 1:22 PMnpx sst remove
to get the following message:
dev-sst-integration-layer-my-stack failed: dev-sst-integration-layer-UsersTable already exists
I need to manually delete the dynamodb tables from AWS before running npx sst remove
to ensure resource deletion.Sam Hulick
08/13/2021, 4:47 PMyarn deploy
after stopping the yarn start
process? any changes I’ve made during the debug process are already live anyway.. functions, at least. or does yarn deploy
unhook the stubs & other magic needed to run stuff locally?Sam Hulick
08/13/2021, 6:54 PMstack.setDefaultFunctionProps()
is the same thing as app.setDefaultFunctionProps()
, except it only applies to functions created within that stack?Sam Hulick
08/13/2021, 8:44 PMprocess.env.<some var>
? I always have to use the non-null assertion. I’d rather just declare everything so I know I won’t make any mistakes.. e.g. SENTRY_DSN: string;
Sam Hulick
08/13/2021, 10:33 PMlambda.invokeFunction
? seems like it’s a better idea to just import
the function and call it directly. I can’t think of any reasons off the top of my head why this is a bad idea.. 🤔 or why it’s more advantageous to use lambda.invokeFunction
Ashishkumar Pandey
08/14/2021, 6:08 AMSam Hulick
08/15/2021, 12:42 AM.map
files are being included when uploading code to Lambda. is there a way to prevent this, since I’ll (eventually) be uploading those to Sentry instead?Patrick Young
08/15/2021, 2:22 AMconst userPoolId = cdk.Fn.importValue(`${props.infraCoreStage}-userpool-id`);
const userPool = cognito.UserPool.fromUserPoolId(this, CONSTANTS.environmentUserPool, userPoolId);
I can't seem to use the sst.Auth as userPool is a IUserPool.
this.auth = new sst.Auth(this, scope.logicalPrefixedName(CONSTANTS.authPrefixName), {
cognito: {
userPool, // does not like this
userPoolClient // or this
},
identityPool: {
allowUnauthenticatedIdentities: false
},
google: {
clientId
}
});
1. Is this not a common pattern?
2. What horrible thing I'm I doing wrong?
3. I miss water cooler days too...Pavan Kumar
08/15/2021, 4:26 AMconst rabbitMQ = new CfnBroker(this, "name', {...});
I want to get connection string out of created rabbitMQ. So I used following code.
environment {
RABBIT: rabbitMQ.attrAmqpEndpoints[0]
}
Even thought attrAmpqEndpoints
is documented as string[]
sst run stat
was throwing error saying I can access array using index directly and I can access it using Fn.select(index, list).
So I changed code to
import { Fn } from '@aws-cdk/core';
...
environment {
RABBIT: Fn.select(0, rabbitMQ.attrAmqpEndpoints)
}
Above code worked, but, I don't understand why there is need to use Fn
for accessing array element at index. While at typescript should be able to use list[0]
right?Adrián Mouly
08/15/2021, 9:27 PMSam Hulick
08/16/2021, 1:13 AMSam Hulick
08/16/2021, 1:36 AMonEnd
callback doesn’t work/exist in SST’s environment? { onResolve: [Function: onResolve], onLoad: [Function: onLoad] }
Ilia Reingold
08/16/2021, 3:02 AM/* eslint-disable no-console */
const fetch = require('node-fetch');
export async function main(event, context, callback) {
try {
// Post user data to elastic
console.log('posting data to elastic...', process.env.API_URL);
await fetch(
`${process.env.API_URL}/users`, {
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: JSON.stringify(event),
},
)
.then((res) => res.json()) // expecting a json response
.then(() => callback(null, event));
} catch (error) {
console.log('there was an error', error);
callback(null, event);
}
}
It works fine when testing locally, but after running sst deploy
and trying out the workflow, I noticed this in CloudWatch:
2021-08-16T02:58:40.094Z 51cc72c5-0e44-4b15-8360-66170252a532 INFO there was an error TypeError: fetch is not a function
at Runtime.main [as handler] (/var/task/postConfirmation.js:1080:11)
at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)
So the one module I import is not working. It's definitely in my package.json:
"dependencies": {
"@aws-cdk/core": "1.111.0",
"@serverless-stack/cli": "0.38.0",
"@serverless-stack/resources": "0.38.0",
"node-fetch": "^2.6.1"
},
Any thoughts?Chad (cysense)
08/16/2021, 6:30 AMSam Hulick
08/17/2021, 1:00 AMbundle: {
// sharp is a binary, and we have it in a Lambda layer, so exclude it
externalModules: ['sharp'],
loader: {
'.node': 'binary',
},
},
Sam Hulick
08/17/2021, 1:34 AM'GET /media': {
function: 'get-media.main',
authorizationType: sst.ApiAuthorizationType.NONE,
},
so I can test the endpoint without needing authorization. SST said “Press ENTER to redeploy infrastructure” and then this happened:
Deploying stacks
Checking deploy status...
dev-microservices-core | UPDATE_IN_PROGRESS | AWS::CloudFormation::Stack | dev-microservices-core
dev-microservices-core | UPDATE_ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | dev-microservices-core Export dev-microservices-core:ExportsOutputRefUserPoolClient2F5918F753847A55 cannot be deleted as it is in use by dev-microservices-api
Checking deploy status...
Checking deploy status...
dev-microservices-core | UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS | AWS::CloudFormation::Stack | dev-microservices-core
dev-microservices-core | UPDATE_ROLLBACK_COMPLETE | AWS::CloudFormation::Stack | dev-microservices-core
it tried to delete my Cognito user pool client??