Skip to content

Commit

Permalink
updated dependencies. Added support for Advanced channel types
Browse files Browse the repository at this point in the history
  • Loading branch information
mboulin committed Jun 22, 2023
1 parent 8193f8b commit f7ed53b
Show file tree
Hide file tree
Showing 78 changed files with 15,097 additions and 6,004 deletions.
3 changes: 3 additions & 0 deletions cdk/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.DEFAULT_GOAL := help
ORANGE := \033[38;5;202m
RESET := \033[0m

.PHONY: help app install bootstrap deploy destroy clean

Expand Down Expand Up @@ -43,6 +45,7 @@ deploy: ## Deploys the stack
node scripts/sanitize-output $(STACK)
rm temp_out.json
@echo "\n$$(tput bold) ✅ $(STACK) Deployed Successfully $$(tput sgr0)\n"
@echo "\n$$(tput bold) $(ORANGE) Attention: Please note that adjustments made to your current cloud stack may not retrospectively affect all previously created resources. $$(tput sgr0)\n$(RESET)"
@if [ $(PUBLISH) = true ]; then\
echo "Publishing Frontend App...";\
npm install --prefix ../web-ui;\
Expand Down
10 changes: 10 additions & 0 deletions cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ Service Auto Scaling automatically creates and manages CloudWatch alarms for you
For this reason, please do not create, edit, or delete the CloudWatch alarms that are used with a target tracking scaling policy.

To learn how to hide auto scaling alarms, please consult the "Hide Auto Scaling alarms" user guide available at: [Hide Auto Scaling alarms user guide](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/hide-autoscaling-alarms.html).

## Stream events API

Amazon IVS sends change events about the status of your streams to Amazon EventBridge. The Stream Events API is an EventBridge rule that updates the DynamoDB Streams table for the UGC application.

When the postStreamEvents function receives an event with a `session created` event name, any existing live stream session in the same channel is updated to offline by removing the `isOpen` attribute from the corresponding DynamoDB record. This logic ensures that a channel cannot have more than one live stream session simultaneously. Subsequently, the new stream session is saved with the `isOpen` attribute set to true.

When a `session ended` event is received, the corresponding stream record is grabbed and updated by removing the `isOpen` attribute.

You can find the Stream events API code in the `/streamEventsApi` folder.
5 changes: 3 additions & 2 deletions cdk/api/__tests__/buildServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ describe('buildServer', () => {
});

expect(response.statusCode).toBe(400);
expect(response.body).toEqual(
'{"statusCode":400,"error":"Bad Request","message":"params/channelOwnerUsername must NOT have more than 100 characters"}'
expect(response.statusMessage).toBe('Bad Request');
expect(JSON.parse(response.body).message).toBe(
'params/channelOwnerUsername must NOT have more than 100 characters'
);
});

Expand Down
8 changes: 7 additions & 1 deletion cdk/api/channel/authRouter/createResources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ChannelType, CreateChannelCommand } from '@aws-sdk/client-ivs';
import {
ChannelType,
CreateChannelCommand,
TranscodePreset
} from '@aws-sdk/client-ivs';
import { CreateRoomCommand } from '@aws-sdk/client-ivschat';
import { FastifyReply, FastifyRequest } from 'fastify';

Expand Down Expand Up @@ -39,6 +43,8 @@ const handler = async (
const createChannelCommand = new CreateChannelCommand({
name: channelName,
type: process.env.IVS_CHANNEL_TYPE as ChannelType,
preset: process.env
.IVS_ADVANCED_CHANNEL_TRANSCODE_PRESET as TranscodePreset,
tags: { project: process.env.PROJECT_TAG as string }
});
const { channel, streamKey } = await ivsClient.send(createChannelCommand);
Expand Down
3,760 changes: 1,954 additions & 1,806 deletions cdk/api/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions cdk/cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"deploySeparateContainers": false,
"enableUserAutoVerify": true,
"ivsChannelType": "BASIC",
"ivsAdvancedChannelTranscodePreset": "",
"logRetention": 7,
"maxAzs": 2,
"minScalingCapacity": 1,
Expand All @@ -48,6 +49,7 @@
"deploySeparateContainers": true,
"enableUserAutoVerify": false,
"ivsChannelType": "STANDARD",
"ivsAdvancedChannelTranscodePreset": "",
"maxAzs": 3,
"minScalingCapacity": 1,
"natGateways": 2,
Expand Down
2 changes: 2 additions & 0 deletions cdk/lib/ChannelsStack/cdk-channels-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class ChannelsStack extends NestedStack {
const {
allowedOrigins,
enableUserAutoVerify,
ivsAdvancedChannelTranscodePreset,
ivsChannelType,
signUpAllowedDomains
} = resourceConfig;
Expand Down Expand Up @@ -383,6 +384,7 @@ export class ChannelsStack extends NestedStack {
CHANNEL_ASSETS_BUCKET_NAME: channelAssetsBucket.bucketName,
CHANNELS_TABLE_NAME: channelsTable.tableName,
IVS_CHANNEL_TYPE: ivsChannelType,
IVS_ADVANCED_CHANNEL_TRANSCODE_PRESET: ivsAdvancedChannelTranscodePreset,
PROJECT_TAG: tags.project,
SIGN_UP_ALLOWED_DOMAINS: JSON.stringify(signUpAllowedDomains),
USER_POOL_CLIENT_ID: userPoolClient.userPoolClientId,
Expand Down
Loading

0 comments on commit f7ed53b

Please sign in to comment.