Messages scheduled updates about active LaunchDarkly flags
Serverless AWS Lambda Function built with Gradle
Built from this template using serverless
The Flag Counter runs weekly by default to pull a count of the LaunchDarkly flags that you have in your system and post that count to Slack. It adds a small sentence to help visualize the large number of configurations that can result from even a handful of flags. The goal of this project is to help motivate your team to remove unused flags from your system to reduce the number of potential configurations of your application.
On a preset schedule, your whole team will get a message similar to the one below.
The string that is included will preferentially pick a single number out of the map in the Generator.
If a single number can't be found then two numbers will be multiplied together as in the message above.
You can also configure individual teams to receive a message with more detailed information about the flags they maintain.
-
Configure serverless on your machine to deploy the Flag Counter.
-
Create a
Reader
access token for your LaunchDarkly account here. Export the token as an environment variable namedLAUNCHDARKLY_KEY
-
Install an
Incoming Webhooks
from the Slack App Directory and configure it to the channel you want to see the main flag count update in. Export theWebhook URL
as an environment variable namedSLACK_URL
-
Install an
Incoming Webhooks
from the Slack App Directory and configure it to the channel you want to see any error messages in. Export theWebhook URL
as an environment variable namedSLACK_ERROR_URL
-
If you would like to notify individual teams of the number of flags that they own (are the maintainer for), create a JSON object which maps the team's email address used in LaunchDarkly to the
Webhook URL
for the team. For example, to configure two teams
{
"teamsList": [
{
"email":"firstTeam@company.com",
"url": "<slack webhook url>"
},
{
"email":"secondTeam@company.com",
"url":"<slack webhook url>"
}
]
}
This object should be stored as a string and exported as an environment variable called TEAMS_MAP
export TEAMS_MAP='{"teamsList":[{"email":"firstTeam@company.com","url":"<slack webhook url>"},{"email":"secondTeam@company.com","url":"<slack webhook url>"}]}'
- If you would like a specific schedule for your team to be sent notifications, you can define this schedule following the AWS schedule syntax, and export it as an environment variable named
SCHEDULE
. The default schedule for notifications will be once weekly on Mondays at 17:00 UTC.
- Ensure that you have Java installed on your machine.
- Run
make build
which will invoke gradle, run the tests, and build the JAR
make docker-save
- jar files will be saved to the build folder.
If you want to deploy to a different region than us-west-2
you can change this in serverless.yml
If you want to change the cron scheduling of the flag update you can change this in serverless.yml. You will need to describe your schedule using AWS Schedule Expressions
-
Run
make deploy
which will invoke serverless and deploy your function. -
To ensure that the deployment was successful, you can view your AWS Lambda function in the AWS Console and trigger it manually with a test event.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.