Ohatra iray amin'ny fampiharana entin'ny hetsika mifototra amin'ny webhooks amin'ny fitahirizana zavatra S3 Mail.ru Cloud Solutions

Ohatra iray amin'ny fampiharana entin'ny hetsika mifototra amin'ny webhooks amin'ny fitahirizana zavatra S3 Mail.ru Cloud Solutions
milina kafe Rube Goldberg

Ny maritrano entin'ny hetsika dia mampitombo ny fahombiazan'ny vola ampiasaina satria amin'ny fotoana ilana azy ihany no ampiasaina. Misy safidy maro momba ny fampiharana izany fa tsy mamorona rahona fanampiny ho fampiharana mpiasa. Ary androany aho dia tsy hiresaka momba ny FaaS, fa momba ny webhooks. Haneho ohatra fampianarana momba ny fikarakarana hetsika aho amin'ny fampiasana webhooks fitehirizana zavatra.

Teny vitsivitsy momba ny fitahirizana zavatra sy webhook. Ny fitahirizana zavatra dia ahafahanao mitahiry angon-drakitra rehetra ao amin'ny rahona amin'ny endrika zavatra, azo idirana amin'ny S3 na API hafa (miankina amin'ny fampiharana) amin'ny HTTP/HTTPS. Ny Webhooks dia antso an-tariby HTTP mahazatra. Matetika izy ireo no atosiky ny hetsika iray, toy ny kaody alefa any amin'ny tahiry iray na fanehoan-kevitra apetraka amin'ny bilaogy. Rehefa misy hetsika iray dia mandefa fangatahana HTTP amin'ny URL voatondro ho an'ny webhook ny tranokala niaviany. Vokatr'izany dia azonao atao ny manao hetsika amin'ny tranokala iray izay miteraka hetsika amin'ny hafa (Wiki). Raha toa ka fitahirizana zavatra ny tranokala loharano, ny hetsika dia miasa toy ny fiovan'ny atiny.

Ohatra amin'ny tranga tsotra izay azo ampiasaina amin'ny automation toy izany:

  1. Mamorona dika mitovy amin'ny zavatra rehetra amin'ny fitahirizana rahona hafa. Ny dika mitovy dia tsy maintsy amboarina haingana isaky ny ampiana na ovaina ny rakitra.
  2. Famoronana mandeha ho azy amin'ny andian-tsarimihetsika an-tsary, manampy mari-drano amin'ny sary, ary fanovana sary hafa.
  3. Fampandrenesana momba ny fahatongavan'ireo antontan-taratasy vaovao (ohatra, ny serivisy kaonty mizara dia mampakatra tatitra any amin'ny rahona, ary ny fanaraha-maso ara-bola dia mahazo fampahafantarana momba ny tatitra vaovao, manamarina ary manadihady azy ireo).
  4. Ny tranga somary sarotra kokoa dia misy, ohatra, ny famoronana fangatahana amin'ny Kubernetes, izay mamorona pod miaraka amin'ireo kaontenera ilaina, mamindra ny mari-pamantarana amin'ny asa, ary aorian'ny fanodinana dia mirodana ilay container.

Ohatra, hanao variana amin'ny asa 1 isika, rehefa ampifandraisina amin'ny fitahirizana zavatra AWS mampiasa webhooks ny fanovana ao amin'ny siny fitahirizana zavatra Mail.ru Cloud Solutions (MCS). Amin'ny tranga tena feno entana, ny asa asynchronous dia tokony omena amin'ny fisoratana anarana webhooks amin'ny filaharana, fa ho an'ny asa fanofanana dia hanao ny fampiharana tsy misy izany.

Lalam-piasana

Ny protocol interaction dia voafaritra amin'ny antsipiriany ao TorolΓ lana ho an'ny S3 webhooks amin'ny MCS. Ny rafitra asa dia ahitana ireto singa manaraka ireto:

  • Serivisy fanontana, izay eo amin'ny lafiny fitahirizana S3 ary mamoaka ny fangatahana HTTP rehefa mipoitra ny webnhook.
  • Mpizara mandray Webhook, izay mihaino ny fangatahana avy amin'ny serivisy famoahana HTTP ary manao hetsika mifanaraka amin'izany. Ny mpizara dia azo soratana amin'ny fiteny rehetra; amin'ny ohatra ataontsika dia hanoratra ny mpizara ao amin'ny Go isika.

Ny endri-javatra manokana amin'ny fampiharana ny webhooks amin'ny S3 API dia ny fisoratana anarana amin'ny mpizara mpandray webhook amin'ny serivisy famoahana. Indrindra indrindra, ny mpizara mpandray webhook dia tsy maintsy manamafy ny famandrihana hafatra avy amin'ny serivisy famoahana (amin'ny fampiharana webhook hafa dia matetika tsy ilaina ny fanamafisana ny famandrihana).

Noho izany, ny mpizara mpandray webhook dia tsy maintsy manohana asa roa lehibe:

  • mamaly ny fangatahan'ny serivisy fanontana hanamarina ny fisoratana anarana,
  • manatontosa hetsika ho avy.

Fametrahana mpizara mandray webhook

Mba hampandehanana ny mpizara mpandray webhook dia mila mpizara Linux ianao. Amin'ity lahatsoratra ity, ohatra, dia mampiasa ohatra virtoaly izay apetrakay amin'ny MCS izahay.

Andao hametraka ny rindrambaiko ilaina ary hanomboka ny webhook receiving server.

ubuntu@ubuntu-basic-1-2-10gb:~$ sudo apt-get install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bc dns-root-data dnsmasq-base ebtables landscape-common liblxc-common 
liblxc1 libuv1 lxcfs lxd lxd-client python3-attr python3-automat 
python3-click python3-constantly python3-hyperlink
  python3-incremental python3-pam python3-pyasn1-modules 
python3-service-identity python3-twisted python3-twisted-bin 
python3-zope.interface uidmap xdelta3
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui 
gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git
0 upgraded, 1 newly installed, 0 to remove and 46 not upgraded.
Need to get 3915 kB of archives.
After this operation, 32.3 MB of additional disk space will be used.
Get:1 http://MS1.clouds.archive.ubuntu.com/ubuntu bionic-updates/main 
amd64 git amd64 1:2.17.1-1ubuntu0.7 [3915 kB]
Fetched 3915 kB in 1s (5639 kB/s)
Selecting previously unselected package git.
(Reading database ... 53932 files and directories currently installed.)
Preparing to unpack .../git_1%3a2.17.1-1ubuntu0.7_amd64.deb ...
Unpacking git (1:2.17.1-1ubuntu0.7) ...
Setting up git (1:2.17.1-1ubuntu0.7) ...

Clone ny lahatahiry amin'ny webhook receiving server:

ubuntu@ubuntu-basic-1-2-10gb:~$ git clone
https://github.com/RomanenkoDenys/s3-webhook.git
Cloning into 's3-webhook'...
remote: Enumerating objects: 48, done.
remote: Counting objects: 100% (48/48), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 114 (delta 20), reused 45 (delta 18), pack-reused 66
Receiving objects: 100% (114/114), 23.77 MiB | 20.25 MiB/s, done.
Resolving deltas: 100% (49/49), done.

Andao hanomboka ny mpizara:

ubuntu@ubuntu-basic-1-2-10gb:~$ cd s3-webhook/
ubuntu@ubuntu-basic-1-2-10gb:~/s3-webhook$ sudo ./s3-webhook -port 80

Misoratra anarana amin'ny serivisy famoahana

Azonao atao ny manoratra ny mpizara fandraisana webhook anao amin'ny alΓ lan'ny API na ny interface interface. Ho an'ny fahatsorana dia hisoratra anarana amin'ny alΓ lan'ny interface web izahay:

  1. Andao ho any amin'ny fizarana siny ao amin'ny efitrano fanaraha-maso.
  2. Mandehana any amin'ny siny izay hamboarinay webhooks ary tsindrio ny fitaovana:

Ohatra iray amin'ny fampiharana entin'ny hetsika mifototra amin'ny webhooks amin'ny fitahirizana zavatra S3 Mail.ru Cloud Solutions

Mandehana any amin'ny tabilao Webhooks ary tsindrio Add:

Ohatra iray amin'ny fampiharana entin'ny hetsika mifototra amin'ny webhooks amin'ny fitahirizana zavatra S3 Mail.ru Cloud Solutions
Fenoy ny saha:

Ohatra iray amin'ny fampiharana entin'ny hetsika mifototra amin'ny webhooks amin'ny fitahirizana zavatra S3 Mail.ru Cloud Solutions

ID - ny anaran'ny webhook.

Hetsika - izay zava-nitranga hampitaina. Nametraka ny fandefasana ny hetsika rehetra mitranga rehefa miasa miaraka amin'ny rakitra (miampy sy mamafa).

URL β€” webhook mandray adiresy mpizara.

Ny prefix/suffix filtre dia sivana izay ahafahanao mamorona webhooks ho an'ny zavatra izay mifanaraka amin'ny fitsipika sasany ihany ny anarany. Ohatra, mba hahafahan'ny webhook hanetsika ny rakitra miaraka amin'ny fanitarana .png, in Tovana sivana mila manoratra "png" ianao.

Amin'izao fotoana izao, seranana 80 sy 443 ihany no tohanana amin'ny fidirana amin'ny mpizara mpandray webhook.

Aleo tsindrio Ampio hook ary ho hitantsika ireto manaraka ireto:

Ohatra iray amin'ny fampiharana entin'ny hetsika mifototra amin'ny webhooks amin'ny fitahirizana zavatra S3 Mail.ru Cloud Solutions
Nampiana Hook.

Ny mpizara mpandray webhook dia mampiseho ao amin'ny diariny ny fivoaran'ny fizotry ny fisoratana anarana hook:

ubuntu@ubuntu-basic-1-2-10gb:~/s3-webhook$ sudo ./s3-webhook -port 80
2020/06/15 12:01:14 [POST] incoming HTTP request from 
95.163.216.92:42530
2020/06/15 12:01:14 Got timestamp: 2020-06-15T15:01:13+03:00 TopicArn: 
mcs5259999770|myfiles-ash|s3:ObjectCreated:*,s3:ObjectRemoved:* Token: 
E2itMqAMUVVZc51pUhFWSp13DoxezvRxkUh5P7LEuk1dEe9y URL: 
http://89.208.199.220/webhook
2020/06/15 12:01:14 Generate responce signature: 
3754ce36636f80dfd606c5254d64ecb2fd8d555c27962b70b4f759f32c76b66d

Vita ny fisoratana anarana. Ao amin'ny fizarana manaraka dia hojerentsika akaiky ny algorithm amin'ny fiasan'ny mpizara mpandray webhook.

Famaritana ny mpizara mandray webhook

Amin'ny ohatra ataontsika, ny mpizara dia voasoratra ao amin'ny Go. Andeha hojerentsika ny fitsipika fototra amin'ny fiasan'izy io.

package main

// Generate hmac_sha256_hex
func HmacSha256hex(message string, secret string) string {
}

// Generate hmac_sha256
func HmacSha256(message string, secret string) string {
}

// Send subscription confirmation
func SubscriptionConfirmation(w http.ResponseWriter, req *http.Request, body []byte) {
}

// Send subscription confirmation
func GotRecords(w http.ResponseWriter, req *http.Request, body []byte) {
}

// Liveness probe
func Ping(w http.ResponseWriter, req *http.Request) {
    // log request
    log.Printf("[%s] incoming HTTP Ping request from %sn", req.Method, req.RemoteAddr)
    fmt.Fprintf(w, "Pongn")
}

//Webhook
func Webhook(w http.ResponseWriter, req *http.Request) {
}

func main() {

    // get command line args
    bindPort := flag.Int("port", 80, "number between 1-65535")
    bindAddr := flag.String("address", "", "ip address in dot format")
    flag.StringVar(&actionScript, "script", "", "external script to execute")
    flag.Parse()

    http.HandleFunc("/ping", Ping)
    http.HandleFunc("/webhook", Webhook)

log.Fatal(http.ListenAndServe(*bindAddr+":"+strconv.Itoa(*bindPort), nil))
}

Diniho ny tena asa:

  • Ping () - lalana mamaly amin'ny alΓ lan'ny URL/ping, fampiharana tsotra indrindra amin'ny fanadihadiana momba ny fiainana.
  • Webhook() - lalana lehibe, URL/webhook mpitantana:
    • manamafy ny fisoratana anarana amin'ny serivisy famoaham-boky (mankany amin'ny famandrihana Confirmation),
    • manodinkodina ny webhooks miditra (asa Gorecords).
  • Ny fiasa HmacSha256 sy HmacSha256hex dia fampiharana ny algorithm encryption HMAC-SHA256 sy HMAC-SHA256 miaraka amin'ny vokatra ho tadin'ny isa hexadecimal amin'ny kajy ny sonia.
  • Ny lehibe dia ny asa lehibe, ny fanodinana ny mari-pamantarana baiko ary ny fisoratana anarana amin'ny mpitantana URL.

Ireo mari-pamantarana baiko eken'ny mpizara:

  • -port no seranana hihainoan'ny mpizara.
  • -address - adiresy IP hohenoin'ny mpizara.
  • -script dia programa ivelany izay antsoina ho an'ny hook miditra tsirairay.

Andeha hojerentsika akaiky ny sasany amin'ireo fiasa:

//Webhook
func Webhook(w http.ResponseWriter, req *http.Request) {

    // Read body
    body, err := ioutil.ReadAll(req.Body)
    defer req.Body.Close()
    if err != nil {
        http.Error(w, err.Error(), 500)
        return
    }

    // log request
    log.Printf("[%s] incoming HTTP request from %sn", req.Method, req.RemoteAddr)
    // check if we got subscription confirmation request
    if strings.Contains(string(body), 
""Type":"SubscriptionConfirmation"") {
        SubscriptionConfirmation(w, req, body)
    } else {
        GotRecords(w, req, body)
    }

}

Ity fiasa ity dia mamaritra raha misy fangatahana hanamarina fisoratana anarana na webhook tonga. Toy izao manaraka izao avy amin'ny tahirin-kevitra, raha voamarina ny fisoratana anarana, ity rafitra Json manaraka ity dia voaray ao amin'ny fangatahana Post:

POST http://test.com HTTP/1.1
x-amz-sns-messages-type: SubscriptionConfirmation
content-type: application/json

{
    "Timestamp":"2019-12-26T19:29:12+03:00",
    "Type":"SubscriptionConfirmation",
    "Message":"You have chosen to subscribe to the topic $topic. To confirm the subscription you need to response with calculated signature",
    "TopicArn":"mcs2883541269|bucketA|s3:ObjectCreated:Put",
    "SignatureVersion":1,
    "Token":Β«RPE5UuG94rGgBH6kHXN9FUPugFxj1hs2aUQc99btJp3E49tAΒ»
}

Mila valiana ity fanontaniana ity:

content-type: application/json

{"signature":Β«ea3fce4bb15c6de4fec365d36bcebbc34ccddf54616d5ca12e1972f82b6d37afΒ»}

Raha ny sonia dia kajy toy izao:

signature = hmac_sha256(url, hmac_sha256(TopicArn, 
hmac_sha256(Timestamp, Token)))

Raha misy webhook tonga dia toy izao ny firafitry ny fangatahana Post:

POST <url> HTTP/1.1
x-amz-sns-messages-type: SubscriptionConfirmation

{ "Records":
    [
        {
            "s3": {
                "object": {
                    "eTag":"aed563ecafb4bcc5654c597a421547b2",
                    "sequencer":1577453615,
                    "key":"some-file-to-bucket",
                    "size":100
                },
            "configurationId":"1",
            "bucket": {
                "name": "bucketA",
                "ownerIdentity": {
                    "principalId":"mcs2883541269"}
                },
                "s3SchemaVersion":"1.0"
            },
            "eventVersion":"1.0",
            "requestParameters":{
                "sourceIPAddress":"185.6.245.156"
            },
            "userIdentity": {
                "principalId":"2407013e-cbc1-415f-9102-16fb9bd6946b"
            },
            "eventName":"s3:ObjectCreated:Put",
            "awsRegion":"ru-msk",
            "eventSource":"aws:s3",
            "responseElements": {
                "x-amz-request-id":"VGJR5rtJ"
            }
        }
    ]
}

Araka izany, miankina amin'ny fangatahana, mila mahatakatra ny fomba fanodinana ny angona ianao. Nifidy ny fidirana ho famantarana aho "Type":"SubscriptionConfirmation", satria misy ao amin'ny fangatahana fanamafisana famandrihana ary tsy ao amin'ny webhook. Miorina amin'ny fisian'ny / tsy fisian'ity fidirana ity amin'ny fangatahana POST, ny fanatanterahana ny programa dia mandeha amin'ny asa. SubscriptionConfirmation, na ao amin'ny asa GotRecords.

Tsy hojerentsika amin'ny antsipiriany ny fiasan'ny SubscriptionConfirmation; apetraka araka ny fitsipika napetraka ao tahirin-kevitra. Azonao jerena ny kaody loharano ho an'ity asa ity ao amin'ny project git repository.

Ny fiasan'ny GotRecords dia mamadika fangatahana ho avy ary ho an'ny zavatra Record tsirairay dia miantso script ivelany (izay nampidirina tao amin'ny parameter -script ny anarany) miaraka amin'ny masontsivana:

  • anarana siny
  • lakile zavatra
  • hetsika:
    • kopia - raha ao amin'ny fangatahana tany am-boalohany EventName = ObjectCreated | PutObject | PutObjectCopy
    • esory - raha ao amin'ny fangatahana tany am-boalohany EventName = ObjectRemoved | DeleteObject

Noho izany, raha misy hook tonga miaraka amin'ny fangatahana Post, araka ny voalaza ambony, ary ny parameter -script=script.sh dia hantsoina toy izao manaraka izao ny script:

script.sh  bucketA some-file-to-bucket copy

Tokony ho takatra fa ity mpizara mandray webhook ity dia tsy vahaolana famokarana feno, fa ohatra tsotsotra amin'ny fampiharana azo atao.

Ohatra amin'ny asa

Andao arindrantsika ny rakitra avy amin'ny siny lehibe ao amin'ny MCS mankany amin'ny siny backup ao amin'ny AWS. Ny siny lehibe dia antsoina hoe myfiles-ash, ny backup dia antsoina hoe myfiles-backup (ny fanamafisana ny siny ao amin'ny AWS dia mihoatra ny faritry ity lahatsoratra ity). Noho izany, rehefa apetraka ao anaty siny lehibe ny rakitra iray, dia tokony hiseho ao amin'ny backup ny kopiany, ary rehefa voafafa amin'ny lehibe izy dia tokony hofafana ao amin'ny backup.

Hiara-hiasa amin'ny siny mampiasa ny awscli utility izahay, izay mifanaraka amin'ny fitehirizana rahona MCS sy fitehirizana rahona AWS.

ubuntu@ubuntu-basic-1-2-10gb:~$ sudo apt-get install awscli
Reading package lists... Done
Building dependency tree
Reading state information... Done
After this operation, 34.4 MB of additional disk space will be used.
Unpacking awscli (1.14.44-1ubuntu1) ...
Setting up awscli (1.14.44-1ubuntu1) ...

Andao amboary ny fidirana amin'ny S3 MCS API:

ubuntu@ubuntu-basic-1-2-10gb:~$ aws configure --profile mcs
AWS Access Key ID [None]: hdywEPtuuJTExxxxxxxxxxxxxx
AWS Secret Access Key [None]: hDz3SgxKwXoxxxxxxxxxxxxxxxxxx
Default region name [None]:
Default output format [None]:

Andao amboary ny fidirana amin'ny AWS S3 API:

ubuntu@ubuntu-basic-1-2-10gb:~$ aws configure --profile aws
AWS Access Key ID [None]: AKIAJXXXXXXXXXXXX
AWS Secret Access Key [None]: dfuerphOLQwu0CreP5Z8l5fuXXXXXXXXXXXXXXXX
Default region name [None]:
Default output format [None]:

Andeha hojerentsika ny fidirana:

Ho an'ny AWS:

ubuntu@ubuntu-basic-1-2-10gb:~$ aws s3 ls --profile aws
2020-07-06 08:44:11 myfiles-backup

Ho an'ny MCS, rehefa mihazakazaka ny baiko ianao dia mila manampy β€”endpoint-url:

ubuntu@ubuntu-basic-1-2-10gb:~$ aws s3 ls --profile mcs --endpoint-url 
https://hb.bizmrg.com
2020-02-04 06:38:05 databasebackups-0cdaaa6402d4424e9676c75a720afa85
2020-05-27 10:08:33 myfiles-ash

Nidirana.

Andeha isika hanoratra script ho an'ny fanodinana ny fihodirana, andao hiantso azy s3_backup_mcs_aws.sh

#!/bin/bash
# Require aws cli
# if file added β€” copy it to backup bucket
# if file removed β€” remove it from backup bucket
# Variables
ENDPOINT_MCS="https://hb.bizmrg.com"
AWSCLI_MCS=`which aws`" --endpoint-url ${ENDPOINT_MCS} --profile mcs s3"
AWSCLI_AWS=`which aws`" --profile aws s3"
BACKUP_BUCKET="myfiles-backup"

SOURCE_BUCKET=""
SOURCE_FILE=""
ACTION=""

SOURCE="s3://${SOURCE_BUCKET}/${SOURCE_FILE}"
TARGET="s3://${BACKUP_BUCKET}/${SOURCE_FILE}"
TEMP="/tmp/${SOURCE_BUCKET}/${SOURCE_FILE}"

case ${ACTION} in
    "copy")
    ${AWSCLI_MCS} cp "${SOURCE}" "${TEMP}"
    ${AWSCLI_AWS} cp "${TEMP}" "${TARGET}"
    rm ${TEMP}
    ;;

    "delete")
    ${AWSCLI_AWS} rm ${TARGET}
    ;;

    *)
    echo "Usage: 
#!/bin/bash
# Require aws cli
# if file added β€” copy it to backup bucket
# if file removed β€” remove it from backup bucket
# Variables
ENDPOINT_MCS="https://hb.bizmrg.com"
AWSCLI_MCS=`which aws`" --endpoint-url ${ENDPOINT_MCS} --profile mcs s3"
AWSCLI_AWS=`which aws`" --profile aws s3"
BACKUP_BUCKET="myfiles-backup"
SOURCE_BUCKET="${1}"
SOURCE_FILE="${2}"
ACTION="${3}"
SOURCE="s3://${SOURCE_BUCKET}/${SOURCE_FILE}"
TARGET="s3://${BACKUP_BUCKET}/${SOURCE_FILE}"
TEMP="/tmp/${SOURCE_BUCKET}/${SOURCE_FILE}"
case ${ACTION} in
"copy")
${AWSCLI_MCS} cp "${SOURCE}" "${TEMP}"
${AWSCLI_AWS} cp "${TEMP}" "${TARGET}"
rm ${TEMP}
;;
"delete")
${AWSCLI_AWS} rm ${TARGET}
;;
*)
echo "Usage: ${0} sourcebucket sourcefile copy/delete"
exit 1
;;
esac
sourcebucket sourcefile copy/delete" exit 1 ;; esac

Andao hanomboka ny mpizara:

ubuntu@ubuntu-basic-1-2-10gb:~/s3-webhook$ sudo ./s3-webhook -port 80 -
script scripts/s3_backup_mcs_aws.sh

Andeha hojerentsika ny fomba fiasa. Amin'ny alalan'ny MCS web interface tsara ampio ny rakitra test.txt amin'ny siny myfiles-ash. Ny diarin'ny console dia mampiseho fa nisy fangatahana natao tamin'ny mpizara webhook:

2020/07/06 09:43:08 [POST] incoming HTTP request from 
95.163.216.92:56612
download: s3://myfiles-ash/test.txt to ../../../tmp/myfiles-ash/test.txt
upload: ../../../tmp/myfiles-ash/test.txt to 
s3://myfiles-backup/test.txt

Andao hojerentsika ny votoatin'ny siny myfiles-backup ao amin'ny AWS:

ubuntu@ubuntu-basic-1-2-10gb:~/s3-webhook$ aws s3 --profile aws ls 
myfiles-backup
2020-07-06 09:43:10       1104 test.txt

Amin'izao fotoana izao, amin'ny alΓ lan'ny interface web, dia hamafa ny rakitra ao amin'ny siny myfiles-ash izahay.

Diarin'ny mpizara:

2020/07/06 09:44:46 [POST] incoming HTTP request from 
95.163.216.92:58224
delete: s3://myfiles-backup/test.txt

Ao anatin'ny siny:

ubuntu@ubuntu-basic-1-2-10gb:~/s3-webhook$ aws s3 --profile aws ls 
myfiles-backup
ubuntu@ubuntu-basic-1-2-10gb:~$

Voafafa ny rakitra, voavaha ny olana.

Fehiny sy ToDo

Ny code rehetra ampiasaina ato amin'ity lahatsoratra ity dia ao amin'ny fitehirizako. Misy ihany koa ny ohatra momba ny script sy ny ohatra amin'ny fanisana sonia amin'ny fisoratana anarana webhooks.

Ity kaody ity dia tsy inona fa ohatra iray amin'ny fomba ahafahanao mampiasa S3 webhooks amin'ny hetsika ataonao. Araka ny nolazaiko tany am-piandohana, raha mikasa ny hampiasa mpizara toy izany amin'ny famokarana ianao, dia mila manoratra farafaharatsiny indray ny mpizara ho an'ny asa asynchronous: misoratra anarana amin'ny filaharana ny webhooks (RabbitMQ na NATS), ary avy eo dia manadihady azy ireo ary manamboatra azy ireo. miaraka amin'ny fangatahana mpiasa. Raha tsy izany, rehefa tonga be dia be ny webhooks, dia mety ho tratran'ny tsy fahampian'ny loharanon'ny mpizara hamitana asa ianao. Ny fisian'ny filaharana dia ahafahanao mizara ny mpizara sy ny mpiasa, ary koa mamaha olana amin'ny asa miverimberina raha misy ny tsy fahombiazana. Tsara ihany koa ny manova ny fanoratana ho amin'ny antsipiriany kokoa sy manara-penitra kokoa.

Mirary soa!

Famakiana bebe kokoa momba ny lohahevitra:

Source: www.habr.com

Add a comment