Skip to content

Commit

Permalink
Point lambda to cross-account kinesis stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Fweddi committed Jul 22, 2024
1 parent efdb581 commit 8b3f194
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 10 deletions.
40 changes: 40 additions & 0 deletions cdk/lib/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ exports[`The typerighter stack matches the snapshot 1`] = `
"Description": "A list of private subnets",
"Type": "AWS::SSM::Parameter::Value<List<AWS::EC2::Subnet::Id>>",
},
"SsmParameterValueTESTtyperightertyperighterlivecontentlambdafirehoseARNC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Default": "/TEST/typerighter/typerighter-live-content-lambda/firehose-ARN",
"Type": "AWS::SSM::Parameter::Value<String>",
},
"VpcId": {
"Default": "/account/vpc/primary/id",
"Description": "Virtual Private Cloud to run EC2 instances within. Should NOT be the account default VPC.",
Expand Down Expand Up @@ -1722,6 +1726,19 @@ exports[`The typerighter stack matches the snapshot 1`] = `
},
"Type": "AWS::Lambda::Function",
},
"TyperighterLiveContentLambdaKinesisEventSourcetyperighterContentApiFirehose12B21953B7975807": {
"Properties": {
"BatchSize": 100,
"EventSourceArn": {
"Ref": "SsmParameterValueTESTtyperightertyperighterlivecontentlambdafirehoseARNC96584B6F00A464EAD1953AFF4B05118Parameter",
},
"FunctionName": {
"Ref": "TyperighterLiveContentLambdaF35D688E",
},
"StartingPosition": "LATEST",
},
"Type": "AWS::Lambda::EventSourceMapping",
},
"TyperighterLiveContentLambdaServiceRole47E0FE94": {
"Properties": {
"AssumeRolePolicyDocument": {
Expand Down Expand Up @@ -1875,6 +1892,29 @@ exports[`The typerighter stack matches the snapshot 1`] = `
],
},
},
{
"Action": [
"kinesis:DescribeStreamSummary",
"kinesis:GetRecords",
"kinesis:GetShardIterator",
"kinesis:ListShards",
"kinesis:SubscribeToShard",
"kinesis:DescribeStream",
"kinesis:ListStreams",
"kinesis:DescribeStreamConsumer",
],
"Effect": "Allow",
"Resource": {
"Ref": "SsmParameterValueTESTtyperightertyperighterlivecontentlambdafirehoseARNC96584B6F00A464EAD1953AFF4B05118Parameter",
},
},
{
"Action": "kinesis:DescribeStream",
"Effect": "Allow",
"Resource": {
"Ref": "SsmParameterValueTESTtyperightertyperighterlivecontentlambdafirehoseARNC96584B6F00A464EAD1953AFF4B05118Parameter",
},
},
],
"Version": "2012-10-17",
},
Expand Down
20 changes: 10 additions & 10 deletions cdk/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,15 @@ EOF
ManagedPolicy.fromAwsManagedPolicyName("service-role/AWSLambdaKinesisExecutionRole")
);

// const streamARN = StringParameter.valueForStringParameter(this,
// // This has been manually created in the console for now
// `/${this.stage}/typerighter/typerighter-live-content-lambda/firehose-ARN`
// );
//
// const stream = Stream.fromStreamArn(this, 'ContentApiFirehose', streamARN);
//
// liveContentLambda.addEventSource(new KinesisEventSource(stream, {
// startingPosition: StartingPosition.LATEST,
// }));
const streamARN = StringParameter.valueForStringParameter(this,
// This has been manually created in the console for now
`/${this.stage}/typerighter/typerighter-live-content-lambda/firehose-ARN`
);

const stream = Stream.fromStreamArn(this, 'ContentApiFirehose', streamARN);

liveContentLambda.addEventSource(new KinesisEventSource(stream, {
startingPosition: StartingPosition.LATEST,
}));
}
}

0 comments on commit 8b3f194

Please sign in to comment.