Compare commits

...

12 Commits

Author SHA1 Message Date
Stefan Reimer c324ab03bb Merge pull request 'chore(deps): update all non-major dependencies' (#19) from renovate/all-minor-patch into master
ZeroDownTime/sns-alert-hub/pipeline/head This commit looks good Details
Reviewed-on: #19
2024-04-15 14:15:26 +00:00
Renovate Bot bf204c8fb4 chore(deps): update all non-major dependencies
ZeroDownTime/sns-alert-hub/pipeline/pr-master This commit looks good Details
2024-04-14 03:05:28 +00:00
Stefan Reimer 1175a38d8b Upgrade base OS to Alpine 3.19, minor ElastiCache fix
ZeroDownTime/sns-alert-hub/pipeline/head This commit looks good Details
ZeroDownTime/sns-alert-hub/pipeline/tag This commit looks good Details
2024-04-05 13:27:05 +00:00
Stefan Reimer d7bf6542ce Merge pull request 'chore(deps): update all non-major dependencies' (#18) from renovate/all-minor-patch into master
ZeroDownTime/sns-alert-hub/pipeline/head This commit looks good Details
Reviewed-on: #18
2024-04-05 13:02:35 +00:00
Renovate Bot 56945759a6 chore(deps): update all non-major dependencies
ZeroDownTime/sns-alert-hub/pipeline/pr-master This commit looks good Details
2024-04-05 03:09:15 +00:00
Stefan Reimer 2d59428b1e Merge pull request 'chore(deps): update all non-major dependencies' (#17) from renovate/all-minor-patch into master
ZeroDownTime/sns-alert-hub/pipeline/head This commit looks good Details
Reviewed-on: #17
2023-08-17 09:59:58 +00:00
Renovate Bot 5f747d5e8b chore(deps): update all non-major dependencies
ZeroDownTime/sns-alert-hub/pipeline/pr-master This commit looks good Details
2023-08-17 09:56:14 +00:00
Stefan Reimer 7043dcb2bf Merge latest ci-tools-lib
ZeroDownTime/sns-alert-hub/pipeline/head This commit looks good Details
2023-08-17 09:51:15 +00:00
Stefan Reimer 27dddfb1b7 Squashed '.ci/' changes from 5023473..22ed100
22ed100 Fix custom branch docker tags
227e39f Allow custom GIT_TAG
38a9cda Debug CI pipeline
3efcc81 Debug CI pipeline

git-subtree-dir: .ci
git-subtree-split: 22ed10034d0a2380085b8f0680a50c2e67f6fada
2023-08-17 09:51:15 +00:00
Stefan Reimer d0f97044c0 Fix tests for RDS events, add error log for failed notifications
ZeroDownTime/sns-alert-hub/pipeline/head Build queued... Details
2023-08-15 10:28:36 +01:00
Stefan Reimer 6d421cefd1 Squashed '.ci/' changes from cdc32e0..5023473
5023473 Make branch detection work for tagged commits

git-subtree-dir: .ci
git-subtree-split: 50234738d04b5b26d9e067fed0e58e98931c2e9b
2023-08-15 10:26:56 +01:00
Stefan Reimer a177d6145e Merge commit '6d421cefd191c85f9c7eb9f0f13a12fcc76bec05' 2023-08-15 10:26:56 +01:00
6 changed files with 73 additions and 26 deletions

View File

@ -1,25 +1,26 @@
# Parse version from latest git semver tag
GIT_BRANCH ?= $(shell git name-rev --name-only HEAD 2>/dev/null | sed -e 's,remotes/origin/,,' -e 's/[^a-zA-Z0-9]/-/g')
GIT_TAG := $(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
GIT_TAG ?= $(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
TAG := $(GIT_TAG)
TAG ::= $(GIT_TAG)
# append branch name to tag if NOT main nor master
ifeq (,$(filter main master, $(GIT_BRANCH)))
# If branch is substring of tag, omit branch name
ifeq ($(findstring $(GIT_BRANCH), $(GIT_TAG)),)
# only append branch name if not equal tag
ifneq ($(GIT_TAG), $(GIT_BRANCH))
TAG = $(GIT_TAG)-$(GIT_BRANCH)
# Sanitize GIT_BRANCH to allowed Docker tag character set
TAG = $(GIT_TAG)-$(shell echo $$GIT_BRANCH | sed -e 's/[^a-zA-Z0-9]/-/g')
endif
endif
endif
ARCH := amd64
ALL_ARCHS := amd64 arm64
ARCH ::= amd64
ALL_ARCHS ::= amd64 arm64
_ARCH = $(or $(filter $(ARCH),$(ALL_ARCHS)),$(error $$ARCH [$(ARCH)] must be exactly one of "$(ALL_ARCHS)"))
ifneq ($(TRIVY_REMOTE),)
TRIVY_OPTS := --server $(TRIVY_REMOTE)
TRIVY_OPTS ::= --server $(TRIVY_REMOTE)
endif
.SILENT: ; # no need for @

View File

@ -10,10 +10,11 @@ def call(Map config=[:]) {
stages {
stage('Prepare') {
steps {
// we set pull tags as project adv. options
// pull tags
withCredentials([gitUsernamePassword(credentialsId: 'gitea-jenkins-user')]) {
sh 'git fetch -q --tags ${GIT_URL}'
}
//withCredentials([gitUsernamePassword(credentialsId: 'gitea-jenkins-user')]) {
// sh 'git fetch -q --tags ${GIT_URL}'
//}
// Optional project specific preparations
sh 'make prepare'
}
@ -22,7 +23,7 @@ def call(Map config=[:]) {
// Build using rootless podman
stage('Build') {
steps {
sh 'make build'
sh 'make build GIT_BRANCH=$GIT_BRANCH'
}
}

View File

@ -2,11 +2,15 @@
# libexec is missing from >=3.17
# Stage 1 - bundle base image + runtime
FROM python:3.11-alpine3.16 AS python-alpine
FROM python:3.12-alpine3.19 AS python-alpine
ARG ALPINE="v3.19"
# Install GCC (Alpine uses musl but we compile and link dependencies with GCC)
RUN apk upgrade -U --available --no-cache && \
apk add --no-cache \
RUN echo "@kubezero https://cdn.zero-downtime.net/alpine/${ALPINE}/kubezero" >> /etc/apk/repositories && \
wget -q -O /etc/apk/keys/stefan@zero-downtime.net-61bb6bfb.rsa.pub https://cdn.zero-downtime.net/alpine/stefan@zero-downtime.net-61bb6bfb.rsa.pub
RUN apk -U --no-cache upgrade && \
apk --no-cache add \
libstdc++
@ -15,8 +19,7 @@ FROM python-alpine AS build-image
ARG TAG="latest"
# Install aws-lambda-cpp build dependencies
RUN apk upgrade -U --available --no-cache && \
apk add --no-cache \
RUN apk --no-cache add \
build-base \
libtool \
autoconf \
@ -25,8 +28,8 @@ RUN apk upgrade -U --available --no-cache && \
cmake \
libcurl \
libffi-dev \
libexecinfo-dev \
openssl-dev
openssl-dev \
libexecinfo-dev@kubezero
# cargo
# Install requirements

8
app.py
View File

@ -261,6 +261,11 @@ def handler(event, context):
title = "ElastiCache fail over complete"
body = "for node {}".format(msg["ElastiCache:FailoverComplete"])
# ElasticCache update notifications
elif "ElastiCache:ServiceUpdateAvailableForNode" in msg:
title = "ElastiCache update available"
body = "for node {}".format(msg["ElastiCache:ServiceUpdateAvailableForNode"])
# known RDS events
elif "Event Source" in msg and msg['Event Source'] in ["db-instance", "db-cluster-snapshot", "db-snapshot"]:
try:
@ -299,4 +304,5 @@ def handler(event, context):
msg_type = apprise.NotifyType.WARNING
body = sns["Message"]
apobj.notify(body=body, title=title, notify_type=msg_type)
if not apobj.notify(body=body, title=title, notify_type=msg_type):
logger.error("Error during notify!")

View File

@ -1,4 +1,4 @@
boto3==1.28.25
apprise==1.4.5
humanize==4.7.0
awslambdaric==2.0.4
boto3==1.34.84
apprise==1.7.6
humanize==4.9.0
awslambdaric==2.0.11

View File

@ -9,8 +9,13 @@ from requests.packages.urllib3.util.retry import Retry
s = requests.Session()
retries = Retry(
total=3, backoff_factor=1, status_forcelist=[502, 503, 504], allowed_methods="POST"
)
total=3,
backoff_factor=1,
status_forcelist=[
502,
503,
504],
allowed_methods="POST")
s.mount("http://", HTTPAdapter(max_retries=retries))
@ -71,7 +76,38 @@ class Test:
# RDS
def test_rds_event(self):
event = json.loads(
r' {"Records": [{"Event Source":"db-instance","Event Time":"2023-06-15 06:13:18.237","Identifier Link":"https://console.aws.amazon.com/rds/home?region=us-west-2#dbinstance:id=vrv6b014c5jbdf","Source ID":"vrv6b014c5jbdf","Source ARN":"arn:aws:rds:us-west-2:123456789012:db:vrv6b014c5jbdf","Event ID":"http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Events.Messages.html#RDS-EVENT-0001","Event Message":"Backing up DB instance","Tags":{"aws:cloudformation:stack-name":"postgres-rds","aws:cloudformation:stack-id":"arn:aws:cloudformation:us-west-2:123456789012:stack/postgres-rds/c7382650-46a7-11ea-bd3f-064fbe1c973c","Conglomerate":"test","aws:cloudformation:logical-id":"RdsDBInstance","Artifact":"postgres-rds","Name":"postgres-rds.DBInstance"}}]}'
r''' {
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:us-west-2:123456789012:AlertHub:63470449-620d-44ce-971f-ad9582804b13",
"Sns": {
"Type": "Notification",
"MessageId": "ef1f821c-a04f-5c5c-9dff-df498532069b",
"TopicArn": "arn:aws:sns:us-west-2:123456789012:AlertHub",
"Subject": "RDS Notification Message",
"Message": "{\"Event Source\":\"db-cluster-snapshot\",\"Event Time\":\"2023-08-15 07:03:24.491\",\"Identifier Link\":\"https://console.aws.amazon.com/rds/home?region=us-west-2#snapshot:engine=aurora;id=rds:projectdb-cluster-2023-08-15-07-03\",\"Source ID\":\"rds:projectdb-cluster-2023-08-15-07-03\",\"Source ARN\":\"arn:aws:rds:us-west-2:123456789012:cluster-snapshot:rds:projectdb-cluster-2023-08-15-07-03\",\"Event ID\":\"http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Events.Messages.html#RDS-EVENT-0168\",\"Event Message\":\"Creating automated cluster snapshot\",\"Tags\":{}}",
"Timestamp": "2023-08-15T07:03:25.289Z",
"SignatureVersion": "1",
"Signature": "mRtx+ddS1uzF3alGDWnDtUkAz+Gno8iuv0wPwkeBJPe1LAcKTXVteYhQdP2BB5ZunPlWXPSDsNtFl8Eh6v4/fcdukxH/czc6itqgGiciQ3DCICLvOJrvrVVgsVvHgOA/Euh8wryzxeQ3HJ/nmF9sg/PtuKyxvGxyO7NSFJrRKkqwkuG1Wr/8gcN3nrenqNTzKiC16kzVuKISWgXM1jqbsleQ4MyBcjq61LRwODKB8tc8vJ6PLGOs4Lrc3qeruCqF3Tzpl43680RsaRBBn1SLycwFVdB1kpHSXuk+YJQ6BS7s6rbMoyhPOpSCFHMZXC/eEb09wTzgpop0KDE/koiUsg==",
"SigningCertUrl": "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-01d088a6f77103d0fe307c0069e40ed6.pem",
"UnsubscribeUrl": "https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:123456789012:AlertHub:63470449-620d-44ce-971f-ad9582804b13",
"MessageAttributes": {
"Resource": {
"Type": "String",
"Value": "arn:aws:rds:us-west-2:123456789012:cluster-snapshot:rds:projectdb-cluster-2023-08-15-07-03"
},
"EventID": {
"Type": "String",
"Value": "RDS-EVENT-0168"
}
}
}
}
]
}
'''
)
self.send_event(event)