Build a Pritunl Slack Slash Commands with a Serverless Backend
Introduction
For self-service automation, Slack is one of the leading platforms that it can provide. As DevOps, which also considers company administrators, we ensure team members, such as Developers or QA, are presented with their technical needs without always relying on us.
In this post, we will build and deploy a Slack Slash Command for Pritunl Enterprise VPN users so they can generate their VPN Profile and Keys to access the organization’s resources.
display_information:name:Pritunldescription:Pritunlbackground_color:"#737373"features:bot_user:display_name:Pritunlalways_online:falseslash_commands:-command:/pritunldescription:Pritunlshould_escape:false## Replace the URL with the actual endpoint later after Serverless backend deployment.url:https://url-id.lambda-url.us-east-1.on.aws/oauth_config:scopes:bot:-commands-users:read-users:read.emailsettings:org_deploy_enabled:falsesocket_mode_enabled:falsetoken_rotation_enabled:false
Once fill-in and without syntax or definition errors, proceed to next step.
Step 3: Review summary & create your app
Based on the YAML manifest from our previous step, inspect the OAuth and Features that suit our requirements, and finalize the app creation steps by clicking the Create button.
Improve App Visual Identity (Optional)
For our application to have a unique visual identity from the rest of our apps, we can change the app icon.
From the Pritunl app, go to ->Settings->Basic Information->App Credentials->Display Information.
Download the Pritunl Icon and, upload it to the App icon & Preview
Prepare the Slack Credentials
We only need the Signing Secret and Bot Token. Then steps on how to obtain these.
Getting the Signing Secret
From the Pritunl app, go to ->Settings->Basic Information->App Credentials.
Then, click the Show button in the Signing Secret field to suppress the information and copy it for our Serverless backend deployment.
Getting the Bot Token
From the Pritunl app, go to ->Settings->Basic Information->Install App.
Then on the Install App to Your Team page, click the Install to Workspace.
Review the app requesting permission to access our workspace, then click Allow.
Once installed in our workspace, the field Bot User OAuth Token shows this will be our Bot Token, which we copy for our Serverless backend deployment.
Deploy the Serverless Backend
Prepare the Pritunl Credentials
Before proceeding to Serverless backend deployment, also prepare the Pritunl credentials.
From the Pritunl Dashboard (Base URL: https://vpn.domain.tld/), go to ->Administrators->Select an Administrator-> then tick the Enable Token Authentication.
Copy the Pritunl API Token and API Secret.
Tooling Requirements
Install the AWS SAM CLI
Make sure you have the latest AWS SAM CLI installed in your system.
The flag --use-container only works if Docker is installed. This method prevents failing builds and packaging issues and promotes the highest runtime compatibility on the serverless environment once deployed.
1
sam build --use-container--no-cached
Show Stdout
Lets deploy the application
The flag --no-confirm-changeset will automatically deploy the application without reviews.
1
2
3
4
5
6
sam deploy --no-confirm-changeset--parameter-overrides"\
PritunlBaseUrl=${PRITUNL_BASE_URL}\
PritunlApiSecret=${PRITUNL_API_SECRET}\
PritunlApiToken=${PRITUNL_API_TOKEN}\
SlackSigningSecret=${SLACK_SIGNING_SECRET}\
SlackBotToken=${SLACK_BOT_TOKEN}"
Show Stdout
Modify our Slack Slash Commands configuration.
Copy the value of PritunlSlackFunctionUrl from our sam deploy outputs, such as the URL https://5lxvqp66eussnx4egwg5hz7dme0vbend.lambda-url.us-east-1.on.aws/. Then modify our Slack Slash Commands Manifest configuration.
From the Pritunl app, go to ->Features->App Manifest->YAML.