Proving that for AWS Serverless:
Sure - You Can Play Doom On It.
Create a tmp folder in the root of the project.
Include the following files:
doom.wasm
You can copy this directly from the resources folder, or you can build it yourself:
- Clone https://github.com/diekmann/wasm-fizzbuzz
- Ensure you have rust and clang installed and locally configured
cd doommake doom.wasm- Copy the resulting doom.wasm into the
tmpfolder
credentials.json
This should be the json response from AWS STS' assume-role api.
For example:
aws --profile [profile name] sts assume-role --role-session-name=doom --role-arn=[local role arn] > ./tmp/credentials.jsoncontext.json
{
"awsIotEndpoint": "abcderfgh123-ats.iot.eu-central-1.amazonaws.com",
"doomBucketName": "serverlessdoomstack-doombucketabcdefgh1234",
"doomBucketStateKey": "doom-state-key",
"doomKeyDbTableName": "ServerlessDoomStack-DoomKeyDbabcdefgh123",
"iotTopic": "doom/keys",
"kinesisChannelArn": "arn:aws:kinesisvideo:eu-central-1:1234567890:channel/doom-call/1234567890",
"kinesisChannelName": "doom-call",
"kvIotDoomLambdaArn": "arn:aws:lambda:eu-central-1:1234567890:function:ServerlessDoomStack-kvIotDoomHandlerABCDEFGH123",
"region": "eu-central-1"
}Where:
awsIotEndpointis the endpoint for your AWS IoT Core instance, you can find this using https://docs.aws.amazon.com/iot/latest/developerguide/iot-connect-devices.html#iot-connect-device-endpointsdoomBucketNameis the name of the S3 bucket created using CDK (see infrastructure)doomBucketStateKeycan be any S3 Key suitable name for the state (e.g.doom-state-key)doomKeyDbTableNameis the name of the DynamoDB table created using CDK (see infrastructure)iotTopicis the topic that the doom key will be published to (e.g.doom/keys)kinesisChannelArnis the ARN of the Kinesis Video channel you manually created (see infrastructure)kinesisChannelNameis the name of the Kinesis Video channel you manually created (see infrastructure)kvIotDoomLambdaArnis the ARN of the Lambda function created using CDK (see infrastructure)regionis the region you are using (e.g.eu-central-1)
Unfortunately the infrastructure is not yet fully automated, so you will need to create some resources manually.
You will need to create the following resources:
- An AWS Kinesis Video Streams Signalling Channel: https://docs.aws.amazon.com/kinesisvideostreams-webrtc-dg/latest/devguide/gs-createchannel.html
- Open the AWS IoT Core console to prompt AWS to create an IoT Core endpoint
Once you have done that, you can use:
- (ensure you have
context.json, using the dummy values for unknown resources) npm run cdk bootstrapnpm run cdk deploy- (update the
context.jsonfile with the ARNs of the resources created by CDK) npm run cdk deployagain- upload the
doom.wasmfile to the S3 bucket created by CDK
npm run start starts a local server on http://localhost:8000/
- Open
s3-dynamo.htmlto view the S3/DynamoDB implementation - Open
kv-iot.htmlto view the Kinesis Video Streams/IoT Core implementation
From the Lambda console you will have two functions named like:
ServerlessDoomStack-s3DynamoDoomHandlerABCDEFGH123- this is the S3/DynamoDB implementationServerlessDoomStack-kvIotDoomHandlerABCDEFGH123- this is the Kinesis Video Streams/IoT Core implementation
In both cases they can be invoked using the test button with an empty payload.