Automagically post to Twitter timeline about new blog post using Go on AWS Lambda.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Lambda Twitter Blog Poster

Automagically post to Twitter timeline about new blog post using Go on AWS Lambda.

TL;DR Events are generated using webhooks - Gitlab in this case because that's where I store my site. On specific commit events (the commits contain a [NEW POST] block), a Twitter status is pushed to my timeline.



Getting started

  1. Create a serverless.env.yml file in the root of the project.
  2. Declare the following variables and values in the file -
secret: "<gitlab-token-header-secret>"
apikey: "<twitter-consumer-api-key>"
apisecret: "<twitter-consumer-secret-key>"
accesstoken: "<twitter-app-access-token>"
accesssecret: "<twitter-app-access-secret>"
baseurl: "<url-of-blog>"


  1. Build the program using make build in the root of the project.
  2. To deploy, use sls deploy -s <env-name>.
  3. Once deployed, copy the API Gateway URL printed on the console.

Create a webhook

Only GitLab is supported at the moment

  1. Navigate to the repo for which a webhook will be triggered.
  2. From the panel on the left, go to Settings > Integrations to create a new webhook.
  3. Paste the URL from the last section into the URL field and the secret from the serverless.env.yml file in to the Secret Token field.
  4. Check Push Events under Trigger.
  5. Click on Add webhook to save.

Triggering the function

  1. To trigger a new post to Twitter on new post publishes, commit your new posts in the form -
The title of the post
  1. Profit!


Read the CONTRIBUTING guide for information.


Licensed under MIT. See LICENSE for more information.


Report a bug in issues.

Made with love in Kuala Lumpur, Malaysia by Riyadh Al Nur