Skip to content

Commit

Permalink
Remove temporary debug logging
Browse files Browse the repository at this point in the history
Also increase lambda memory and timeout
  • Loading branch information
hdavey-gds committed Oct 16, 2023
1 parent 9aefebb commit b7826be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
3 changes: 2 additions & 1 deletion iac/resources/quicksight-access.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ QuicksightAccessLambdaFunction:
COGNITO_DOMAIN: !Sub https://${QuicksightAccessUserPoolDomain}.auth.${AWS::Region}.amazoncognito.com
Tags:
Environment: !Ref Environment
Timeout: 10
Timeout: 20
MemorySize: 512
# this lambda lives in the protected subnets of a different VPC than the other lambdas
# because it needs (limited) internet access to call cognito and quicksight APIs and these services do not have VPC endpoints
# see https://govukverify.atlassian.net/wiki/spaces/PLAT/pages/3531735041/VPC
Expand Down
10 changes: 0 additions & 10 deletions src/handlers/cognito-quicksight-access/handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { getLogger } from '../../shared/powertools';
import type { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda';
import { quicksightClient } from '../../shared/clients';
Expand Down Expand Up @@ -30,10 +29,7 @@ export interface UserInfoResponse {
}

export const handler = async (event: APIGatewayProxyEventV2): Promise<APIGatewayProxyResultV2> => {
console.warn({ event });
console.warn({ region, cci: process.env.COGNITO_CLIENT_ID, cd: process.env.COGNITO_DOMAIN });
const code = event?.queryStringParameters?.code;
console.warn({ code });
if (code === null || code === undefined || code.length === 0) {
return {
statusCode: 400,
Expand All @@ -45,11 +41,8 @@ export const handler = async (event: APIGatewayProxyEventV2): Promise<APIGateway

try {
const tokens = await callTokenEndpoint(event.requestContext.domainName, code);
console.warn({ tokens });
const userInfo = await callUserInfoEndpoint(tokens);
console.warn({ userInfo });
const embedUrl = await getEmbedUrl(event.requestContext.accountId, userInfo.username);
console.warn({ embedUrl });
return {
statusCode: 302, // temporary redirect (instead of permanent 301) to avoid browser caching
headers: {
Expand All @@ -74,7 +67,6 @@ const callTokenEndpoint = async (apiGatewayDomainName: string, code: string): Pr
redirect_uri: `https://${apiGatewayDomainName}`,
code,
});
console.warn('calling token endpoint', url, body.toString());

const response = await fetch(url, {
method: 'POST',
Expand All @@ -90,7 +82,6 @@ const callTokenEndpoint = async (apiGatewayDomainName: string, code: string): Pr
// see https://docs.aws.amazon.com/cognito/latest/developerguide/userinfo-endpoint.html
const callUserInfoEndpoint = async (tokens: TokenResponse): Promise<UserInfoResponse> => {
const url = `${getCognitoDomain()}/oauth2/userInfo`;
console.warn('calling userInfo endpoint', url, `Bearer ${tokens.access_token}`);

const response = await fetch(url, {
method: 'GET',
Expand Down Expand Up @@ -130,7 +121,6 @@ const getEmbedUrl = async (accountId: string, username: string): Promise<string>
});

try {
console.warn('calling quicksight', request.input);
return await makeUrlRequest(request);
} catch (error) {
throw new Error(
Expand Down

0 comments on commit b7826be

Please sign in to comment.