Fetch what's new from AWS and send out notifications on social sites.
go-aws-news
can be executed as an application that sends out notifications to social sites like
Discord. To configure providers, modify the config.yaml file to enable a
provider.
go-aws-news
is designed to be run on a schedule, once a day (displaying the previous day's AWS
News). See the install options for examples on how to install and run.
Currently supported providers:
The simplest way to run go-aws-news
is via crontab.
Type crontab -e
on Mac or Linux and add a line:
# Binary
0 2 * * * /path/to/go-aws-news-binary
# Docker
0 14 * * * docker run -d --rm --name aws-news \
-v your_config.yaml:/config.yaml \
circa10a/go-aws-news
The above example will execute
go-aws-news
at2PM UTC
(8AM CST) each day.
go-aws-news
can be run as a CronJob in a Kubernetes cluster.
Example cronjob.yaml
:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: go-aws-news
spec:
schedule: "0 14 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: go-aws-news
image: circa10a/go-aws-news
volumeMounts:
- name: config
mountPath: /config.yaml
subPath: config.yaml
volumes:
- name: config
configMap:
name: awsnews-config
restartPolicy: OnFailure
The ConfigMap can be created from the config.yaml file itself:
kubectl create configmap awsnews-config --from-file=config.yaml
To apply the cronjob.yaml
example above:
kubectl apply -f cronjob.yaml
go-aws-news
can be installed as a module for use in other Go applications:
go get -u "github.com/circa10a/go-aws-news/news"
Methods return a slice of structs which include the announcement title, a link, and the date it was posted as well an error. This allows you to manipulate the data in whichever way you please, or simply use Print()
to print a nice ASCII table to the console.
package main
import (
awsnews "github.com/circa10a/go-aws-news/news"
)
func main() {
news, err := awsnews.Today()
if err != nil {
// Handle error
}
news.Print()
}
news, _ := awsnews.Yesterday()
news, _ := awsnews.ThisMonth()
// Custom timeframe(June 2019)
news, err := awsnews.Fetch(2019, 06)
// Custom timeframe(2017)
news, err := awsnews.FetchYear(2017)
news, _ := awsnews.ThisMonth()
news.Print()
// Console output
// +--------------------------------+--------------+
// | ANNOUNCEMENT | DATE |
// +--------------------------------+--------------+
// | Amazon Cognito now supports | Jan 10, 2020 |
// | CloudWatch Usage Metrics | |
// +--------------------------------+--------------+
// | Introducing Workload Shares in | Jan 10, 2020 |
// | AWS Well-Architected Tool | |
// +--------------------------------+--------------+
//
// Loop slice of stucts of announcements
// For your own data manipulation
news, _ := awsnews.Fetch(time.Now().Year(), int(time.Now().Month()))
for _, v := range news {
fmt.Printf("Title: %v\n", v.Title)
fmt.Printf("Link: %v\n", v.Link)
fmt.Printf("Date: %v\n", v.PostDate)
}
news, _ := awsnews.ThisMonth()
// Last 10 news items of the month
news.Last(10).Print()
news, _ := awsnews.ThisMonth()
json, jsonErr := news.JSON()
if jsonErr != nil {
log.Fatal(err)
}
fmt.Println(string(json))
news, _ := awsnews.ThisMonth()
html := news.HTML()
fmt.Println(html)
news, err := awsnews.Fetch(2019, 12)
if err != nil {
fmt.Println(err)
} else {
news.Filter([]string{"EKS", "ECS"}).Print()
}
# Unit/Integration tests
make
# Get code coverage
make coverage