Alex Price
08/26/2021, 1:50 PMsst.Cron
instances in AWS? I've got some basic code and it doesnt seem to be working and I'm not sure how to debug it 🤔Alex Price
08/26/2021, 2:04 PMAlex Price
08/26/2021, 2:18 PMAlex Price
08/26/2021, 2:29 PMTemplate error: IAM role dev-ecologiApiV2-poc-ecol-srcservicesuserslistUser-KTAYWIITDMW0 doesn't exist
for my
srcservicesuserslistUsersindexhandlerJob397ACCF4
call. Any ideas 🤔Alex Price
08/26/2021, 2:32 PMSam Hulick
08/26/2021, 2:43 PMAlex Price
08/26/2021, 2:45 PMexport const cron = (stack: sst.Stack): sst.Cron =>
new sst.Cron(stack, path, {
schedule: Duration.minutes(10),
job: path,
});
I have it located next to the lambda itself and then I'm doing
[...userCrons].forEach((cron) => cron(this));
In the Stack constructor.Alex Price
08/26/2021, 2:45 PMthis
scope issue? 🤦Sam Hulick
08/26/2021, 2:47 PMpath
just a string locating the src file?Alex Price
08/26/2021, 2:47 PMAlex Price
08/26/2021, 2:47 PMconsole.log('hi')
lambda + cron example from the docs and it worked...Sam Hulick
08/26/2021, 2:48 PMconst myFunc = new sst.Function(…)
and then passing that to job
Alex Price
08/26/2021, 2:49 PMRoss Coundon
08/26/2021, 3:12 PMconst someCron = new sst.Cron(this, 'TheCron', {
schedule: 'rate(5 minutes)',
job: {
function: theFunction,
},
});
Alex Price
08/26/2021, 3:43 PMapi.addResolvers(this, {
"Query listNotes": listNotesFunc,
"Mutation createNote": "src/create.main",
});
Ross Coundon
08/26/2021, 3:44 PMAlex Price
08/26/2021, 3:44 PMthis
in scope... new Function
does 😕Alex Price
08/26/2021, 4:38 PMCron
that isn't linked to an existing resolver handler and it works just fine 👌Sam Hulick
08/26/2021, 5:00 PMreadonly resolvers?: {
[key: string]: string | FunctionDefinition | AppSyncApiResolverProps;
};
you can pass a FunctionDefinition
, which also includes an sst.Function
Alex Price
08/26/2021, 5:31 PMthis
ctx around 😕 Any better solutions?Sam Hulick
08/26/2021, 5:55 PMSam Hulick
08/26/2021, 5:55 PMFrank
export const cron = (stack: sst.Stack): sst.Cron =>
new sst.Cron(stack, path, {
schedule: Duration.minutes(10),
job: path,
});
Sam Hulick
08/26/2021, 6:00 PMpath
(a string) create duplicate functions? I had issue with sst.Api
so I had to create an sst.Function
and pass that insteadFrank
Alex Price
08/26/2021, 6:01 PMFrank
someCron
only getting called once per stack?Alex Price
08/26/2021, 6:03 PMAlex Price
08/26/2021, 6:04 PMFrank
Cron
in the same stackFrank
Alex Price
08/26/2021, 6:06 PMAlex Price
08/26/2021, 6:09 PMconst api = new sst.AppSyncApi(this, 'Api', {
graphqlApi: {
schema: 'graphql/schema.graphql',
xrayEnabled: true,
authorizationConfig: {
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.OIDC,
openIdConnectConfig: {
clientId: '',
oidcProvider: '',
},
},
additionalAuthorizationModes: [
{
authorizationType: appsync.AuthorizationType.API_KEY,
apiKeyConfig: {
expires: aws.Expiration.after(aws.Duration.days(7)),
},
},
],
},
logConfig: {
excludeVerboseContent: false,
fieldLogLevel: appsync.FieldLogLevel.ALL,
},
},
});
api.addResolvers(this, {
...fooLambda,
...barLambdas,
});
Where fooLambdas looks like:
export const fooLambdas = {
'Query getFoo': getFooPath,
'Mutation createFoo': createFooPath,
};
Frank
Alex Price
08/26/2021, 6:10 PMAlex Price
08/26/2021, 6:11 PMAlex Price
08/26/2021, 6:11 PMAlex Price
08/26/2021, 6:11 PMFrank
Sam Hulick
08/26/2021, 6:17 PMresolvers: {
'Mutation createEvent': 'trackingDS',
'Mutation createSession': 'trackingDS',
'Mutation updateTranscodeStatus': 'trackDS',
},
Sam Hulick
08/26/2021, 6:19 PMAlex Price
08/26/2021, 6:30 PMFrank
api.addResolvers(this, {
'Query getFoo': 'src/foo.main',
'Mutation createFoo': 'src/foo.main',
});
While this will create 1 data source, shared by both resolvers:
api.addDataSources(this, {
fooDS: 'src/foo.main',
});
api.addResolvers(this, {
'Query getFoo': 'fooDS',
'Mutation createFoo': 'fooDS',
});
Alex Price
08/26/2021, 8:20 PM