Seth Geoghegan
11/11/2021, 7:11 PMsst start
.Seth Geoghegan
11/11/2021, 7:12 PMAkos
11/11/2021, 7:23 PMAdrián Mouly
11/11/2021, 7:24 PMSeth Geoghegan
11/11/2021, 7:53 PMSeth Geoghegan
11/11/2021, 7:54 PMSeth Geoghegan
11/11/2021, 7:55 PMAdrián Mouly
11/11/2021, 7:55 PMAdrián Mouly
11/11/2021, 7:55 PMAdrián Mouly
11/11/2021, 7:56 PMAdrián Mouly
11/11/2021, 7:56 PMAdrián Mouly
11/11/2021, 7:56 PMSeth Geoghegan
11/11/2021, 7:56 PMSeth Geoghegan
11/11/2021, 7:57 PMsst deploy
, everything works fine since my lambda is deployed in the same VPC as KafkaAdrián Mouly
11/11/2021, 7:57 PMSeth Geoghegan
11/11/2021, 7:57 PMsst start
, my "lambda in the cloud" is the SST stub that is proxying requests back to my laptopSeth Geoghegan
11/11/2021, 7:57 PMSeth Geoghegan
11/11/2021, 7:58 PMAdrián Mouly
11/11/2021, 8:04 PMAdrián Mouly
11/11/2021, 8:05 PMvpc
parameter to that lambda.Adrián Mouly
11/11/2021, 8:05 PMAdrián Mouly
11/11/2021, 8:05 PMSeth Geoghegan
11/11/2021, 8:05 PMSeth Geoghegan
11/11/2021, 8:05 PMthdxr
11/12/2021, 1:33 PMSeth Geoghegan
11/12/2021, 1:47 PMSeth Geoghegan
11/12/2021, 1:50 PMSeth Geoghegan
11/12/2021, 1:51 PMimport * as sst from "@serverless-stack/resources";
import * as lambda from '@aws-cdk/aws-lambda';
import { ManagedKafkaEventSource } from '@aws-cdk/aws-lambda-event-sources';
import * as ec2 from '@aws-cdk/aws-ec2';
export default class MyStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
// Your MSK cluster arn
const clusterArn = "arn:aws:kafka:us-east-1:ACCOUNT_ID:cluster/stage-analytics/XXXXXXXXXXXXXX"
const vpc = ec2.Vpc.fromLookup(this, 'VPC', {
vpcName: 'stage_vpc',
});
const securityGroup = ec2.SecurityGroup.fromSecurityGroupId(
this,
'SG',
'sg-YYYYYYYYYYYYY'
);
const kafkaIngestFunction = new sst.Function(this, "KafkaIngestHandler", {
handler: "/src/lambda.handler"
});
kafkaIngestFunction.addEventSource(new ManagedKafkaEventSource({
clusterArn,
topic: 'analytics_cdc.public.profile',
batchSize: 100, // default
startingPosition: lambda.StartingPosition.TRIM_HORIZON
}));
}
}
Seth Geoghegan
11/12/2021, 1:52 PMexport async function handler(event) {
return {
statusCode: 200,
headers: { "Content-Type": "text/plain" },
body: `Hello, World! Your request was received!.`,
};
}
Seth Geoghegan
11/12/2021, 1:54 PMsst deploy
. It's the sst start
live lambda environment that doesn't work for methdxr
11/12/2021, 1:58 PMSeth Geoghegan
11/12/2021, 2:09 PMthdxr
11/12/2021, 2:12 PMthdxr
11/12/2021, 2:12 PMSeth Geoghegan
11/12/2021, 2:17 PMSeth Geoghegan
11/12/2021, 2:21 PM2021-11-10T23:39:14.491Z 8faab32b-f3ed-4fa9-9848-5f83d0a865a8 INFO ws.onerror ErrorEvent {
target: WebSocket {
_events: [Object: null prototype] {
open: [Function],
close: [Function],
message: [Function],
error: [Function]
},
_eventsCount: 4,
_maxListeners: undefined,
_binaryType: 'nodebuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_extensions: {},
_protocol: '',
_readyState: 2,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_url: '<wss://1ilbjbs70k.execute-api.us-east-1.amazonaws.com/sgeoghegan>',
_req: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [TLSSocket],
connection: [TLSSocket],
_header: 'GET /sgeoghegan HTTP/1.1\r\n' +
'Sec-WebSocket-Version: 13\r\n' +
'Sec-WebSocket-Key: mZTxW3tpUSFllakA5mkJLQ==\r\n' +
'Connection: Upgrade\r\n' +
'Upgrade: websocket\r\n' +
'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\r\n' +
'Host: <http://1ilbjbs70k.execute-api.us-east-1.amazonaws.com|1ilbjbs70k.execute-api.us-east-1.amazonaws.com>\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: noopPendingOutput],
agent: undefined,
socketPath: undefined,
method: 'GET',
insecureHTTPParser: undefined,
path: '/sgeoghegan',
_ended: false,
res: [IncomingMessage],
aborted: true,
timeoutCb: null,
upgradeOrConnect: false,
parser: [HTTPParser],
maxHeadersCount: null,
reusedSocket: false,
host: '<http://1ilbjbs70k.execute-api.us-east-1.amazonaws.com|1ilbjbs70k.execute-api.us-east-1.amazonaws.com>',
protocol: 'https:',
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype]
},
[Symbol(kCapture)]: false
},
type: 'error',
message: 'Unexpected server response: 403',
error: Error: Unexpected server response: 403
at ClientRequest.<anonymous> (/var/task/node_modules/ws/lib/websocket.js:604:7)
at ClientRequest.emit (events.js:314:20)
at ClientRequest.EventEmitter.emit (domain.js:483:12)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:601:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:122:17)
at TLSSocket.socketOnData (_http_client.js:474:22)
at TLSSocket.emit (events.js:314:20)
at TLSSocket.EventEmitter.emit (domain.js:483:12)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:272:9)
}
thdxr
11/12/2021, 2:28 PMFrank
Frank
sgeoghegan-xxxx-debug-stack
. Remove the stack. Then restart sst start
.Frank
Seth Geoghegan
11/12/2021, 11:35 PM