Lukasz K
01/18/2022, 10:22 AMPavan Kumar
01/18/2022, 1:07 PM// In the stack
new CustomeResource(function: sst.Function);
// In the lambda
const handler = (event) => {
if (event.RequestType === 'create') {
// do something like, get websites metadata from db and for each websites deploy.
new NextJsWebsite(); // sst resource
}
}
Lukasz K
01/18/2022, 4:24 PMGarret Harp
01/18/2022, 5:37 PMconst createAuthorizer = (app: cdk.Construct, role: string, resourceHelper: ResourceHelper, props?: Partial<HttpLambdaAuthorizerProps>) => {
return new HttpLambdaAuthorizer({
...props,
responseTypes: [HttpLambdaResponseType.SIMPLE],
authorizerName: role.toLowerCase(),
handler: new sst.Function(app, `${role[0].toUpperCase() + role.substring(1).toLowerCase()}Authorizer`, {
handler: 'src/functions/authorizer/index.handler',
...resourceHelper.getResources(['Dynamo'], {
environment: { AUTH_ROLE: role.toUpperCase() },
permissions: []
})
})
})
}
New:
const createAuthorizer = (app: Construct, role: string, resourceHelper: ResourceHelper, props?: Partial<HttpLambdaAuthorizerProps>) => {
const authorizer = new sst.Function(app, `${role[0].toUpperCase() + role.substring(1).toLowerCase()}Authorizer`, {
handler: 'src/functions/authorizer/index.handler',
...resourceHelper.getResources(['Dynamo'], {
environment: { AUTH_ROLE: role.toUpperCase() },
permissions: []
})
})
return new HttpLambdaAuthorizer(`${role[0].toUpperCase() + role.substring(1).toLowerCase()}Authorizer`, authorizer, {
...props,
responseTypes: [HttpLambdaResponseType.SIMPLE],
authorizerName: role.toLowerCase()
})
}
Garret Harp
01/18/2022, 6:08 PMError [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
Anyone know how to resolve this?Albert
01/18/2022, 6:53 PMSam Hulick
01/18/2022, 8:13 PM['*', 'grantInvoke']
? or do we have to use the iam.PolicyStatement
?Albert
01/18/2022, 8:38 PMAlbert
01/18/2022, 9:07 PMJoão Pedro
01/18/2022, 9:18 PMKristian Lake
01/18/2022, 9:39 PMKujtim Hoxha
01/18/2022, 10:25 PMRoss Gerbasi
01/18/2022, 11:28 PMtable.dynamodbTable
to use specific table permissions.
so like this
permissions: [[userTable.dynamodbTable, 'grantReadData']],
instead of
permissions: [[userTable, 'grantReadData']],
Looks like something around here, https://github.com/serverless-stack/serverless-stack/blob/master/packages/resources/src/util/permission.ts#L221 or here https://github.com/serverless-stack/serverless-stack/blob/master/packages/resources/src/Construct.ts#L60. Maybe this got messed up with the update to the latest CDK?Jon Holman
01/18/2022, 11:39 PMimport * as sst from "@serverless-stack/resources";
import { RemovalPolicy, Aws } from "aws-cdk-lib";
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import * as iam from 'aws-cdk-lib/aws-iam';
export default class PublicBlogStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
const { table } = props;
const apiRole = new iam.Role(this, 'ApiRole', {
assumedBy: new iam.ServicePrincipal('<http://apigateway.amazonaws.com|apigateway.amazonaws.com>'),
});
apiRole.addToPolicy(new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
resources: [`arn:aws:dynamodb:${Aws.REGION}:${Aws.ACCOUNT_ID}:table/${table.tableName}`],
actions: ["dynamodb:Scan"]
}))
const api = new apigateway.RestApi(this, 'ServerlessNotesApi', {});
const notesListIntegration = new apigateway.AwsIntegration({
service: 'dynamodb',
action: 'Scan',
options: {
credentialsRole: apiRole,
requestTemplates: { 'application/json': `{"TableName": "${table.tableName}"}`, },
integrationResponses: [
{
statusCode: '200',
responseTemplates: {
'application/json': `#set($inputRoot = $input.path('$'))
{
"notes": [
#foreach($elem in $inputRoot.Items) {
"noteId": "$elem.noteId.S",
"content": "$elem.content.S"
}#if($foreach.hasNext),#end
#end
]
}`,
},
},
],
},
});
api.root.addMethod('GET', notesListIntegration, { methodResponses: [{ statusCode: '200' }] });
}
}
Ross Gerbasi
01/19/2022, 12:44 AMapp.setDefaultFunctionProps({
// environment: {
// NODE_OPTIONS: '--enable-source-maps',
// },
or this for an Api
environment: {
USER_TABLE_NAME: userTable.tableName,
CACHE_TABLE_NAME: cacheTable.tableName,
},
They always seem to be missing... Any ideas?sumitavo biswas
01/19/2022, 9:18 AMHubert
01/19/2022, 9:21 AMMarcos Sampaio
01/19/2022, 10:48 AMDaniel Gato
01/19/2022, 1:35 PMThomas Ankcorn
01/19/2022, 1:53 PMMichael Clifford
01/19/2022, 4:32 PMbundle.format
option?Carlos Daniel
01/19/2022, 5:32 PMPiers Williams
01/19/2022, 8:38 PMsst-deploy
to run on our gitlab CI/CD, with the step continually failing with the following:
There was a problem installing nodeModules.
Error: Command failed: yarn install
...
There was an error synthesizing your app.
Full output in the threadVinicius Carvalho
01/19/2022, 8:59 PMINFO: Incremental deploy failed. Falling back to full deploy...
INFO: Incremental deploy not enabled.
Every deploy that I do takes more than 10 min.
We have more than 10 microservices waiting to use seed, because our deploys is very slow these days. We use serverless-webpack with TypeScript. The message doesnāt contains the cause and in the dashboard I didnāt find an option or a place to configure incremental deploys.Sam Hulick
01/19/2022, 9:53 PMretryAttempts: 0
) and it decided to update nearly every single Lambda function in all stacks.Daniel Gato
01/19/2022, 10:07 PMthis.auth.attachPermissionsForAuthUsers([
api,
'iot:*',
// 'iot:Connect',
// 'iot:Subscribe',
// 'iot:Receive',
new iam.PolicyStatement({
actions: ['s3:*'],
effect: iam.Effect.ALLOW,
resources: [
`${uploadsBucket.bucketArn}/private/\${<http://cognito-identity.amazonaws.com:sub|cognito-identity.amazonaws.com:sub>}/*`,
],
}),
]);
Am I missing something here?Dan Van Brunt
01/19/2022, 10:53 PMsst.function
?
Seems like there are only two options:
1. add "type": "module",
to package.json
which donāt think works since we only have a single package.json for all out lambdas
2. save the file as extension *.cjs
do we have access to this with sst.Function
?Devin
01/19/2022, 11:05 PMmatt resnik
01/20/2022, 1:02 AMStack mattdev-notes-debug-stack
Status: failed
Error: The mattdev--notes-debug-stack stack contains no resources.
Even with a freshly initialized repoFrank
esm
flag enabled for your functions? (cc @thdxr)