This is a Dockerised application meant to serve as the backend of a Slack App which would return the Private IPs of all running tasks in an AWS Elastic Container Service
There are 2 parts of setting the process to work from Slack.
- Setting up the Slack App itself
- Setting up the Backend App (this one) which the Slack App will "talk" to
In order to set this up in your slack channel you have to do the following:
(Lets assume you are running this application under http://myslackapp-backend.com)
- Create a Slack Application from https://api.slack.com
- Create a Slash Command within your APP
- Set the "Request URL" for the Slash Command to be http://myslackapp-backend.com/aws-get-ips
- Under "OAuth and Permissions", "Add a new Redirect URL" to point to http://myslackapp-backend.com/oauth
- Lastly under "Interactive Messages" set the "Request URL" to be http://myslackapp-backend.com/button-response
This is a Dockerised application and all you need to do is run the potter/slackapp-aws-ips (available in DockerHub) image in a server of your own.
You will need to setup a few Environment variables in order to correctly configure the backend to be able to connect to your AWS accounts:
Currently the Application comes with support for 2 different AWS environments "stag" and "prod" and you can provide the AWS access key and secret for whichever you want to use(or both)
- AWS_STAGING_KEY - The AWS key for your staging environment (optional)
- AWS_STAGING_SECRET - The AWS secret for your staging environment (optional)
- AWS_PROD_KEY - The AWS key for your production environment (optional if Staging is provided)
- AWS_PROD_SECRET - The AWS secret for your production environment (optional if Staging is provided)
- SLACK_CLIENT_ID - This is you Slack APP's client ID (found under Basic Information)
- SLACK_CLIENT_SECRET - This is you Slack APP's client Secret (found under Basic Information)
- DEFAULT_ENV - The default env the app is going to use if none is provided (recommended)
- DEFAULT_REGION - The default region the app is going to use if none is provided (recommended)
- DEFAULT_CLUSTER - The default cluster the app is going to use if none is provided (optional)
- DEFAULT_SERVICE - The default service the app is going to use if none is provided (optional)
Lets assume you called your slash command /aws-ecs-ips
Once you have installed the application to your team you will have access to this command.
The command can be ran with or without parameters depending on your defaults (mentioned above).
I strongly recommend you set defaults for Region and Env as those are less likely to change between user invocations.
The application uses Interactive Messages to find out which Cluster and which Service the user wants to query.
If all the information, however, is provided via parameters, the app will immediately show you the answer.
Once integrated with slack you can issue your command with the following parameters:
- -e, --env - the aws environment query [Required - either through input or default]
- -r, --region - the aws region query [Required - either through input or default]
- -s, --service - the ECS service name you want to query [Optional - but will use input or default if set]
- -c, --cluster - the ECS cluster name you want to query [Optional - but will use input or default if set]
If you have already set defaults for Env and Region you can just call the command without any parameters.
/aws-ecs-ips
- The app will the give you a list of Clusters to select from, followed by a list of Services, once you've chosen a Cluster
You can specify the Cluster and Service via parameters, which will skip the selection processes:
/aws-ecs-ips --cluster="my-cluster" --service="my-service"
#/aws-ecs-ips -c="my-cluster" -s="my-service" [shorthand version]
Alternatively you can override and call the full command with all parameters
/aws-ecs-ips --env="prod" --region="eu-west-1" --cluster="my-cluster" --service="my-service"
#/aws-ecs-ips -e="prod" -r="eu-west-1" -c="my-cluster" -s="my-service" [shorthand version]