Devil Bot Rust
Overview
- A Rust implementation of a Slack bot that will be used by the CodeDevils Slack workspace.
- All resources are managed using AWS CDK.
- The main driver is AWS API Gateway to provide static endpoints and AWS Lambda for serverless compute/request handling.
Prereqs
- Install Rust: https://rustup.rs/
- Install NodeJS v16 (latest LTS version): https://nodejs.org/en/download/
- Install AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
- Install AWS CDK Toolkit:
npm install -g aws-cdk
Getting Started with Git
- Create a new local directory for this project.
- Run
git clone https://github.com/ASU-CodeDevils/devil_bot_rust.git
in that new directory.
Set up AWS account
- Create a new AWS account for free: https://aws.amazon.com
- Go to the IAM console (type IAM in search bar on AWS website after logging in).
- Click on "Users" on the left-hand side bar under "Access Management".
- Click "Add Users" to the right.
- For username choose something like "devil-bot-test-user-${your_asu_alias}" (e.g. "devil-bot-test-user-jtmichel").
- Make sure "Access key - Programmatic access" check box is checked.
- Click "Next: Permissions".
- Click "Attach existing policies directly".
- Check "AdministratorAccess" (you can use less permissions if you know what you're doing, but this should work fine as long as you don't give away your credentials).
- Click "Next: Tags".
- Click "Next: Review".
- Click "Create user".
- Copy both your "Access key ID" and your "Secret access key" somewhere locally (only store this temporarily then delete).
- Continue to "Connecting to your AWS Account" steps below.
Connecting to your AWS Account
aws configure
- For "access key" use your "Access key ID" from the "Set up AWS account" instructions above.
- For "secret access key" use your "Secret access key" from the "Set up AWS account" instructions above.
- For "default region name" use:
us-east-1
- For "defaut output format" use:
None
(just leave blank and press enter)
Set up project for AL2 target Mac and Linux
- Ensure you've installed Rust, NPM, AWS-CDK Toolkit, and AWS-CLI.
- Confirm you've setup your AWS account and Connected it!
chmod +x build-function.sh
sh build-function.sh
cdk bootstrap
cdk deploy
After your project is set up use the following to build your code and deploy it to AWS test.
sh build-function.sh
cdk diff
(optional, but useful command)cdk deploy
Useful CDK commands and their descriptions
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template