AWS SES Logging

AWS SES ロギング Amazon SES ログにはどのようにアクセスできますか? Amazon SES でのメール送信ログを表示する AWS CloudTrail を使用した Amazon SES API コールのログ作成 SESの送信履歴を確認したい Terrafrom + Firefose Firehoseを使用してSESのログをS3バケットに記録するには、Terraformで以下のように記述することができます。 resource "aws_s3_bucket" "log_bucket" { bucket = "log-bucket" } resource "aws_ses_domain_identity" "example" { domain = "example.com" } resource "aws_ses_domain_identity_verification" "example" { domain = aws_ses_domain_identity.example.domain } resource "aws_ses_configuration_set" "example" { name = "example" } resource "aws_ses_event_destination" "example" { configuration_set_name = aws_ses_configuration_set.example.name name = "example" enabled = true kinesis_firehose_destination { role_arn = aws_iam_role.firehose_role.arn delivery_stream_arn = aws_kinesis_firehose_delivery_stream.firehose.arn } matching_types = [ "send", "reject", "bounce", "complaint", "delivery", "open", "click", ] } このコードでは、S3バケットを作成し、SESドメイン識別子を作成し、検証し、構成セットを作成し、イベント宛先を作成しています。 ...

2023年5月17日 · 1 分

Django Subquery

Subquery 合計値のアノテート サブクエリの合計値: 合計対象レコードを OuterRefで条件指定してして絞り込む values() で ユニークフィールドで GROUP BY する 対象フィールドの合計値をanotate する アノテートしたフィールドを values() で ValueList にしてSubqueryで返す(1件のはず) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 def verify(): from django.db.models import OuterRef, Subquery, F from django.db.models.functions import Coalesce from base.models.utils import aggr_sum_decimal as D from decimal import Decimal ref_query = dict( book__company_code=OuterRef("company_code"), book__processing_month=OuterRef("processing_month"), account_code=OuterRef("account_code"), account_item_code=OuterRef("account_item_code"), advances_code=OuterRef("outsource_code"), advances_branch_code=OuterRef("outsource_branch_code"), ) def bookitem_sum(bookitem): qs = ( bookitem.objects.filter(**ref_query) .values(*ref_query.keys()) .annotate(total=D("amount")) .values("total") ) return Subquery(qs) qs = models.CostOutsource.objects.annotate( sum_debit=Coalesce(bookitem_sum(BookDebit), Decimal("0")), sum_credit=Coalesce(bookitem_sum(BookCredit), Decimal("0")), ).exclude(debit_amount=F("sum_debit"), credit_amount=F("sum_credit")) Bing Djangoのクエリセットで、別のテーブルのフィールドの合計値をSubqueryを使ってannotateすることができます¹。以下は、例です。 ...

2023年5月17日 · 1 分

DRF: Content Negotiation

DRF: Content Negotiation DefaultContentNegotiation content_negotiation_classをカスタマイズするには、以下のようにします。 1 2 3 4 5 6 from rest_framework.negotiation import DefaultContentNegotiation class MyContentNegotiation(DefaultContentNegotiation): def select_renderer(self, request, renderers, format_suffix=None): # ここに処理を書きます。 pass 上記の例では、DefaultContentNegotiationを継承しています。 select_renderer()メソッドには、レンダラーを選択するための処理を書きます。 このメソッドは、リクエストオブジェクト、レンダラーのリスト、およびフォーマットサフィックスを引数として受け取ります。 ソース: Bing との会話 2023/5/12 (1) Content negotiation - Django REST framework. https://www.django-rest-framework.org/api-guide/content-negotiation/. (2) Django REST Framework - Content negotiation - HTTPは …. https://runebook.dev/ja/docs/django_rest_framework/api-guide/content-negotiation/index. (3) Django REST framework カスタマイズ方法 - チュートリアルの補足. https://qiita.com/okoppe8/items/c58bb3faaf26c9e2f27f. ViewSetでの設定 ViewSetごとにcontent_negotiation_classを設定することができます。 ...

2023年5月12日 · 1 分

pandas: カラム連結

pandas: カラム連結 pandasで数値カラム同士を文字列に変換するには、 df['新しい列名'] = df['数値カラム1名'].astype(str) + df['数値カラム2名'].astype(str) と書くことができます。 例えば、以下のようになります。 1 2 3 4 5 import pandas as pd df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) df['C'] = df['A'].astype(str) + df['B'].astype(str) print(df) 出力: A B C 0 1 3 13 1 2 4 24 以上のように、df['新しい列名'] = df['数値カラム1名'].astype(str) + df['数値カラム2名'].astype(str) を使って、2つの数値の列を文字列に変換してから連結して新しい列を追加することができます。 ソース: Bing との会話 2023/5/11 (1) python - dataframe内の数値から文字列に変換する方法 - スタック …. https://ja.stackoverflow.com/questions/74518/dataframe%e5%86%85%e3%81%ae%e6%95%b0%e5%80%a4%e3%81%8b%e3%82%89%e6%96%87%e5%ad%97%e5%88%97%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95. (2) 【Pandas】DataFrameから文字列と数値データのcolumnを分ける. https://mochablog.org/pandas-saparate-numerical-col/.

2023年5月11日 · 1 分

## Cognite(MAU=5,000) Show calculations

Cognite(MAU=5,000) Show calculations MAU = 5,000 Unit conversions Percent of monthly users who sign in through SAML or OIDC federation: 10 / 100 = 0.1 Pricing calculations SAML or OIDC federation cost (monthly) 5,000 MAUs x 0.10 SAML or OIDC federation requests = 500.00 SAML or OIDC federation MAU requests 500.00 SAML or OIDC federation MAUs - 50 free SAML or OIDC federation MAU requests per month = 450.00 billable SAML or OIDC federation MAU requests Max (450.00 billable SAML or OIDC federation MAU requests, 0 minimum billable SAML or OIDC federation MAU requests) = 450 total billable SAML or OIDC federation MAU requests 450 MAUs x 0.015 USD = 6.75 USD (SAML or OIDC federation MAU requests) SAML or OIDC federation cost (monthly): 6.75 USD User Pool MAU cost (monthly) 5,000 MAUs - 50000 free MAU requests per month = -45,000.00 billable MAU requests Max (-45000.000000 billable MAU requests, 0 Constant Unit) = 0.00 total billable MAU requests Tiered price for: 0.00 MAUs Total tier cost = 0.00 USD (User Pool MAUs) User Pool MAU cost (monthly): 0.00 USD Advanced security feature cost (monthly) 5,000 MAUs x 1 Advanced security features option enabled = 5,000.00 Advanced security feature MAUs Tiered price for: 5000.00 MAUs 5000 MAUs x 0.0500000000 USD = 250.00 USD Total tier cost = 250.00 USD (ASF MAUs) Advanced security feature cost (monthly): 250 USD Cognito MAU cost (monthly) 250 USD + 6.75 USD = 256.75 USD Cognito MAU cost (monthly): 256.75 USD

2023年5月8日 · 2 分

AWS Connect CCP

AWS Connect: CCP(Contact Control Panel) Contact Control Panel とは、Amazon Connect 問い合わせコントロールパネル (CCP) を使用して問い合わせと通信するための GUI の機能です ²。 エージェントが CCP にアクセスし、問い合わせを処理できるようになる前に、行わなければならない操作がいくつかあります ³。 ご参考になれば幸いです。 ソース: Bing との会話 2023/5/8 (1) 問い合わせコントロールパネルへのアクセスを提供する - Amazon …. https://docs.aws.amazon.com/ja_jp/connect/latest/adminguide/amazon-connect-contact-control-panel.html. (2) Provide access to the Contact Control Panel - Amazon Connect. https://docs.aws.amazon.com/connect/latest/adminguide/amazon-connect-contact-control-panel.html. (3) 【Amazon Connect】在宅コールセンター向けに CCP(発着信 …. https://qiita.com/duplicate1984/items/3a4d93a2e9bb5fcf54d1. 資料: Amazon Connect とは? 導入前に知っておきたい機能・料金・注意点と事例 Google ログイン AWS Connect に Google ユーザーを紐付けることは可能です。 ただし、紐付ける前に、AWS Cognito 単体で、ユーザ ID のサインアップ(ユーザ登録)・サインイン(ログイン)ができるようにする必要があります ³。 また、外部で認証されたユーザー(ID フェデレーション)へのアクセス権限を付与することもできます ¹。 ご参考になれば幸いです。 ソース: Bing との会話 2023/5/8 ...

2023年5月8日 · 1 分

autossh

autossh autossh は、ssh 接続が切断された場合に自動的に再接続してくれるプログラムです。 autossh を使用すると、ssh サービスを開始し、監視することができます。 プログラムの問題やネットワークの問題が発生した場合、ssh サービスを再起動できます。¹²³ 以下のように使用します。 1 autossh -M 0 -N -f -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -R 8080:localhost:80 user@remote_host この例では、リモートホスト上でポート 8080 を開き、ローカルホストのポート 80 に転送します。⁴ ソース: Bing との会話 2023/5/5 (1) 用 autossh 工具进行端口转发 - 腾讯云开发者社区-腾讯云. https://cloud.tencent.com/developer/article/1836005. (2) autossh 工具进行端口转发 - 简书. https://www.jianshu.com/p/ae2cd8d9a368. (3) 用 autossh 工具进行端口转发 | Escape. https://www.escapelife.site/posts/e6647650.html. (4) ssh 接続を維持し続ける autossh の使い方 – ぺけみさお - xmisao. https://www.xmisao.com/2013/07/16/autossh-how-to.html. (5) CentOS で autossh を systemd service として動かす - Qiita. https://qiita.com/sandopan65/items/e21bdf710ac70f691e21. (6) autossh と ssh ポートフォワードでルータ内のマシンにアクセスする …. https://qiita.com/wf9a5m75/items/a78262532ac4823104f0. ポートフォワード (-L, -R, -D) -L : ローカル -> リモート -R : リモート -> ローカル -D : ダイナミック(SOCKS) -N -N オプションは、ssh 接続を開始して、リモートシェルを実行しないようにします。¹²³ ...

2023年5月5日 · 2 分

jupyter: Django

Jupyter: Django 準備 django_extensions , notebookを入れておく settgins.py: 1 INSTALLED_APPS += ['django_extensions'] VSCode VSCodeでJupyterのPythonランタイムを選んでから以下を実行する 環境変数で、DJANGO_ALLOW_ASYNC_UNSAFE=true をセットしておく(.envとか) 1 2 3 4 5 6 import sys, os, django BASE_DIR = "path_ot_manage_py" sys.path.insert(0, BASE_DIR) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") django.setup() リモートサーバー autossh でポートフォワード PCの 8.8.8.8 -> リモート(EC2とか)の 8.8.8.8 にフォワードする: 1 autossh -M 0 -F .secrets/ssh.ec2.conf server -N -L 8888:localhost:8888 -4 カーネル起動 1 DJANGO_ALLOW_ASYNC_UNSAFE=true python manage.py shell_plus --notebook URLが表示されるので、ブラウザでアクセスする ...

2023年5月5日 · 1 分

redis

redis Ubuntu 1 sudo apt update && sudo apt install redis-server -y 1 2 $ ps ax | grep redis 1083463 ? Ssl 0:00 /usr/bin/redis-server 127.0.0.1:6379 redis-cli redis-cliコマンドでデータベース1に接続するには、次のように入力します。¹² redis-cli -n 1 このコマンドは、データベース1に接続するためのものです。-nオプションを使用して、データベース番号を指定します。 上記の例では、データベース番号が1であることを示しています。 ソース: Bing との会話 2023/5/5 (1) redis-cliの接続時によく使うコマンド使い方メモ - Qiita. https://qiita.com/a-nishimura/items/54b0d85dbce47685a36f. (2) 【入門】Redis - Qiita. https://qiita.com/wind-up-bird/items/f2d41d08e86789322c71. (3) redis-cliの使い方 - Qiita. https://qiita.com/sawada_masahiko/items/1f60936c421ecab8dfbf. (4) redis-cliでよく使うコマンド20選 - Qiita. https://qiita.com/hatsu/items/a52817364160e0b6bb60. (5) Redisコマンド一覧 - Qiita. https://qiita.com/taiba/items/18016906d80c13e88853. (6) リモート環境にあるRedisに接続する - 箱のプログラミング日記。. https://www.y-hakopro.com/entry/2020/10/31/185235. Django 1 poetry add django-redis settings.py: ...

2023年5月5日 · 1 分

djang-mptt: tree 構造で export する

django-mptt: Tree モデルを エクスポート mptt_tags テンプレートライブラリ の recursetree / endrecursetree タグを使う profiles/templates/profile/workgroup/tree.json: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 {% load mptt_tags %} [ {% recursetree nodes %} { "id": "{{ node.id }}", "code": "{{ node.code|default:''}}", "name": "{{ node.name }}", "path": "{{ node.path }}", "full_name": "{{ node.full_name }}", "data": {}, "children": [{{ children }}] }{% if node.get_next_sibling %},{% endif %} {% endrecursetree %} ] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 from django.template import engines, loader from django.utils.safestring import mark_safe from django.db.models import QuerySet def render(src, request=None, engine_name="django", safe=True, **ctx): text = engines[engine_name].from_string(src).render(ctx, request=request) return safe and mark_safe(text) or text def render_by(name, request=None, safe=True, **ctx): t = loader.get_template(name) text = t.render(ctx, request=request) return safe and mark_safe(text) or text def export_trees(nodes, model_class=None, template_name=None, request=None, safe=True, **ctx): if not model_class and isinstance(nodes, QuerySet): model_class = nodes.model if not template_name and model_class: template_name = f"{model_class._meta.app_label}/{model_class._meta.model_name}/tree.json" if not template_name: return "" return render_by(template_name, request=request, safe=safe, nodes=nodes, **ctx) 1 2 3 4 5 6 7 8 @main.command() @click.argument("path") @click.pass_context def workgroup_export(ctx, path): """ Workgroup Export """ nodes = models.Workgroup.objects.all() print(export_trees(nodes))

2023年5月4日 · 1 分