본문 바로가기

반응형

Ops

(295)
AWS Lambda to Slack (basic) - function 생성 AWS Lambda to Slack - function 생성 Lambda 서비스로 이동하여 함수 메뉴를 선택한 다음 ‘함수 생성’을 선택합니다. (Lamdba → 함수 → 함수 생성) 다음의 항목을 입력하고 우측 하단의 ‘함수 생성’을 클릭합니다. IAM은 Lambda에서 다른 AWS 서비스로 연결하는 경우가 아니라면 basic으로 생성한 role을 연결하면 됩니다. 생성이 완료되면 기본 코드가 작성이 되어 있는 것을 확인할 수 있습니다. 해당 부분에 코드를 작성하고 사용하면 됩니다. 참고 (파이썬 기본 코드 양식) # python 3.8 import json def lambda_handler(event, context): # TODO implement return { 'statusCode': 200, ..
AWS Lambda to Slack (basic) - IAM role 생성 AWS Lambda to Slack - IAM role 생성 - lambda를 생성하려면 iam role 이 필수로 들어가야 합니다. - 기본적으로 slack 에 알람만 보내는 경우 Policy는 'AWSLambdaBasicExecutionRole' 만 있으면 됩니다. IAM 서비스로 이동하여 ‘역할’ 메뉴를 선택 후 ‘역할 만들기’를 클릭합니다. 신뢰할 수 있는 엔터티 유형에서 ‘AWS 서비스’를 선택합니다. 사용 사례는 Lambda를선택하고 제일 하단의 ‘다음’을 선택합니다. 권한 추가 화면에서 ‘awslambdabasic’을 입력하면 'AWSLambdaBasicExecutionRole' 을 확인할 수 있습니다. 해당 권한을 선택하고 제일 하단의 ‘다음’을 클릭합니다. Role의 이름을 지정하고 기타..
AWS Lambda to Slack - process 요약 (이론) AWS Lambda to Slack - process 요약 (이론) (basic) 1. IAM Role 생성 2. Lambda Function 생성 3. Lambda Function 변수 입력 4. Lambda 코드 입력 5. Lambda 테스트 6. 트리거 연결 (EventBridge, SNS, CloudWatch 등) (kms) 1. KMS 생성 2. IAM Role 생성 3. Lambda Function 생성 4. Lambda Function 변수 입력 5. Lambda Function 변수에 대한 IAM Role 업그레이드 6. Lambda 코드 입력 7. Lambda 테스트 8. 트리거 연결 (EventBridge, SNS, CloudWatch 등) by mkdir-chandler
AWS Lambda Code - infra noti AWS Lambda Code - infra noti # Python 3.7 import boto3 import json import logging import os from base64 import b64decode from urllib.request import Request, urlopen from urllib.error import URLError, HTTPError # The base-64 encoded, encrypted key (CiphertextBlob) stored in the kmsEncryptedHookUrl environment variable ENCRYPTED_HOOK_URL = os.environ['kmsEncryptedHookUrl'] # The Slack channel to s..
AWS Lambda Code - firehose peer AWS Lambda Code - firehose peer # Python 3.8 import base64 import json import datetime print('Loading function') def lambda_handler(event, context): output = [] for record in event['records']: print("recordId: " + record['recordId']) payload = base64.b64decode(record['data']).decode('utf-8') # JSON(payload) -> Dict(payload_dict) payload_dict = json.loads(payload) data_dict = {} print("payload_di..
AWS Lambda Code - 403 rewrite request AWS Lambda Code - 403 rewrite request # node.js 16.x exports.handler = (event, context, callback) => { const request = event.Records[0].cf.request; const headers = request.headers; const uri = request.uri; const host = request.headers.host[0].value; var domain = "https://mkdir-chandler.com" if ( uri != null && uri != "") domain = domain + request.uri if ( request.querystring != null && request.q..
AWS Lambda Code - 특정 region 요청 redirect AWS Lambda Code - 특정 region 요청 redirect function handler(event) { var request = event.request; var supported_countries = ['kr']; if (request.uri.substr(3,1) != '/') { var headers = request.headers; var newUri; var countryCode = headers['cloudfront-viewer-country'].value.toLowerCase(); if (supported_countries.includes(countryCode)) { newUri = 'https://mkdir-chandler.com:443/test'; var response = ..
AWS Lambda Code - 이미지 리사이징 (feat. cloudfront) AWS Lambda Code - 이미지 리사이징 (feat. cloudfront) const imagemin = require("imagemin"); const imageminGiflossy = require("imagemin-giflossy"); const fsPromise = require("fs").promises; const querystring = require("querystring"); const Sharp = require("sharp"); const AWS = require("aws-sdk"); const S3 = new AWS.S3({ region: "us-east-2" }); const BUCKET = { test1: "s3-ue2-test1", test2: "s3-ue2-test2"..
AWS Lamdba code - maintenance (node.js) AWS Lamdba code - maintenance (node.js) 점검 작업이 있을 경우 web 페이지로 접속하면 점검 안내 페이지 (혹은 이미지)를 보여주는 함수 세팅입니다. exports.handler = (event, context, callback) => { const request = event.Records[0].cf.request; const headers = request.headers; console.log('request_ip', request.clientIp); // if (user_agent && user_agent.match(bot.toLowerCase()) && 1===0) { if(request.clientIp != "192.168.1.50" && request.clien..
Podman Compose - install on rhel 8 Podman Compose - install on rhel 8 환경 - Oracle VirtualBox 6.0.14 Build r133895 - CentOS Linux release 8.2 (2004) x86_64 설치 dnf install python3-pip pip3 install podman-compose ■ Reference 내용 URL Github, containers/podman-compose https://github.com/containers/podman-compose - - by mkdir-chandler

728x90
반응형