In general, AWS services can be accessed using
- AWS web interface,
- API libraries in a programming language, such as
boto3
for Python 3, - AWS command-line interface, i.e.
awscli
.
I opted for the API library since it is
FROM alpine:3.7 | |
ENV AWSCLI_VERSION "1.14.10" | |
RUN apk add --update \ | |
python \ | |
python-dev \ | |
py-pip \ | |
build-base \ | |
&& pip install awscli==$AWSCLI_VERSION --upgrade --user \ |
# coding:utf-8 | |
from elasticsearch import Elasticsearch | |
import json | |
# Define config | |
host = "127.0.0.1" | |
port = 9200 | |
timeout = 1000 | |
index = "index" |
# -*- coding: utf-8 -*- | |
from flask import Flask, request, render_template, current_app | |
from flask_wtf import Form | |
from wtforms.validators import DataRequired | |
from wtforms import SelectField, SelectMultipleField, SubmitField | |
app = Flask(__name__) |
# echo '{}' > event.json; mkdir -p libs; pip install attrs envattrs -t libs; \ | |
# export YOUR_PREFIX_SLACK_CHANNEL=your_project-staging; \ | |
# export YOUR_PREFIX_S3_BUCKET=pyconapac-bucket; \ | |
# export YOUR_PREFIX_THRESHOLD=50; \ | |
# python-lambda-local -l libs/ -f handler -t 5 lambda_pyconapac.py event.json | |
from typing import Dict | |
import attr | |
import envattrs |
The goal of this document is submitting a job to AWS Batch and confirming the result in CloudWatch Logs.
Since I've worked on ap-northeast-1
region, The following examples includes this region name.
import contextlib | |
import OpenSSL.crypto | |
import os | |
import requests | |
import ssl | |
import tempfile | |
@contextlib.contextmanager | |
def pfx_to_pem(pfx_path, pfx_password): | |
''' Decrypts the .pfx file to be used with requests. ''' |
Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py
file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.
Turns out, however, you can define fixtures in individual files like this:
tests/fixtures/add.py
import pytest
@pytest.fixture