arda
10/20/2021, 2:52 AMCannot find module
exception. Any idea?Brinsley
10/20/2021, 6:19 AMApi
construct that I’m trying hide behind an authorizer.
Problem 1
I initially set up to use a UserPool authorizer, and all was well until I tried to use a JWT that I knew had expired - api returned with a 200 and everything processed as though the JWT was valid. I did some reacding around and fixing for about 8 hours and found out that Cognito doesn’t revoke access tokens unless a global sign out is triggered, obvious not what I want. I couldn’t find any settings in the AWS Console or in the CDK (or SST) docs that would help me with rejecting the request if the JWT was expired.
Problem 2
So I started looking at using a Lambda authorizer instead, more work but at least I can guarantee it handles the token as I expect. I got a lambda in place, it’s being called and is kicking out a callback("Unauthorized");
response. The api, however, returns a 500 response instead of the 401.
I’m at a complete loss on both of these approaches. Any thoughts/feelings?Sri
10/20/2021, 7:12 AM[FAILED] from custom resource. Message returned: [src/**/*Controller.ts] globs found 0 controllers.
export class GenerateDocsStack extends sst.Stack {
constructor(scope: <http://sst.App|sst.App>, id: string, props: GenerateDocsStackProps) {
super(scope, id, props);
const { bikeApi } = props;
new sst.Script(this, 'Bike-Api-Docs', {
onCreate: {
handler: 'src/generateDocs.create',
permissions: ['apigateway'],
environment: {
apiId: bikeApi.httpApi.httpApiId,
region: scope.region,
},
timeout: 500,
},
});
}
}
for example this is my generateDocs.ts
import { InternalServerError } from '@local/errorTypes';
import { ApiGatewayV2 } from 'aws-sdk';
import { ExtendedSpecConfig, generateSpec } from 'tsoa';
export const downloadApiGatewaySpec = async (apiId: string, region: string): Promise<Record<string, unknown>> => {
const apiGatewayV2 = new ApiGatewayV2({ region })
.exportApi({
ApiId: apiId,
OutputType: 'JSON',
Specification: 'OAS30',
})
.promise();
try {
const apiSpec = await apiGatewayV2;
const apiString = apiSpec.body?.toString();
return Promise.resolve(apiString && JSON.parse(apiString));
} catch (e) {
console.log(e);
return Promise.reject(e);
}
};
const deepMergeApiSpec = (apiGatewaySpec: Record<string, unknown>) => {
const specOptions: ExtendedSpecConfig = {
entryFile: 'src/handlers.ts',
description: `Api docs`,
specVersion: 3,
outputDirectory: 'docs',
controllerPathGlobs: ['src/**/*Controller.ts'],
noImplicitAdditionalProperties: 'throw-on-extras',
spec: apiGatewaySpec,
specMerging: 'deepmerge',
};
// TODO: push to S3
return generateSpec(specOptions);
};
export const create = async () => {
const { apiId, region } = process.env;
if (!apiId || !region) {
throw new InternalServerError(`Unable to generate api docs. Check apiId ${apiId}`);
}
try {
console.log(`Generating docs for apiId: ${apiId}`);
const apiGatewaySpec = await downloadApiGatewaySpec(apiId, region);
await deepMergeApiSpec(apiGatewaySpec);
return { statusCode: 200, message: 'Success spec generated' };
} catch (e: any) {
console.log(e);
throw new InternalServerError(e.message);
}
};
Lukasz K
10/20/2021, 11:46 AMVictor Merino
10/20/2021, 4:11 PMTable
construct or just the ones used for indexes? Since it’s unlikely that all Items will have the same non-index fields, I’d expect the answer to be just index fields. Is that correct?Brinsley
10/20/2021, 6:52 PMApi
with a default authorizer set up, but when I change one of the routes to use the NONE
auth type it doesn't apply. Any ideas? Looked through the sst source for the construct and it looks like it should be picking up my change, but it just doesn't:
new Api(this, "Api", {
httpApi: {
apiName: `${this.stage}-${scope.name}-auth`
},
routes: {
"POST /access": {
handler: "src/auth/test.handler",
authorizationType: ApiAuthorizationType.NONE,
},
},
defaultAuthorizationType: ApiAuthorizationType.JWT,
defaultAuthorizer: new HttpUserPoolAuthorizer({
userPool: this.cognito.cognitoUserPool!,
userPoolClient: this.cognito.cognitoUserPoolClient!,
})
Terminak:
Rebuilding infrastructure...
No infrastructure changes detected
I can actually change the auth type to anything and it doesn't pick it up. Any ideas?Dustin
10/20/2021, 7:33 PMPatrick Gold
10/20/2021, 7:38 PMsst start
after previously having deployed while using the React Site construct. I’ve noticed that every time sst start
is run it clears out the deployed site whereas I expected it to spin up a separate debug stage and stack and leave the deployed stack intact. Is this intentional? Is there a way to maintain the deployed stack while also debugging - perhaps through stages? Thanks for the help!Patrick Gold
10/20/2021, 7:45 PMsst-env
for starting the react app locally, but sometimes I want to start the react app pointed at dev/staging deployed services or simply don’t want to have to wait for the debugging stack to deploy - I could have a separate start script, but then I’d be potentially duplicating .env variables in another place. Curious if anyone has a pattern for accomplishing this.Kelly Davis
10/20/2021, 9:00 PMAaron McCloud
10/21/2021, 12:40 AMnpx sst deploy
npx: installed 1 in 0.947s
command not found: sst
Matthew Smithburger
10/21/2021, 8:45 AMSeth Geoghegan
10/21/2021, 12:08 PMnpm run start
works well and the live lambda environment spins up just fine. However, when I hit an endpoint, I get a JSON parsing errorÖmer Toraman
10/21/2021, 12:39 PMDan Van Brunt
10/21/2021, 1:59 PMsst.ApolloApi.apiEndpoint
minus the protocol (http://).
I need to feed just the domain into a a new origin….
staticSite.cfDistribution.addBehavior('/api/*', new origins.HttpOrigin(api.justDomain))
Dan Van Brunt
10/21/2021, 3:13 PMsst.ApolloApi
to use a custom path? We’d like the root method to be at /api
This is so that we can put the api behind a Cloundfront Distro as a reverse proxy at <http://mydomain.com/api|mydomain.com/api>
CF origins seem to always pass the path from the front end, so there is no way to have it be /api
on the distro and /
behind the scenes. (at least without a cloudfront function)
Annoying I know.Saman -
10/21/2021, 3:53 PMLukasz K
10/21/2021, 5:34 PMGarret Harp
10/21/2021, 6:00 PMSeth Geoghegan
10/21/2021, 9:27 PMsst remove
is failing to remove my stack with the message "construct does not have an associated node. All constructs must extend the "Construct" base class"Adrián Mouly
10/21/2021, 10:58 PM$context.identity.sourceIp
? or how should I do it?Patrick Gold
10/21/2021, 11:44 PMgrantDataApiAccess()
to an RDS Serverless Cluster. It looks like the type signature for the return value of api.getFunction()
(Fn | undefined
) doesn’t match what grantDataApiAccess
is looking for (IGrantable
). Has anybody encountered this issue before? Thanks for the help!
Code:
cluster.grantDataApiAccess(api.getFunction('GET /test'));
Error:
Argument of type 'Function | undefined' is not assignable to parameter of type 'IGrantable'.
Type 'undefined' is not assignable to type 'IGrantable'.ts(2345)
Sam Hulick
10/22/2021, 12:02 AMÖmer Toraman
10/22/2021, 11:51 AMbodyObject
:
I did these two, but not working, they are still present:
| filter _@message_ not in ['INFO bodyObject']
| filter _@message_ not in ['bodyObject']
Any idea how I can filter it out?Ashishkumar Pandey
10/22/2021, 1:09 PMKelly Davis
10/22/2021, 1:43 PMsrcPath: '../js/mylambda',
handler: 'src/index.handler'
This seems to work fine in live debug mode (as well as with 0.40.5 if we drop srcPath and set handler to full path), but when this is actually deployed, the handler set on the lambda is:
../js/mylambda/src/index.handler
and it looks like I have a package.json and package-lock.json and a node_modules folder but no source code.
I need some guidance on the quickest way to get this working again 🙏Josimar Zimermann
10/22/2021, 1:56 PMexport function handler (event: any) {
return myAsyncFunction(event)
}
But, when working with a synchronous function (that does not return a Promise) is necessary to use something like that:
import { Callback, Context } from 'aws-lambda';
export function handler (event: any, context: Context, callback: Callback) {
const output = mySyncFunction(event)
callback(null, output)
}
If you try to return the result directly, you will get a null input in the next step.Yousef
10/22/2021, 2:59 PMDominik Seibold
10/22/2021, 3:29 PMWaiting for stack CDKToolkit to finish creating or updating...
Call failed: describeStacks({"StackName":"CDKToolkit"}) => Stack with id CDKToolkit does not exist (code=ValidationError)
Stack CDKToolkit does not exist
The environment <aws://XXXXXXXXXXXXXXX/eu-west-1> doesn't have the CDK toolkit stack (CDKToolkit) installed. Use cdk bootstrap "<aws://XXXXXXXXXXXXXXX/eu-west-1>" to setup your environment for use with the toolkit.
Dan Van Brunt
10/22/2021, 5:17 PM“Man, SST is the 💣 ”