vagrant upvagrant sshcd /vagrantnpm installnpm test
Follow these steps to configure the slash command in Slack:
- Navigate to https://.slack.com/services/new
- Search for and select "Slash Commands".
- Enter a name for your command and click "Add Slash Command Integration".
- Copy the token string from the integration settings and use it in the next section.
- After you complete the deployment to AWS, enter the provided API endpoint URL in the URL field.
Follow these steps to encrypt your Slack token for use in this function:
- Create a KMS key - http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html.
- Give your function's role the permission for the kms:Decrypt action.
- Encrypt the Slack token using the AWS CLI:
$ aws kms encrypt --region <region> --key-id alias/<KMS key name> --plaintext "<SLACK_TOKEN>" - Copy the base-64 encoded, encrypted key (CiphertextBlob) to the relevant
kmsEncyptedSlackTokenconfiguration key value inindex.js. - Obtain a read-only PagerDuty API V2 key - https://support.pagerduty.com/hc/en-us/articles/202829310-Generating-an-API-Key
- Encrypt the PagerDuty API key using the AWS CLI:
$ aws kms encrypt --region <region> --key-id alias/<KMS key name> --plaintext "<PAGERDUTY_KEY>" - Copy the base-64 encoded, encrypted key (CiphertextBlob) to the relevate
kmsEncryptedPagerDutyApiTokenconfiguration key value inindex.js. - Obtain a Slack API token for testing and development: https://api.slack.com/docs/oauth-test-tokens
- Encrypt the Slack API token using the AWS CLI:
$ aws kms encrypt --region <region> --key-id alias/<KMS key name> --plaintext "<API_TOKEN>" - Copy the base-64 encoded, encrypted token (CiphertextBlob) to the relevate
kmsEncryptedSlackApiTokenconfiguration key value inindex.js.
Example role permission:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kms:Decrypt"
],
"Resource": [
"<your KMS key ARN>"
]
}
]
}Follow these steps to deploy the AWS Lambda function:
aws configureserverless deploy- Update the URL for your Slack slash command with the invocation URL for the created API resource in the prod stage.
serverless invoke --function slack --path event.json
- allow filtering by policy
- allow filtering by escalation level