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
import random | |
from collections import Counter | |
random.seed(3) | |
pizzas = ['caipira', 'portuguesa', 'pepperoni', '4 queijos'] | |
print(Counter([random.sample(pizzas, 1)[0] for r in range(1000)])) |
IPython.core.debugger.Pdb.set_trace() | |
# DeprecationWarning: `Tracer` is deprecated since version 5.1, directly use `IPython.core.debugger.Pdb.set_trace()` | |
from IPython.core.debugger import Tracer; Tracer()() |
// paste it in your console and change the url to your needs. | |
function logout(to_url) { | |
var out = window.location.href.replace(/:\/\//, '://log:out@'); | |
jQuery.get(out).error(function() { | |
window.location = to_url; | |
}); | |
} |
from math import gcd | |
from functools import reduce | |
# or | |
# def gcd(a, b): | |
# """Return greatest common divisor using Euclid's Algorithm.""" | |
# while b: | |
# a, b = b, a % b | |
# return a |
# credits for -> https://www.sisense.com/blog/exact-row-counts-for-every-database-table/ | |
CREATE OR REPLACE FUNCTION | |
count_rows(schema text, tablename text) RETURNS integer | |
AS | |
$BODY$ | |
DECLARE | |
result integer; | |
query varchar; | |
BEGIN |
--- | |
- name: Create Instance in AWS | |
hosts: localhost | |
connection: local | |
gather_facts: false | |
vars: | |
aws_access_key: "xxxxxx" | |
aws_secret_key: "xxxxxx" | |
security_token: "xxxxxx" |
--- | |
# Name: ansible-aws-inventory-main.yml | |
# Description: this is the main file that calls the worker file (ansible-aws-inventory-worker.yml) to create an inventory of all the | |
# specific aws resources. | |
# Below are the resources that will be inventoried | |
# - vpc | |
# - subnet | |
# - igw | |
# - cgw | |
# - vgw |
# Name: ansible-aws-inventory-worker.yml | |
# Description: this is the worker file that called the main file (ansible-aws-inventory-main.yml) to to create an inventory of all the | |
# specific aws resources. This file, the worker file and the ansible inventory file must be placed in the same folder | |
# Prerequisites: | |
# - the worker file (ansible-aws-inventory-worker.yml) and the ansible hosts file must be present in the same folder as this file (ansible-aws-inventory-main.yml) | |
# - this script requires read access to all resources it will be querying. An AWS IAM user account must be created with the necessary permissions and with access keys enabled. | |
# At a minimum, to query all the resources mentioned above, the following permissions are required | |
# - AmazonVPCReadOnlyAccess | |
# - AmazonEC2ReadOnlyAccess | |
# - ElasticLoadBalancingReadOnly |
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 \ |