Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
Stefan Reimer | c324ab03bb | |
Renovate Bot | bf204c8fb4 | |
Stefan Reimer | 1175a38d8b | |
Stefan Reimer | d7bf6542ce | |
Renovate Bot | 56945759a6 | |
Stefan Reimer | 2d59428b1e | |
Renovate Bot | 5f747d5e8b | |
Stefan Reimer | 7043dcb2bf | |
Stefan Reimer | 27dddfb1b7 | |
Stefan Reimer | d0f97044c0 | |
Stefan Reimer | 6d421cefd1 | |
Stefan Reimer | a177d6145e |
|
@ -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 @
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
17
Dockerfile
17
Dockerfile
|
@ -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
8
app.py
|
@ -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!")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue