├── 202-AppEnvironmentVersion1
├── Test1
│ └── test.pattern
├── Test2
│ └── test.pattern
├── Test3
│ └── test.pattern
├── App1.zip
├── App2.zip
├── App3.zip
├── Test1.zip
├── Test2.zip
├── Test3.zip
├── App1
│ └── app.php
├── App3
│ └── app.php
└── App2
│ └── app.php
├── 206-LambdaCustomEnhancements
├── autosubnet
│ ├── netaddr-0.7.18.dist-info
│ │ ├── INSTALLER
│ │ ├── top_level.txt
│ │ ├── WHEEL
│ │ ├── DESCRIPTION.rst
│ │ ├── metadata.json
│ │ ├── RECORD
│ │ └── METADATA
│ ├── requests-2.11.1.dist-info
│ │ ├── INSTALLER
│ │ ├── top_level.txt
│ │ ├── WHEEL
│ │ └── metadata.json
│ ├── requests
│ │ ├── packages
│ │ │ ├── urllib3
│ │ │ │ ├── contrib
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── ntlmpool.py
│ │ │ │ ├── packages
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── ssl_match_hostname
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ └── _implementation.py
│ │ │ │ ├── util
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── request.py
│ │ │ │ │ ├── response.py
│ │ │ │ │ └── connection.py
│ │ │ │ ├── filepost.py
│ │ │ │ └── __init__.py
│ │ │ ├── chardet
│ │ │ │ ├── compat.py
│ │ │ │ ├── __init__.py
│ │ │ │ ├── constants.py
│ │ │ │ ├── euctwprober.py
│ │ │ │ ├── euckrprober.py
│ │ │ │ ├── gb2312prober.py
│ │ │ │ ├── big5prober.py
│ │ │ │ ├── cp949prober.py
│ │ │ │ ├── charsetprober.py
│ │ │ │ ├── mbcsgroupprober.py
│ │ │ │ ├── codingstatemachine.py
│ │ │ │ ├── chardetect.py
│ │ │ │ ├── utf8prober.py
│ │ │ │ ├── escprober.py
│ │ │ │ ├── sbcsgroupprober.py
│ │ │ │ ├── mbcharsetprober.py
│ │ │ │ ├── eucjpprober.py
│ │ │ │ ├── sjisprober.py
│ │ │ │ ├── charsetgroupprober.py
│ │ │ │ ├── sbcharsetprober.py
│ │ │ │ └── latin1prober.py
│ │ │ └── __init__.py
│ │ ├── certs.py
│ │ ├── hooks.py
│ │ ├── compat.py
│ │ ├── __init__.py
│ │ ├── exceptions.py
│ │ ├── structures.py
│ │ └── status_codes.py
│ └── netaddr
│ │ ├── ip
│ │ ├── rfc1924.py
│ │ └── nmap.py
│ │ ├── compat.py
│ │ └── __init__.py
├── Apps
│ ├── App1.zip
│ ├── App2.zip
│ ├── App3.zip
│ ├── Test1.zip
│ ├── Test2.zip
│ └── Test3.zip
├── autosubnet.zip
├── autosubnet.yaml
├── autosubnet.json
└── sharedinfrastructure2.yaml
├── 207-DeploymentPortal
├── APPS
│ ├── App1.zip
│ ├── App2.zip
│ ├── App3.zip
│ ├── Test1.zip
│ ├── Test2.zip
│ └── Test3.zip
├── autosubnet.zip
├── portalbucketanduser.yaml
└── autosubnet.yaml
├── 204-CrossStackReferences
├── Apps
│ ├── App1.zip
│ ├── App2.zip
│ ├── App3.zip
│ ├── Test1.zip
│ ├── Test2.zip
│ └── Test3.zip
├── sharedinfrastructure.yaml
└── sharedinfrastructure2.yaml
├── 205-StackUpdateImprovements
├── Apps
│ ├── App1.zip
│ ├── App2.zip
│ ├── App3.zip
│ ├── Test1.zip
│ ├── Test2.zip
│ └── Test3.zip
└── sharedinfrastructure2.yaml
├── 110-SelfServicePortal
├── Business
│ ├── bucketpolicy.json
│ ├── stackrole.yaml
│ ├── supportiam.yaml
│ ├── supportiam.json
│ ├── stackrole.json
│ ├── provisioningbuckets.json
│ ├── provisioningbuckets.yaml
│ └── support.html
└── Customer
│ ├── customeriamandrole.yaml
│ └── customeriamandrole.json
├── .editorconfig
├── .gitignore
├── README.md
├── 101-OURFIRSTTEMPLATE
├── wp-infrastructure-101-Linux1-distro-us-east-1.yaml
└── wp-infrastructure-101-Linux1-distro-us-east-1.json
├── 109-CFNServiceRoles
└── supportpolicy.json
├── 102-TemplatePortability
├── wp-infrastructure-102-Linux1-distro-.yaml
└── wp-infrastructure-102-Linux1-distro-.json
├── 103-UserData Installing WordPress
├── wp-infrastructure-103-Linux1-distro.yaml
└── wp-infrastructure-103-Linux1-distro.json
└── 201-SharedInfrastructure
└── sharedinfrastructure-201.yaml
/202-AppEnvironmentVersion1/Test1/test.pattern:
--------------------------------------------------------------------------------
1 | Hello World - Working - Version 1
2 |
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/Test2/test.pattern:
--------------------------------------------------------------------------------
1 | Hello World - Working - Version 2
2 |
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/Test3/test.pattern:
--------------------------------------------------------------------------------
1 | Hello World - Working - Version 3
2 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr-0.7.18.dist-info/INSTALLER:
--------------------------------------------------------------------------------
1 | pip
2 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests-2.11.1.dist-info/INSTALLER:
--------------------------------------------------------------------------------
1 | pip
2 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/contrib/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr-0.7.18.dist-info/top_level.txt:
--------------------------------------------------------------------------------
1 | netaddr
2 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests-2.11.1.dist-info/top_level.txt:
--------------------------------------------------------------------------------
1 | requests
2 |
--------------------------------------------------------------------------------
/207-DeploymentPortal/APPS/App1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/207-DeploymentPortal/APPS/App1.zip
--------------------------------------------------------------------------------
/207-DeploymentPortal/APPS/App2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/207-DeploymentPortal/APPS/App2.zip
--------------------------------------------------------------------------------
/207-DeploymentPortal/APPS/App3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/207-DeploymentPortal/APPS/App3.zip
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/App1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/202-AppEnvironmentVersion1/App1.zip
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/App2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/202-AppEnvironmentVersion1/App2.zip
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/App3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/202-AppEnvironmentVersion1/App3.zip
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/Test1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/202-AppEnvironmentVersion1/Test1.zip
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/Test2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/202-AppEnvironmentVersion1/Test2.zip
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/Test3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/202-AppEnvironmentVersion1/Test3.zip
--------------------------------------------------------------------------------
/207-DeploymentPortal/APPS/Test1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/207-DeploymentPortal/APPS/Test1.zip
--------------------------------------------------------------------------------
/207-DeploymentPortal/APPS/Test2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/207-DeploymentPortal/APPS/Test2.zip
--------------------------------------------------------------------------------
/207-DeploymentPortal/APPS/Test3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/207-DeploymentPortal/APPS/Test3.zip
--------------------------------------------------------------------------------
/207-DeploymentPortal/autosubnet.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/207-DeploymentPortal/autosubnet.zip
--------------------------------------------------------------------------------
/204-CrossStackReferences/Apps/App1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/204-CrossStackReferences/Apps/App1.zip
--------------------------------------------------------------------------------
/204-CrossStackReferences/Apps/App2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/204-CrossStackReferences/Apps/App2.zip
--------------------------------------------------------------------------------
/204-CrossStackReferences/Apps/App3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/204-CrossStackReferences/Apps/App3.zip
--------------------------------------------------------------------------------
/204-CrossStackReferences/Apps/Test1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/204-CrossStackReferences/Apps/Test1.zip
--------------------------------------------------------------------------------
/204-CrossStackReferences/Apps/Test2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/204-CrossStackReferences/Apps/Test2.zip
--------------------------------------------------------------------------------
/204-CrossStackReferences/Apps/Test3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/204-CrossStackReferences/Apps/Test3.zip
--------------------------------------------------------------------------------
/205-StackUpdateImprovements/Apps/App1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/205-StackUpdateImprovements/Apps/App1.zip
--------------------------------------------------------------------------------
/205-StackUpdateImprovements/Apps/App2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/205-StackUpdateImprovements/Apps/App2.zip
--------------------------------------------------------------------------------
/205-StackUpdateImprovements/Apps/App3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/205-StackUpdateImprovements/Apps/App3.zip
--------------------------------------------------------------------------------
/205-StackUpdateImprovements/Apps/Test1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/205-StackUpdateImprovements/Apps/Test1.zip
--------------------------------------------------------------------------------
/205-StackUpdateImprovements/Apps/Test2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/205-StackUpdateImprovements/Apps/Test2.zip
--------------------------------------------------------------------------------
/205-StackUpdateImprovements/Apps/Test3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/205-StackUpdateImprovements/Apps/Test3.zip
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/Apps/App1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/206-LambdaCustomEnhancements/Apps/App1.zip
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/Apps/App2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/206-LambdaCustomEnhancements/Apps/App2.zip
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/Apps/App3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/206-LambdaCustomEnhancements/Apps/App3.zip
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/Apps/Test1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/206-LambdaCustomEnhancements/Apps/Test1.zip
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/Apps/Test2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/206-LambdaCustomEnhancements/Apps/Test2.zip
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/Apps/Test3.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/206-LambdaCustomEnhancements/Apps/Test3.zip
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ACloudGuru/AdvancedCloudFormation/HEAD/206-LambdaCustomEnhancements/autosubnet.zip
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr-0.7.18.dist-info/WHEEL:
--------------------------------------------------------------------------------
1 | Wheel-Version: 1.0
2 | Generator: bdist_wheel (0.24.0)
3 | Root-Is-Purelib: true
4 | Tag: py2-none-any
5 | Tag: py3-none-any
6 |
7 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests-2.11.1.dist-info/WHEEL:
--------------------------------------------------------------------------------
1 | Wheel-Version: 1.0
2 | Generator: bdist_wheel (0.26.0)
3 | Root-Is-Purelib: true
4 | Tag: py2-none-any
5 | Tag: py3-none-any
6 |
7 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/packages/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 |
3 | from . import ssl_match_hostname
4 |
5 | __all__ = ('ssl_match_hostname', )
6 |
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/App1/app.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cody's Amazing PHP App
4 |
5 |
6 | Hello World - Working - Version 1'; ?>
7 |
8 |
9 |
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/App3/app.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cody's Amazing PHP App
4 |
5 |
6 | Hello World - Working - Version 3'; ?>
7 |
8 |
9 |
--------------------------------------------------------------------------------
/202-AppEnvironmentVersion1/App2/app.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cody's Amazing PHP App
4 |
5 |
6 | Hello World - HJFDHJBFJBHFDJBH - Version 2'; ?>
7 |
8 |
9 |
--------------------------------------------------------------------------------
/110-SelfServicePortal/Business/bucketpolicy.json:
--------------------------------------------------------------------------------
1 | {
2 | "Version": "2008-10-17",
3 | "Statement": [
4 | {
5 | "Sid": "ABC123",
6 | "Effect": "Allow",
7 | "Principal": {
8 | "AWS": "*"
9 | },
10 | "Action": "s3:GetObject",
11 | "Resource": "arn:aws:s3:::BUCKETNAMEHERE/*"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.json]
15 | indent_size = 2
16 |
17 | [*.yml]
18 | indent_size = 2
19 |
20 | [*.yaml]
21 | indent_style = space
22 | indent_size = 2
23 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py:
--------------------------------------------------------------------------------
1 | try:
2 | # Python 3.2+
3 | from ssl import CertificateError, match_hostname
4 | except ImportError:
5 | try:
6 | # Backport of the function from a pypi module
7 | from backports.ssl_match_hostname import CertificateError, match_hostname
8 | except ImportError:
9 | # Our vendored copy
10 | from ._implementation import CertificateError, match_hostname
11 |
12 | # Not needed, but documenting what we provide.
13 | __all__ = ('CertificateError', 'match_hostname')
14 |
--------------------------------------------------------------------------------
/110-SelfServicePortal/Business/stackrole.yaml:
--------------------------------------------------------------------------------
1 | Resources:
2 | iamrole:
3 | Type: "AWS::IAM::Role"
4 | Properties:
5 | AssumeRolePolicyDocument:
6 | Version: "2012-10-17"
7 | Statement:
8 | -
9 | Effect: "Allow"
10 | Action:
11 | - "sts:AssumeRole"
12 | Principal:
13 | Service:
14 | - "cloudformation.amazonaws.com"
15 | Path: "/"
16 | ManagedPolicyArns:
17 | - "arn:aws:iam::aws:policy/AdministratorAccess" # this would be tighter in production
18 | Outputs:
19 | stackrole:
20 | Description: Stack Role arn
21 | Value: !GetAtt iamrole.Arn
22 |
--------------------------------------------------------------------------------
/110-SelfServicePortal/Business/supportiam.yaml:
--------------------------------------------------------------------------------
1 | Resources:
2 | iamuser:
3 | Type: "AWS::IAM::User"
4 | Properties:
5 | UserName: whisupport
6 | ManagedPolicyArns:
7 | - "arn:aws:iam::aws:policy/AdministratorAccess"
8 | LoginProfile:
9 | Password: "P@55w0rd"
10 | PasswordResetRequired: false
11 | iamkeys:
12 | DependsOn: iamuser
13 | Type: "AWS::IAM::AccessKey"
14 | Properties:
15 | UserName: whisupport
16 | Outputs:
17 | adminakid:
18 | Description: Support Access Key ID
19 | Value: !Ref iamkeys
20 | adminsecretkey:
21 | Description: Support Secret Access Key
22 | Value: !GetAtt iamkeys.SecretAccessKey
23 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/certs.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | """
5 | requests.certs
6 | ~~~~~~~~~~~~~~
7 |
8 | This module returns the preferred default CA certificate bundle.
9 |
10 | If you are packaging Requests, e.g., for a Linux distribution or a managed
11 | environment, you can change the definition of where() to return a separately
12 | packaged CA bundle.
13 | """
14 | import os.path
15 |
16 | try:
17 | from certifi import where
18 | except ImportError:
19 | def where():
20 | """Return the preferred certificate bundle."""
21 | # vendored bundle inside Requests
22 | return os.path.join(os.path.dirname(__file__), 'cacert.pem')
23 |
24 | if __name__ == '__main__':
25 | print(where())
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Folder view configuration files
2 | .DS_Store
3 | Desktop.ini
4 |
5 | # Thumbnail cache files
6 | ._*
7 | Thumbs.db
8 |
9 | # Files that might appear on external disks
10 | .Spotlight-V100
11 | .Trashes
12 |
13 | # Compiled Python files
14 | *.pyc
15 |
16 | # Compiled C++ files
17 | *.out
18 |
19 | # Application specific files
20 | venv
21 | node_modules
22 | .sass-cache
23 | #
24 |
25 | # zappa_settings.json
26 | # =======================
27 | *.*~
28 | *.pyc
29 | **/pyc
30 | **/*.pyc
31 | *.swp
32 | *.tmp
33 | *~
34 | *.pydevproject
35 | *.project
36 | */*.xml
37 | **/*.xml
38 | workspace.xml
39 | */workspace.xml
40 | **/workspace.xml
41 |
42 | .idea
43 | .idea/*
44 | .idea/*.xml
45 | */.idea
46 | **/.idea
47 | */.idea/*
48 | **/.idea/*
49 | .idea/
50 | Notes.txt
51 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # A Cloud Guru - Advanced Cloud Formation
2 | Prepared by Adrian Cantrill 2016
3 |
4 | (c) A Cloud Guru 2016, 2019
5 | Lab files for A Cloud Guru - Advanced CloudFormation Course
6 |
7 | Please note, this is provided as-is, neither I, nor A Cloud Guru support this code. If you do identify any errors, then please identify and we will attempt to fix on a best efforts basis.
8 |
9 | ## aCloud.Guru
10 | This file was created for the purposes of the Advanced Cloud Formation Course from [ACloud.Guru](https://acloud.guru)
11 |
12 | ## IMPORTANT
13 | These files are distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
14 |
15 | ## Updated:
16 | - Dec 2017 - Ported to this new Repo
17 | - Jan 2019 - revised AMIs to Jan 2019, updated template names to make the Linux(1) version clear, and small tweaks to the scripts to fix minor bugs.
18 |
19 |
20 |
--------------------------------------------------------------------------------
/101-OURFIRSTTEMPLATE/wp-infrastructure-101-Linux1-distro-us-east-1.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | AWSTemplateFormatVersion: '2010-09-09'
3 | Description: 'A simple template intended to be run in N.Virginia (us-east-1) with a Linux (1) distro. Feel free to change the ami so that you can run this in a different Region'
4 | Resources:
5 | DB:
6 | Type: "AWS::RDS::DBInstance"
7 | Properties:
8 | AllocatedStorage: 5
9 | StorageType: gp2
10 | DBInstanceClass: db.t2.micro
11 | DBName: wordpress
12 | Engine: MySQL
13 | MasterUsername: wordpress
14 | MasterUserPassword: w0rdpr355
15 | EC2:
16 | Type: AWS::EC2::Instance
17 | Properties:
18 | ImageId: ami-0080e4c5bc078760e # Linux (1), N.Virginia - Sept 2016
19 | InstanceType: t2.micro
20 | S3:
21 | Type: "AWS::S3::Bucket"
22 | Properties:
23 | BucketName: wp-xxxxxxxxxxx # replace xxxxxxxxxxx with random
24 |
25 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/hooks.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | requests.hooks
5 | ~~~~~~~~~~~~~~
6 |
7 | This module provides the capabilities for the Requests hooks system.
8 |
9 | Available hooks:
10 |
11 | ``response``:
12 | The response generated from a Request.
13 | """
14 | HOOKS = ['response']
15 |
16 |
17 | def default_hooks():
18 | return dict((event, []) for event in HOOKS)
19 |
20 | # TODO: response is the only one
21 |
22 |
23 | def dispatch_hook(key, hooks, hook_data, **kwargs):
24 | """Dispatches a hook dictionary on a given piece of data."""
25 | hooks = hooks or dict()
26 | hooks = hooks.get(key)
27 | if hooks:
28 | if hasattr(hooks, '__call__'):
29 | hooks = [hooks]
30 | for hook in hooks:
31 | _hook_data = hook(hook_data, **kwargs)
32 | if _hook_data is not None:
33 | hook_data = _hook_data
34 | return hook_data
35 |
--------------------------------------------------------------------------------
/101-OURFIRSTTEMPLATE/wp-infrastructure-101-Linux1-distro-us-east-1.json:
--------------------------------------------------------------------------------
1 | {
2 | "AWSTemplateFormatVersion": "2010-09-09",
3 | "Description": "A simple template intended to be run in N.Virginia (us-east-1) with a Linux (1) distro. Feel free to change the ami so that you can run this in a different Region",
4 | "Resources": {
5 | "DB": {
6 | "Type": "AWS::RDS::DBInstance",
7 | "Properties": {
8 | "AllocatedStorage": "5",
9 | "StorageType": "gp2",
10 | "DBInstanceClass": "db.t2.micro",
11 | "DBName": "wordpress",
12 | "Engine": "MySQL",
13 | "MasterUsername": "wordpress",
14 | "MasterUserPassword": "w0rdpr355"
15 | }
16 | },
17 | "EC2": {
18 | "Type": "AWS::EC2::Instance",
19 | "Properties": {
20 | "ImageId": "ami-0080e4c5bc078760e",
21 | "InstanceType": "t2.micro"
22 | }
23 | },
24 | "S3": {
25 | "Type": "AWS::S3::Bucket",
26 | "Properties": {
27 | "BucketName": "wp-xxxxxxxxxxx"
28 | }
29 | }
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/110-SelfServicePortal/Business/supportiam.json:
--------------------------------------------------------------------------------
1 | {
2 | "Resources" : {
3 | "iamuser" : {
4 | "Type": "AWS::IAM::User",
5 | "Properties" : {
6 | "UserName" : "whisupport",
7 | "ManagedPolicyArns" : [
8 | "arn:aws:iam::aws:policy/AdministratorAccess"
9 | ],
10 | "LoginProfile" : {
11 | "Password" : "P@55w0rd",
12 | "PasswordResetRequired" : "false"
13 | }
14 | }
15 | },
16 | "iamkeys" : {
17 | "DependsOn" : "iamuser",
18 | "Type" : "AWS::IAM::AccessKey",
19 | "Properties" : {
20 | "UserName" : "whisupport"
21 | }
22 | }
23 | },
24 | "Outputs" : {
25 | "adminakid" : {
26 | "Description" : "Support Access Key ID",
27 | "Value" : {"Ref" : "iamkeys"}
28 | },
29 | "adminsecretkey" : {
30 | "Description" : "Support Secret Access Key",
31 | "Value" : {"Fn::GetAtt" : ["iamkeys", "SecretAccessKey"]}
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/util/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | # For backwards compatibility, provide imports that used to be here.
3 | from .connection import is_connection_dropped
4 | from .request import make_headers
5 | from .response import is_fp_closed
6 | from .ssl_ import (
7 | SSLContext,
8 | HAS_SNI,
9 | IS_PYOPENSSL,
10 | assert_fingerprint,
11 | resolve_cert_reqs,
12 | resolve_ssl_version,
13 | ssl_wrap_socket,
14 | )
15 | from .timeout import (
16 | current_time,
17 | Timeout,
18 | )
19 |
20 | from .retry import Retry
21 | from .url import (
22 | get_host,
23 | parse_url,
24 | split_first,
25 | Url,
26 | )
27 |
28 | __all__ = (
29 | 'HAS_SNI',
30 | 'IS_PYOPENSSL',
31 | 'SSLContext',
32 | 'Retry',
33 | 'Timeout',
34 | 'Url',
35 | 'assert_fingerprint',
36 | 'current_time',
37 | 'is_connection_dropped',
38 | 'is_fp_closed',
39 | 'get_host',
40 | 'parse_url',
41 | 'make_headers',
42 | 'resolve_cert_reqs',
43 | 'resolve_ssl_version',
44 | 'split_first',
45 | 'ssl_wrap_socket',
46 | )
47 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr-0.7.18.dist-info/DESCRIPTION.rst:
--------------------------------------------------------------------------------
1 | Provides provides support for:
2 |
3 | Layer 3 addresses
4 |
5 | - IPv4 and IPv6 addresses, subnets, masks, prefixes
6 | - iterating, slicing, sorting, summarizing and classifying IP networks
7 | - dealing with various ranges formats (CIDR, arbitrary ranges and globs, nmap)
8 | - set based operations (unions, intersections etc) over IP addresses and subnets
9 | - parsing a large variety of different formats and notations
10 | - looking up IANA IP block information
11 | - generating DNS reverse lookups
12 | - supernetting and subnetting
13 |
14 | Layer 2 addresses
15 |
16 | - representation and manipulation MAC addresses and EUI-64 identifiers
17 | - looking up IEEE organisational information (OUI, IAB)
18 | - generating derived IPv6 addresses
19 |
20 | Changes
21 | -------
22 |
23 | For details on the latest updates and changes, see
24 |
25 | https://github.com/drkjam/netaddr/blob/rel-0.7.x/CHANGELOG
26 |
27 | Documentation
28 | -------------
29 | - https://pythonhosted.org/netaddr/
30 | - https://netaddr.readthedocs.org/en/latest/
31 |
32 |
33 |
--------------------------------------------------------------------------------
/109-CFNServiceRoles/supportpolicy.json:
--------------------------------------------------------------------------------
1 | {
2 | "Version": "2012-10-17",
3 | "Statement": [
4 | {
5 | "Sid": "Stmt1478055099000",
6 | "Effect": "Allow",
7 | "Action": [
8 | "cloudformation:CreateUploadBucket",
9 | "cloudformation:GetTemplateSummary",
10 | "cloudformation:CreateStack",
11 | "cloudformation:DeleteStack",
12 | "cloudformation:DescribeStacks",
13 | "cloudformation:UpdateStack",
14 | "cloudformation:ListStacks",
15 | "cloudformation:ListStackResources",
16 | "cloudformation:DescribeStackEvents",
17 | "cloudformation:CreateChangeSet",
18 | "cloudformation:GetTemplate",
19 | "cloudformation:GetStackPolicy",
20 | "cloudformation:ListChangeSets",
21 | "cloudformation:DescribeChangeSet",
22 | "s3:PutObject",
23 | "s3:GetObject",
24 | "s3:CreateBucket",
25 | "iam:ListRoles"
26 | ],
27 | "Resource": [
28 | "*"
29 | ]
30 | }
31 | ]
32 | }
33 |
--------------------------------------------------------------------------------
/110-SelfServicePortal/Business/stackrole.json:
--------------------------------------------------------------------------------
1 | {
2 | "Resources" : {
3 | "iamrole" : {
4 | "Type" : "AWS::IAM::Role",
5 | "Properties" : {
6 | "AssumeRolePolicyDocument" : {
7 | "Version" : "2012-10-17",
8 | "Statement" : [
9 | {
10 | "Effect" : "Allow",
11 | "Action" : [
12 | "sts:AssumeRole"
13 | ],
14 | "Principal" : {
15 | "Service": [
16 | "cloudformation.amazonaws.com"
17 | ]
18 | }
19 | }
20 | ]
21 | },
22 | "Path" : "/",
23 | "ManagedPolicyArns": [
24 | "arn:aws:iam::aws:policy/AdministratorAccess"
25 | ]
26 | }
27 | }
28 | },
29 | "Outputs" : {
30 | "stackrole" : {
31 | "Description" : "Stack Role Arn",
32 | "Value" : {"Fn::GetAtt" : ["iamrole", "Arn"]}
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/110-SelfServicePortal/Business/provisioningbuckets.json:
--------------------------------------------------------------------------------
1 | {
2 | "Resources" : {
3 | "S3Bucket" : {
4 | "Type" : "AWS::S3::Bucket",
5 | "Properties" : {
6 | "AccessControl" : "PublicRead",
7 | "WebsiteConfiguration" : {
8 | "ErrorDocument" : "index.html",
9 | "IndexDocument" : "index.html"
10 | }
11 | }
12 | },
13 | "S3BucketPolicy" : {
14 | "Type" : "AWS::S3::BucketPolicy",
15 | "Properties" : {
16 | "Bucket" : {"Ref" : "S3Bucket"},
17 | "PolicyDocument" : {
18 | "Statement" : [
19 | {
20 | "Sid" : "ABC123",
21 | "Action" : [
22 | "s3:GetObject"
23 | ],
24 | "Effect" : "Allow",
25 | "Resource" : {"Fn::Join" : ["", ["arn:aws:s3:::", {"Ref" : "S3Bucket"}, "/*"]]},
26 | "Principal" : {
27 | "AWS" : [ "*" ]
28 | }
29 | }
30 | ]
31 | }
32 | }
33 | }
34 | },
35 | "Outputs" : {
36 | "federationHTML" : {
37 | "Description" : "HTML URL",
38 | "Value" : {"Fn::Join" : ["", [{"Fn::GetAtt" : ["S3Bucket", "WebsiteURL"]}, "/federationdemo.html"] ]}
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests-2.11.1.dist-info/metadata.json:
--------------------------------------------------------------------------------
1 | {"generator": "bdist_wheel (0.26.0)", "summary": "Python HTTP for Humans.", "classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Natural Language :: English", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy"], "extensions": {"python.details": {"project_urls": {"Home": "http://python-requests.org"}, "contacts": [{"email": "me@kennethreitz.com", "name": "Kenneth Reitz", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}}}, "license": "Apache 2.0", "metadata_version": "2.0", "name": "requests", "extras": ["security", "socks"], "run_requires": [{"requires": ["PySocks (>=1.5.6)"], "extra": "socks"}, {"requires": ["ndg-httpsclient", "pyOpenSSL (>=0.13)", "pyasn1"], "extra": "security"}], "version": "2.11.1", "test_requires": [{"requires": ["pytest (>=2.8.0)", "pytest-cov", "pytest-httpbin (==0.0.7)"]}]}
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/compat.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # Contributor(s):
3 | # Ian Cordasco - port to Python
4 | #
5 | # This library is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU Lesser General Public
7 | # License as published by the Free Software Foundation; either
8 | # version 2.1 of the License, or (at your option) any later version.
9 | #
10 | # This library is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | # Lesser General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU Lesser General Public
16 | # License along with this library; if not, write to the Free Software
17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 | # 02110-1301 USA
19 | ######################### END LICENSE BLOCK #########################
20 |
21 | import sys
22 |
23 |
24 | if sys.version_info < (3, 0):
25 | base_str = (str, unicode)
26 | else:
27 | base_str = (bytes, str)
28 |
29 |
30 | def wrap_ord(a):
31 | if sys.version_info < (3, 0) and isinstance(a, base_str):
32 | return ord(a)
33 | else:
34 | return a
35 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/__init__.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # This library is free software; you can redistribute it and/or
3 | # modify it under the terms of the GNU Lesser General Public
4 | # License as published by the Free Software Foundation; either
5 | # version 2.1 of the License, or (at your option) any later version.
6 | #
7 | # This library is distributed in the hope that it will be useful,
8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 | # Lesser General Public License for more details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public
13 | # License along with this library; if not, write to the Free Software
14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
15 | # 02110-1301 USA
16 | ######################### END LICENSE BLOCK #########################
17 |
18 | __version__ = "2.3.0"
19 | from sys import version_info
20 |
21 |
22 | def detect(aBuf):
23 | if ((version_info < (3, 0) and isinstance(aBuf, unicode)) or
24 | (version_info >= (3, 0) and not isinstance(aBuf, bytes))):
25 | raise ValueError('Expected a bytes object, not a unicode object')
26 |
27 | from . import universaldetector
28 | u = universaldetector.UniversalDetector()
29 | u.reset()
30 | u.feed(aBuf)
31 | u.close()
32 | return u.result
33 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/constants.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | #
13 | # This library is free software; you can redistribute it and/or
14 | # modify it under the terms of the GNU Lesser General Public
15 | # License as published by the Free Software Foundation; either
16 | # version 2.1 of the License, or (at your option) any later version.
17 | #
18 | # This library is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 | # Lesser General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU Lesser General Public
24 | # License along with this library; if not, write to the Free Software
25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 | # 02110-1301 USA
27 | ######################### END LICENSE BLOCK #########################
28 |
29 | _debug = 0
30 |
31 | eDetecting = 0
32 | eFoundIt = 1
33 | eNotMe = 2
34 |
35 | eStart = 0
36 | eError = 1
37 | eItsMe = 2
38 |
39 | SHORTCUT_THRESHOLD = 0.95
40 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/__init__.py:
--------------------------------------------------------------------------------
1 | '''
2 | Debian and other distributions "unbundle" requests' vendored dependencies, and
3 | rewrite all imports to use the global versions of ``urllib3`` and ``chardet``.
4 | The problem with this is that not only requests itself imports those
5 | dependencies, but third-party code outside of the distros' control too.
6 |
7 | In reaction to these problems, the distro maintainers replaced
8 | ``requests.packages`` with a magical "stub module" that imports the correct
9 | modules. The implementations were varying in quality and all had severe
10 | problems. For example, a symlink (or hardlink) that links the correct modules
11 | into place introduces problems regarding object identity, since you now have
12 | two modules in `sys.modules` with the same API, but different identities::
13 |
14 | requests.packages.urllib3 is not urllib3
15 |
16 | With version ``2.5.2``, requests started to maintain its own stub, so that
17 | distro-specific breakage would be reduced to a minimum, even though the whole
18 | issue is not requests' fault in the first place. See
19 | https://github.com/kennethreitz/requests/pull/2375 for the corresponding pull
20 | request.
21 | '''
22 |
23 | from __future__ import absolute_import
24 | import sys
25 |
26 | try:
27 | from . import urllib3
28 | except ImportError:
29 | import urllib3
30 | sys.modules['%s.urllib3' % __name__] = urllib3
31 |
32 | try:
33 | from . import chardet
34 | except ImportError:
35 | import chardet
36 | sys.modules['%s.chardet' % __name__] = chardet
37 |
--------------------------------------------------------------------------------
/110-SelfServicePortal/Business/provisioningbuckets.yaml:
--------------------------------------------------------------------------------
1 | Resources:
2 | resbucket:
3 | Type: "AWS::S3::Bucket"
4 | Properties:
5 | AccessControl: PublicRead
6 | WebsiteConfiguration:
7 | ErrorDocument: index.html
8 | IndexDocument: index.html
9 | selfservebucket:
10 | Type: "AWS::S3::Bucket"
11 | Properties:
12 | AccessControl: PublicRead
13 | WebsiteConfiguration:
14 | ErrorDocument: index.html
15 | IndexDocument: index.html
16 | resbucketpolicy:
17 | Type: "AWS::S3::BucketPolicy"
18 | Properties:
19 | Bucket: !Ref resbucket
20 | PolicyDocument:
21 | Statement:
22 | -
23 | Sid: "ABC123"
24 | Action:
25 | - "s3:GetObject"
26 | Effect: Allow
27 | Resource: !Join ["", ["arn:aws:s3:::", !Ref resbucket, "/*"]]
28 | Principal:
29 | AWS:
30 | - "*"
31 | selfservebucketpolicy:
32 | Type: "AWS::S3::BucketPolicy"
33 | Properties:
34 | Bucket: !Ref selfservebucket
35 | PolicyDocument:
36 | Statement:
37 | -
38 | Sid: "ABC123"
39 | Action:
40 | - "s3:GetObject"
41 | Effect: Allow
42 | Resource: !Join ["", ["arn:aws:s3:::", !Ref selfservebucket, "/*"]]
43 | Principal:
44 | AWS:
45 | - "*"
46 | Outputs:
47 | resbucketurl:
48 | Description: URL for Resource Bucket
49 | Value: !GetAtt resbucket.WebsiteURL
50 | selfservebucketURL:
51 | Description: URL for Self Service Portal
52 | Value: !GetAtt selfservebucket.WebsiteURL
53 |
--------------------------------------------------------------------------------
/207-DeploymentPortal/portalbucketanduser.yaml:
--------------------------------------------------------------------------------
1 | Resources:
2 | iamuser:
3 | Type: "AWS::IAM::User"
4 | Properties:
5 | UserName: cdllcportal
6 | ManagedPolicyArns:
7 | - "arn:aws:iam::aws:policy/AdministratorAccess"
8 | LoginProfile:
9 | Password: "P@55w0rd"
10 | PasswordResetRequired: false
11 | iamkeys:
12 | DependsOn: iamuser
13 | Type: "AWS::IAM::AccessKey"
14 | Properties:
15 | UserName: cdllcportal
16 | portalbucket:
17 | Type: "AWS::S3::Bucket"
18 | Properties:
19 | CorsConfiguration:
20 | CorsRules:
21 | - AllowedHeaders: ['*']
22 | AllowedMethods: ['GET']
23 | AllowedOrigins: ['*']
24 | Id: rule1
25 | MaxAge: '3000'
26 | AccessControl: PublicRead
27 | WebsiteConfiguration:
28 | ErrorDocument: index.html
29 | IndexDocument: index.html
30 | portalbucketpolicy:
31 | Type: "AWS::S3::BucketPolicy"
32 | Properties:
33 | Bucket: !Ref portalbucket
34 | PolicyDocument:
35 | Statement:
36 | -
37 | Sid: "ABC123"
38 | Action:
39 | - "s3:GetObject"
40 | Effect: Allow
41 | Resource: !Join ["", ["arn:aws:s3:::", !Ref portalbucket, "/*"]]
42 | Principal:
43 | AWS:
44 | - "*"
45 | Outputs:
46 | resbucketurl:
47 | Description: URL for Portal Bucket
48 | Value: !Sub ${portalbucket.WebsiteURL}/portal.html
49 | adminakid:
50 | Description: Portal Access Key ID
51 | Value: !Ref iamkeys
52 | adminsecretkey:
53 | Description: Portal Secret Access Key
54 | Value: !GetAtt iamkeys.SecretAccessKey
55 |
56 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/compat.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | requests.compat
5 | ~~~~~~~~~~~~~~~
6 |
7 | This module handles import compatibility issues between Python 2 and
8 | Python 3.
9 | """
10 |
11 | from .packages import chardet
12 |
13 | import sys
14 |
15 | # -------
16 | # Pythons
17 | # -------
18 |
19 | # Syntax sugar.
20 | _ver = sys.version_info
21 |
22 | #: Python 2.x?
23 | is_py2 = (_ver[0] == 2)
24 |
25 | #: Python 3.x?
26 | is_py3 = (_ver[0] == 3)
27 |
28 | try:
29 | import simplejson as json
30 | except (ImportError, SyntaxError):
31 | # simplejson does not support Python 3.2, it throws a SyntaxError
32 | # because of u'...' Unicode literals.
33 | import json
34 |
35 | # ---------
36 | # Specifics
37 | # ---------
38 |
39 | if is_py2:
40 | from urllib import quote, unquote, quote_plus, unquote_plus, urlencode, getproxies, proxy_bypass
41 | from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag
42 | from urllib2 import parse_http_list
43 | import cookielib
44 | from Cookie import Morsel
45 | from StringIO import StringIO
46 | from .packages.urllib3.packages.ordered_dict import OrderedDict
47 |
48 | builtin_str = str
49 | bytes = str
50 | str = unicode
51 | basestring = basestring
52 | numeric_types = (int, long, float)
53 |
54 | elif is_py3:
55 | from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag
56 | from urllib.request import parse_http_list, getproxies, proxy_bypass
57 | from http import cookiejar as cookielib
58 | from http.cookies import Morsel
59 | from io import StringIO
60 | from collections import OrderedDict
61 |
62 | builtin_str = str
63 | str = str
64 | bytes = bytes
65 | basestring = (str, bytes)
66 | numeric_types = (int, float)
67 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/euctwprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import EUCTWDistributionAnalysis
31 | from .mbcssm import EUCTWSMModel
32 |
33 | class EUCTWProber(MultiByteCharSetProber):
34 | def __init__(self):
35 | MultiByteCharSetProber.__init__(self)
36 | self._mCodingSM = CodingStateMachine(EUCTWSMModel)
37 | self._mDistributionAnalyzer = EUCTWDistributionAnalysis()
38 | self.reset()
39 |
40 | def get_charset_name(self):
41 | return "EUC-TW"
42 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/euckrprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import EUCKRDistributionAnalysis
31 | from .mbcssm import EUCKRSMModel
32 |
33 |
34 | class EUCKRProber(MultiByteCharSetProber):
35 | def __init__(self):
36 | MultiByteCharSetProber.__init__(self)
37 | self._mCodingSM = CodingStateMachine(EUCKRSMModel)
38 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis()
39 | self.reset()
40 |
41 | def get_charset_name(self):
42 | return "EUC-KR"
43 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/gb2312prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import GB2312DistributionAnalysis
31 | from .mbcssm import GB2312SMModel
32 |
33 | class GB2312Prober(MultiByteCharSetProber):
34 | def __init__(self):
35 | MultiByteCharSetProber.__init__(self)
36 | self._mCodingSM = CodingStateMachine(GB2312SMModel)
37 | self._mDistributionAnalyzer = GB2312DistributionAnalysis()
38 | self.reset()
39 |
40 | def get_charset_name(self):
41 | return "GB2312"
42 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/big5prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Communicator client code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import Big5DistributionAnalysis
31 | from .mbcssm import Big5SMModel
32 |
33 |
34 | class Big5Prober(MultiByteCharSetProber):
35 | def __init__(self):
36 | MultiByteCharSetProber.__init__(self)
37 | self._mCodingSM = CodingStateMachine(Big5SMModel)
38 | self._mDistributionAnalyzer = Big5DistributionAnalysis()
39 | self.reset()
40 |
41 | def get_charset_name(self):
42 | return "Big5"
43 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/cp949prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import EUCKRDistributionAnalysis
31 | from .mbcssm import CP949SMModel
32 |
33 |
34 | class CP949Prober(MultiByteCharSetProber):
35 | def __init__(self):
36 | MultiByteCharSetProber.__init__(self)
37 | self._mCodingSM = CodingStateMachine(CP949SMModel)
38 | # NOTE: CP949 is a superset of EUC-KR, so the distribution should be
39 | # not different.
40 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis()
41 | self.reset()
42 |
43 | def get_charset_name(self):
44 | return "CP949"
45 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr/ip/rfc1924.py:
--------------------------------------------------------------------------------
1 | #-----------------------------------------------------------------------------
2 | # Copyright (c) 2008-2015, David P. D. Moss. All rights reserved.
3 | #
4 | # Released under the BSD license. See the LICENSE file for details.
5 | #-----------------------------------------------------------------------------
6 | """A basic implementation of RFC 1924 ;-)"""
7 |
8 | from netaddr.core import AddrFormatError
9 | from netaddr.ip import IPAddress
10 |
11 | from netaddr.compat import _zip
12 |
13 |
14 | def chr_range(low, high):
15 | """Returns all characters between low and high chars."""
16 | return [chr(i) for i in range(ord(low), ord(high) + 1)]
17 |
18 | #: Base 85 integer index to character lookup table.
19 | BASE_85 = (
20 | chr_range('0', '9') + chr_range('A', 'Z') +
21 | chr_range('a', 'z') +
22 | ['!', '#', '$', '%', '&', '(', ')', '*', '+', '-', ';', '<', '=', '>',
23 | '?', '@', '^', '_', '`', '{', '|', '}', '~']
24 | )
25 |
26 | #: Base 85 digit to integer lookup table.
27 | BASE_85_DICT = dict(_zip(BASE_85, range(0, 86)))
28 |
29 |
30 | def ipv6_to_base85(addr):
31 | """Convert a regular IPv6 address to base 85."""
32 | ip = IPAddress(addr)
33 | int_val = int(ip)
34 |
35 | remainder = []
36 | while int_val > 0:
37 | remainder.append(int_val % 85)
38 | int_val //= 85
39 |
40 | encoded = ''.join([BASE_85[w] for w in reversed(remainder)])
41 | leading_zeroes = (20 - len(encoded)) * "0"
42 | return leading_zeroes + encoded
43 |
44 |
45 | def base85_to_ipv6(addr):
46 | """
47 | Convert a base 85 IPv6 address to its hexadecimal format.
48 | """
49 | tokens = list(addr)
50 |
51 | if len(tokens) != 20:
52 | raise AddrFormatError('Invalid base 85 IPv6 address: %r' % addr)
53 |
54 | result = 0
55 | for i, num in enumerate(reversed(tokens)):
56 | num = BASE_85_DICT[num]
57 | result += (num * 85 ** i)
58 |
59 | ip = IPAddress(result, 6)
60 |
61 | return str(ip)
62 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/charsetprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | #
13 | # This library is free software; you can redistribute it and/or
14 | # modify it under the terms of the GNU Lesser General Public
15 | # License as published by the Free Software Foundation; either
16 | # version 2.1 of the License, or (at your option) any later version.
17 | #
18 | # This library is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 | # Lesser General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU Lesser General Public
24 | # License along with this library; if not, write to the Free Software
25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 | # 02110-1301 USA
27 | ######################### END LICENSE BLOCK #########################
28 |
29 | from . import constants
30 | import re
31 |
32 |
33 | class CharSetProber:
34 | def __init__(self):
35 | pass
36 |
37 | def reset(self):
38 | self._mState = constants.eDetecting
39 |
40 | def get_charset_name(self):
41 | return None
42 |
43 | def feed(self, aBuf):
44 | pass
45 |
46 | def get_state(self):
47 | return self._mState
48 |
49 | def get_confidence(self):
50 | return 0.0
51 |
52 | def filter_high_bit_only(self, aBuf):
53 | aBuf = re.sub(b'([\x00-\x7F])+', b' ', aBuf)
54 | return aBuf
55 |
56 | def filter_without_english_letters(self, aBuf):
57 | aBuf = re.sub(b'([A-Za-z])+', b' ', aBuf)
58 | return aBuf
59 |
60 | def filter_with_english_letters(self, aBuf):
61 | # TODO
62 | return aBuf
63 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/mbcsgroupprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | # Proofpoint, Inc.
13 | #
14 | # This library is free software; you can redistribute it and/or
15 | # modify it under the terms of the GNU Lesser General Public
16 | # License as published by the Free Software Foundation; either
17 | # version 2.1 of the License, or (at your option) any later version.
18 | #
19 | # This library is distributed in the hope that it will be useful,
20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 | # Lesser General Public License for more details.
23 | #
24 | # You should have received a copy of the GNU Lesser General Public
25 | # License along with this library; if not, write to the Free Software
26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 | # 02110-1301 USA
28 | ######################### END LICENSE BLOCK #########################
29 |
30 | from .charsetgroupprober import CharSetGroupProber
31 | from .utf8prober import UTF8Prober
32 | from .sjisprober import SJISProber
33 | from .eucjpprober import EUCJPProber
34 | from .gb2312prober import GB2312Prober
35 | from .euckrprober import EUCKRProber
36 | from .cp949prober import CP949Prober
37 | from .big5prober import Big5Prober
38 | from .euctwprober import EUCTWProber
39 |
40 |
41 | class MBCSGroupProber(CharSetGroupProber):
42 | def __init__(self):
43 | CharSetGroupProber.__init__(self)
44 | self._mProbers = [
45 | UTF8Prober(),
46 | SJISProber(),
47 | EUCJPProber(),
48 | GB2312Prober(),
49 | EUCKRProber(),
50 | CP949Prober(),
51 | Big5Prober(),
52 | EUCTWProber()
53 | ]
54 | self.reset()
55 |
--------------------------------------------------------------------------------
/110-SelfServicePortal/Customer/customeriamandrole.yaml:
--------------------------------------------------------------------------------
1 | Resources:
2 | iamuser:
3 | Type: "AWS::IAM::User"
4 | Properties:
5 | UserName: whicustomer
6 | ManagedPolicyArns:
7 | - "arn:aws:iam::aws:policy/ReadOnlyAccess"
8 | LoginProfile:
9 | Password: "P@55w0rd"
10 | PasswordResetRequired: false
11 | iamkeys:
12 | DependsOn: iamuser
13 | Type: "AWS::IAM::AccessKey"
14 | Properties:
15 | UserName: whicustomer
16 | iamrole:
17 | Type: "AWS::IAM::Role"
18 | Properties:
19 | AssumeRolePolicyDocument:
20 | Version: "2012-10-17"
21 | Statement:
22 | -
23 | Effect: "Allow"
24 | Action:
25 | - "sts:AssumeRoleWithWebIdentity"
26 | Condition:
27 | "ForAnyValue:StringLike":
28 | "cognito-identity.amazonaws.com:amr": "authenticated"
29 | Principal:
30 | Federated:
31 | - "cognito-identity.amazonaws.com"
32 | Path: "/"
33 | "Policies":
34 | -
35 | PolicyName: main
36 | PolicyDocument:
37 | Version: "2012-10-17"
38 | Statement:
39 | -
40 | Effect: "Allow"
41 | Action:
42 | - "cloudformation:CreateStack"
43 | - "cloudformation:UpdateStack"
44 | - "cloudformation:DeleteStack"
45 | - "cloudformation:CreateUploadBucket"
46 | - "cloudformation:DescribeStacks"
47 | - "cloudformation:DescribeStackEvents"
48 | - "cloudformation:GetTemplateSummary"
49 | - "cloudformation:ListStacks"
50 | - "cloudformation:ListStackResources"
51 | - "s3:CreateBucket"
52 | - "s3:GetObject"
53 | - "s3:PutObject"
54 | - "mobileanalytics:PutEvent"
55 | - "cognito-sync:*"
56 | - "cognito-identity:*"
57 | Resource: "*"
58 | Outputs:
59 | customerakid:
60 | Description: Customer Access Key ID
61 | Value: !Ref iamkeys
62 | customersecretkey:
63 | Description: Customer Secret Access Key
64 | Value: !GetAtt iamkeys.SecretAccessKey
65 | customerrole:
66 | Description: Customer Role arn
67 | Value: !GetAtt iamrole.Arn
68 |
--------------------------------------------------------------------------------
/102-TemplatePortability/wp-infrastructure-102-Linux1-distro-.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | AWSTemplateFormatVersion: '2010-09-09'
3 | Description: 'A template with a Mapping to allow it to be run in a number of regions. Must use Linux (1) distro. Feel free to update the AMIs if there is a newer Linux (1) version'
4 | Parameters:
5 | EnvironmentSize:
6 | Type: String
7 | Default: SMALL
8 | AllowedValues:
9 | - SMALL
10 | - MEDIUM
11 | - LARGE
12 | Description: Select Environment Size (S,M,L)
13 | Mappings:
14 | RegionMap:
15 | us-east-1:
16 | AMALINUX: ami-0080e4c5bc078760e
17 | us-east-2:
18 | AMALINUX: ami-0cd3dfa4e37921605
19 | us-west-1:
20 | AMALINUX: ami-0ec6517f6edbf8044
21 | us-west-2:
22 | AMALINUX: ami-01e24be29428c15b2
23 | sa-east-1:
24 | AMALINUX: ami-05145e0b28ad8e0b2
25 | ca-central-1:
26 | AMALINUX: ami-07423fb63ea0a0930
27 | eu-west-1:
28 | AMALINUX: ami-08935252a36e25f85
29 | eu-west-2:
30 | AMALINUX: ami-01419b804382064e4
31 | eu-west-3:
32 | AMALINUX: ami-0dd7e7ed60da8fb83
33 | eu-central-1:
34 | AMALINUX: ami-0cfbf4f6db41068ac
35 | ap-southeast-1:
36 | AMALINUX: ami-05b3bcf7f311194b3
37 | ap-southeast-2:
38 | AMALINUX: ami-02fd0b06f06d93dfc
39 | ap-northeast-1:
40 | AMALINUX: ami-00a5245b4816c38e6
41 | ap-northeast-2:
42 | AMALINUX: ami-00dc207f8ba6dc919
43 | ap-south-1:
44 | AMALINUX: ami-0ad42f4f66f6c1cc9
45 | cn-north-1:
46 | AMALINUX: ami-8e6aa0e3
47 |
48 | InstanceSize:
49 | SMALL:
50 | "EC2" : "t2.micro"
51 | "DB" : "db.t2.micro"
52 | MEDIUM:
53 | "EC2" : "t2.small"
54 | "DB" : "db.t2.small"
55 | LARGE:
56 | "EC2" : "t2.medium"
57 | "DB" : "db.t2.medium"
58 |
59 | Resources:
60 | DB:
61 | Type: "AWS::RDS::DBInstance"
62 | Properties:
63 | AllocatedStorage: 5
64 | StorageType: gp2
65 | DBInstanceClass: !FindInMap [InstanceSize, !Ref EnvironmentSize, DB] # Dynamic mapping + Pseudo Parameter
66 | DBName: wordpress
67 | Engine: MySQL
68 | MasterUsername: wordpress
69 | MasterUserPassword: w0rdpr355
70 | EC2:
71 | Type: "AWS::EC2::Instance"
72 | Properties:
73 | ImageId: !FindInMap [RegionMap, !Ref "AWS::Region", AMALINUX] # Dynamic mapping + Pseudo Parameter
74 | InstanceType: !FindInMap [InstanceSize, !Ref EnvironmentSize, EC2]
75 | S3:
76 | Type: "AWS::S3::Bucket"
77 |
78 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/util/request.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | from base64 import b64encode
3 |
4 | from ..packages.six import b
5 |
6 | ACCEPT_ENCODING = 'gzip,deflate'
7 |
8 |
9 | def make_headers(keep_alive=None, accept_encoding=None, user_agent=None,
10 | basic_auth=None, proxy_basic_auth=None, disable_cache=None):
11 | """
12 | Shortcuts for generating request headers.
13 |
14 | :param keep_alive:
15 | If ``True``, adds 'connection: keep-alive' header.
16 |
17 | :param accept_encoding:
18 | Can be a boolean, list, or string.
19 | ``True`` translates to 'gzip,deflate'.
20 | List will get joined by comma.
21 | String will be used as provided.
22 |
23 | :param user_agent:
24 | String representing the user-agent you want, such as
25 | "python-urllib3/0.6"
26 |
27 | :param basic_auth:
28 | Colon-separated username:password string for 'authorization: basic ...'
29 | auth header.
30 |
31 | :param proxy_basic_auth:
32 | Colon-separated username:password string for 'proxy-authorization: basic ...'
33 | auth header.
34 |
35 | :param disable_cache:
36 | If ``True``, adds 'cache-control: no-cache' header.
37 |
38 | Example::
39 |
40 | >>> make_headers(keep_alive=True, user_agent="Batman/1.0")
41 | {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}
42 | >>> make_headers(accept_encoding=True)
43 | {'accept-encoding': 'gzip,deflate'}
44 | """
45 | headers = {}
46 | if accept_encoding:
47 | if isinstance(accept_encoding, str):
48 | pass
49 | elif isinstance(accept_encoding, list):
50 | accept_encoding = ','.join(accept_encoding)
51 | else:
52 | accept_encoding = ACCEPT_ENCODING
53 | headers['accept-encoding'] = accept_encoding
54 |
55 | if user_agent:
56 | headers['user-agent'] = user_agent
57 |
58 | if keep_alive:
59 | headers['connection'] = 'keep-alive'
60 |
61 | if basic_auth:
62 | headers['authorization'] = 'Basic ' + \
63 | b64encode(b(basic_auth)).decode('utf-8')
64 |
65 | if proxy_basic_auth:
66 | headers['proxy-authorization'] = 'Basic ' + \
67 | b64encode(b(proxy_basic_auth)).decode('utf-8')
68 |
69 | if disable_cache:
70 | headers['cache-control'] = 'no-cache'
71 |
72 | return headers
73 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/util/response.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | from ..packages.six.moves import http_client as httplib
3 |
4 | from ..exceptions import HeaderParsingError
5 |
6 |
7 | def is_fp_closed(obj):
8 | """
9 | Checks whether a given file-like object is closed.
10 |
11 | :param obj:
12 | The file-like object to check.
13 | """
14 |
15 | try:
16 | # Check via the official file-like-object way.
17 | return obj.closed
18 | except AttributeError:
19 | pass
20 |
21 | try:
22 | # Check if the object is a container for another file-like object that
23 | # gets released on exhaustion (e.g. HTTPResponse).
24 | return obj.fp is None
25 | except AttributeError:
26 | pass
27 |
28 | raise ValueError("Unable to determine whether fp is closed.")
29 |
30 |
31 | def assert_header_parsing(headers):
32 | """
33 | Asserts whether all headers have been successfully parsed.
34 | Extracts encountered errors from the result of parsing headers.
35 |
36 | Only works on Python 3.
37 |
38 | :param headers: Headers to verify.
39 | :type headers: `httplib.HTTPMessage`.
40 |
41 | :raises urllib3.exceptions.HeaderParsingError:
42 | If parsing errors are found.
43 | """
44 |
45 | # This will fail silently if we pass in the wrong kind of parameter.
46 | # To make debugging easier add an explicit check.
47 | if not isinstance(headers, httplib.HTTPMessage):
48 | raise TypeError('expected httplib.Message, got {0}.'.format(
49 | type(headers)))
50 |
51 | defects = getattr(headers, 'defects', None)
52 | get_payload = getattr(headers, 'get_payload', None)
53 |
54 | unparsed_data = None
55 | if get_payload: # Platform-specific: Python 3.
56 | unparsed_data = get_payload()
57 |
58 | if defects or unparsed_data:
59 | raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
60 |
61 |
62 | def is_response_to_head(response):
63 | """
64 | Checks whether the request of a response has been a HEAD-request.
65 | Handles the quirks of AppEngine.
66 |
67 | :param conn:
68 | :type conn: :class:`httplib.HTTPResponse`
69 | """
70 | # FIXME: Can we do this somehow without accessing private httplib _method?
71 | method = response._method
72 | if isinstance(method, int): # Platform-specific: Appengine
73 | return method == 3
74 | return method.upper() == 'HEAD'
75 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # __
4 | # /__) _ _ _ _ _/ _
5 | # / ( (- (/ (/ (- _) / _)
6 | # /
7 |
8 | """
9 | Requests HTTP library
10 | ~~~~~~~~~~~~~~~~~~~~~
11 |
12 | Requests is an HTTP library, written in Python, for human beings. Basic GET
13 | usage:
14 |
15 | >>> import requests
16 | >>> r = requests.get('https://www.python.org')
17 | >>> r.status_code
18 | 200
19 | >>> 'Python is a programming language' in r.content
20 | True
21 |
22 | ... or POST:
23 |
24 | >>> payload = dict(key1='value1', key2='value2')
25 | >>> r = requests.post('http://httpbin.org/post', data=payload)
26 | >>> print(r.text)
27 | {
28 | ...
29 | "form": {
30 | "key2": "value2",
31 | "key1": "value1"
32 | },
33 | ...
34 | }
35 |
36 | The other HTTP methods are supported - see `requests.api`. Full documentation
37 | is at .
38 |
39 | :copyright: (c) 2016 by Kenneth Reitz.
40 | :license: Apache 2.0, see LICENSE for more details.
41 | """
42 |
43 | __title__ = 'requests'
44 | __version__ = '2.11.1'
45 | __build__ = 0x021101
46 | __author__ = 'Kenneth Reitz'
47 | __license__ = 'Apache 2.0'
48 | __copyright__ = 'Copyright 2016 Kenneth Reitz'
49 |
50 | # Attempt to enable urllib3's SNI support, if possible
51 | try:
52 | from .packages.urllib3.contrib import pyopenssl
53 | pyopenssl.inject_into_urllib3()
54 | except ImportError:
55 | pass
56 |
57 | import warnings
58 |
59 | # urllib3's DependencyWarnings should be silenced.
60 | from .packages.urllib3.exceptions import DependencyWarning
61 | warnings.simplefilter('ignore', DependencyWarning)
62 |
63 | from . import utils
64 | from .models import Request, Response, PreparedRequest
65 | from .api import request, get, head, post, patch, put, delete, options
66 | from .sessions import session, Session
67 | from .status_codes import codes
68 | from .exceptions import (
69 | RequestException, Timeout, URLRequired,
70 | TooManyRedirects, HTTPError, ConnectionError,
71 | FileModeWarning, ConnectTimeout, ReadTimeout
72 | )
73 |
74 | # Set default logging handler to avoid "No handler found" warnings.
75 | import logging
76 | try: # Python 2.7+
77 | from logging import NullHandler
78 | except ImportError:
79 | class NullHandler(logging.Handler):
80 | def emit(self, record):
81 | pass
82 |
83 | logging.getLogger(__name__).addHandler(NullHandler())
84 |
85 | # FileModeWarnings go off per the default.
86 | warnings.simplefilter('default', FileModeWarning, append=True)
87 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/codingstatemachine.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .constants import eStart
29 | from .compat import wrap_ord
30 |
31 |
32 | class CodingStateMachine:
33 | def __init__(self, sm):
34 | self._mModel = sm
35 | self._mCurrentBytePos = 0
36 | self._mCurrentCharLen = 0
37 | self.reset()
38 |
39 | def reset(self):
40 | self._mCurrentState = eStart
41 |
42 | def next_state(self, c):
43 | # for each byte we get its class
44 | # if it is first byte, we also get byte length
45 | # PY3K: aBuf is a byte stream, so c is an int, not a byte
46 | byteCls = self._mModel['classTable'][wrap_ord(c)]
47 | if self._mCurrentState == eStart:
48 | self._mCurrentBytePos = 0
49 | self._mCurrentCharLen = self._mModel['charLenTable'][byteCls]
50 | # from byte's class and stateTable, we get its next state
51 | curr_state = (self._mCurrentState * self._mModel['classFactor']
52 | + byteCls)
53 | self._mCurrentState = self._mModel['stateTable'][curr_state]
54 | self._mCurrentBytePos += 1
55 | return self._mCurrentState
56 |
57 | def get_current_charlen(self):
58 | return self._mCurrentCharLen
59 |
60 | def get_coding_state_machine(self):
61 | return self._mModel['name']
62 |
--------------------------------------------------------------------------------
/102-TemplatePortability/wp-infrastructure-102-Linux1-distro-.json:
--------------------------------------------------------------------------------
1 | {
2 | "AWSTemplateFormatVersion": "2010-09-09",
3 | "Description": "A template with a Mapping to allow it to be run in a number of regions. Must use Linux (1) distro. Feel free to update the AMIs if there is a newer Linux (1) version",
4 |
5 | "Parameters": {
6 | "EnvironmentSize": {
7 | "Type": "String",
8 | "Default": "SMALL",
9 | "AllowedValues": [ "SMALL", "MEDIUM", "LARGE" ],
10 | "Description": "Select Environment Size (S,M,L)"
11 | }
12 | },
13 | "Mappings": {
14 | "RegionMap": {
15 | "us-east-1" : { "AMALINUX": "ami-0080e4c5bc078760e" },
16 | "us-east-2" : { "AMALINUX": "ami-0cd3dfa4e37921605" },
17 |
18 | "us-west-1" : { "AMALINUX": "ami-0ec6517f6edbf8044" },
19 | "us-west-2" : { "AMALINUX": "ami-01e24be29428c15b2" },
20 |
21 | "sa-east-1" : { "AMALINUX": "ami-05145e0b28ad8e0b2" },
22 | "ca-central-1" : { "AMALINUX": "ami-07423fb63ea0a0930" },
23 |
24 | "eu-west-1" : { "AMALINUX": "ami-08935252a36e25f85" },
25 | "eu-west-2" : { "AMALINUX": "ami-01419b804382064e4" },
26 | "eu-west-3" : { "AMALINUX": "ami-0dd7e7ed60da8fb83" },
27 | "eu-central-1" : { "AMALINUX": "ami-0cfbf4f6db41068ac" },
28 |
29 | "ap-southeast-1": { "AMALINUX": "ami-05b3bcf7f311194b3" },
30 | "ap-southeast-2": { "AMALINUX": "ami-02fd0b06f06d93dfc" },
31 | "ap-northeast-1": { "AMALINUX": "ami-00a5245b4816c38e6" },
32 | "ap-northeast-2": { "AMALINUX": "ami-00dc207f8ba6dc919" },
33 | "ap-south-1" : { "AMALINUX": "ami-0ad42f4f66f6c1cc9" },
34 |
35 | "cn-north-1" : { "AMALINUX": "ami-8e6aa0e3" }
36 | },
37 |
38 |
39 | "InstanceSize": {
40 | "SMALL" : { "EC2": "t2.micro", "DB": "db.t2.micro" },
41 | "MEDIUM": { "EC2": "t2.small", "DB": "db.t2.small" },
42 | "LARGE" : { "EC2": "t2.medium", "DB": "db.t2.medium" }
43 | }
44 | },
45 |
46 | "Resources": {
47 | "DB": {
48 | "Type": "AWS::RDS::DBInstance",
49 | "Properties": {
50 | "AllocatedStorage": 5,
51 | "StorageType" : "gp2",
52 | "DBInstanceClass": {"Fn::FindInMap" : ["InstanceSize", {"Ref" : "EnvironmentSize"}, "DB"]},
53 | "DBName": "wordpress",
54 | "Engine": "MySQL",
55 | "MasterUsername": "wordpress",
56 | "MasterUserPassword": "w0rdpr355"
57 | }
58 | },
59 | "EC2": {
60 | "Type": "AWS::EC2::Instance",
61 | "Properties": {
62 | "ImageId": {"Fn::FindInMap" : ["RegionMap", {"Ref" : "AWS::Region"}, "AMALINUX"]},
63 | "InstanceType": {"Fn::FindInMap" : ["InstanceSize", {"Ref" : "EnvironmentSize"}, "EC2"]}
64 | }
65 | },
66 | "S3": {
67 | "Type": "AWS::S3::Bucket"
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/filepost.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | import codecs
3 |
4 | from uuid import uuid4
5 | from io import BytesIO
6 |
7 | from .packages import six
8 | from .packages.six import b
9 | from .fields import RequestField
10 |
11 | writer = codecs.lookup('utf-8')[3]
12 |
13 |
14 | def choose_boundary():
15 | """
16 | Our embarassingly-simple replacement for mimetools.choose_boundary.
17 | """
18 | return uuid4().hex
19 |
20 |
21 | def iter_field_objects(fields):
22 | """
23 | Iterate over fields.
24 |
25 | Supports list of (k, v) tuples and dicts, and lists of
26 | :class:`~urllib3.fields.RequestField`.
27 |
28 | """
29 | if isinstance(fields, dict):
30 | i = six.iteritems(fields)
31 | else:
32 | i = iter(fields)
33 |
34 | for field in i:
35 | if isinstance(field, RequestField):
36 | yield field
37 | else:
38 | yield RequestField.from_tuples(*field)
39 |
40 |
41 | def iter_fields(fields):
42 | """
43 | .. deprecated:: 1.6
44 |
45 | Iterate over fields.
46 |
47 | The addition of :class:`~urllib3.fields.RequestField` makes this function
48 | obsolete. Instead, use :func:`iter_field_objects`, which returns
49 | :class:`~urllib3.fields.RequestField` objects.
50 |
51 | Supports list of (k, v) tuples and dicts.
52 | """
53 | if isinstance(fields, dict):
54 | return ((k, v) for k, v in six.iteritems(fields))
55 |
56 | return ((k, v) for k, v in fields)
57 |
58 |
59 | def encode_multipart_formdata(fields, boundary=None):
60 | """
61 | Encode a dictionary of ``fields`` using the multipart/form-data MIME format.
62 |
63 | :param fields:
64 | Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).
65 |
66 | :param boundary:
67 | If not specified, then a random boundary will be generated using
68 | :func:`mimetools.choose_boundary`.
69 | """
70 | body = BytesIO()
71 | if boundary is None:
72 | boundary = choose_boundary()
73 |
74 | for field in iter_field_objects(fields):
75 | body.write(b('--%s\r\n' % (boundary)))
76 |
77 | writer(body).write(field.render_headers())
78 | data = field.data
79 |
80 | if isinstance(data, int):
81 | data = str(data) # Backwards compatibility
82 |
83 | if isinstance(data, six.text_type):
84 | writer(body).write(data)
85 | else:
86 | body.write(data)
87 |
88 | body.write(b'\r\n')
89 |
90 | body.write(b('--%s--\r\n' % (boundary)))
91 |
92 | content_type = str('multipart/form-data; boundary=%s' % boundary)
93 |
94 | return body.getvalue(), content_type
95 |
--------------------------------------------------------------------------------
/207-DeploymentPortal/autosubnet.yaml:
--------------------------------------------------------------------------------
1 | Resources:
2 | AutoSubnetTable:
3 | Type: AWS::DynamoDB::Table
4 | Properties:
5 | AttributeDefinitions:
6 | -
7 | AttributeName: "Cidr"
8 | AttributeType: "S"
9 | -
10 | AttributeName: "StackId"
11 | AttributeType: "S"
12 | KeySchema:
13 | -
14 | AttributeName: "Cidr"
15 | KeyType: "HASH"
16 | ProvisionedThroughput:
17 | ReadCapacityUnits: "5"
18 | WriteCapacityUnits: "5"
19 | GlobalSecondaryIndexes:
20 | -
21 | IndexName: "rangesforstack"
22 | KeySchema:
23 | -
24 | AttributeName: "StackId"
25 | KeyType: "HASH"
26 | Projection:
27 | ProjectionType: ALL
28 | ProvisionedThroughput:
29 | ReadCapacityUnits: "5"
30 | WriteCapacityUnits: "5"
31 | IAMRole:
32 | Type: AWS::IAM::Role
33 | Properties:
34 | AssumeRolePolicyDocument:
35 | Version: 2012-10-17
36 | Statement:
37 | -
38 | Effect: Allow
39 | Principal:
40 | Service:
41 | - lambda.amazonaws.com
42 | Action:
43 | - sts:AssumeRole
44 | Path: "/"
45 | IAMPolicy:
46 | DependsOn: IAMRole
47 | Type: AWS::IAM::Policy
48 | Properties:
49 | PolicyName: autosubnetrole
50 | Roles:
51 | - !Ref IAMRole
52 | PolicyDocument:
53 | Version: 2012-10-17
54 | Statement:
55 | -
56 | Effect: Allow
57 | Action:
58 | - "logs:*"
59 | Resource:
60 | - "arn:aws:logs:*:*:*"
61 | -
62 | Effect: Allow
63 | Action:
64 | - "dynamodb:*"
65 | Resource:
66 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${AutoSubnetTable}
67 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${AutoSubnetTable}/index/*
68 | subnetpicker:
69 | Type: AWS::Lambda::Function
70 | DependsOn:
71 | - IAMRole
72 | - IAMPolicy
73 | Properties:
74 | Role: !GetAtt IAMRole.Arn
75 | Code:
76 | S3Bucket: !ImportValue sharedinf-lambdabucketname
77 | S3Key: autosubnet.zip
78 | Handler: autosubnet.handler
79 | Runtime: "python2.7"
80 | Timeout: "300"
81 | MemorySize: "128"
82 | Outputs:
83 | autosubnetlambdaarn:
84 | Description: ARN of AutoSubnet Lambda
85 | Value: !GetAtt subnetpicker.Arn
86 | Export:
87 | Name: sharedinf-autosubnetarn
88 | autosubnettablename:
89 | Description: Table Name of AutoSubnet DDB Table
90 | Value: !Ref AutoSubnetTable
91 | Export:
92 | Name: sharedinf-autosubnetddbtablename
93 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet.yaml:
--------------------------------------------------------------------------------
1 | Resources:
2 | AutoSubnetTable:
3 | Type: AWS::DynamoDB::Table
4 | Properties:
5 | AttributeDefinitions:
6 | -
7 | AttributeName: "Cidr"
8 | AttributeType: "S"
9 | -
10 | AttributeName: "StackId"
11 | AttributeType: "S"
12 | KeySchema:
13 | -
14 | AttributeName: "Cidr"
15 | KeyType: "HASH"
16 | ProvisionedThroughput:
17 | ReadCapacityUnits: "5"
18 | WriteCapacityUnits: "5"
19 | GlobalSecondaryIndexes:
20 | -
21 | IndexName: "rangesforstack"
22 | KeySchema:
23 | -
24 | AttributeName: "StackId"
25 | KeyType: "HASH"
26 | Projection:
27 | ProjectionType: ALL
28 | ProvisionedThroughput:
29 | ReadCapacityUnits: "5"
30 | WriteCapacityUnits: "5"
31 | IAMRole:
32 | Type: AWS::IAM::Role
33 | Properties:
34 | AssumeRolePolicyDocument:
35 | Version: 2012-10-17
36 | Statement:
37 | -
38 | Effect: Allow
39 | Principal:
40 | Service:
41 | - lambda.amazonaws.com
42 | Action:
43 | - sts:AssumeRole
44 | Path: "/"
45 | IAMPolicy:
46 | DependsOn: IAMRole
47 | Type: AWS::IAM::Policy
48 | Properties:
49 | PolicyName: autosubnetrole
50 | Roles:
51 | - !Ref IAMRole
52 | PolicyDocument:
53 | Version: 2012-10-17
54 | Statement:
55 | -
56 | Effect: Allow
57 | Action:
58 | - "logs:*"
59 | Resource:
60 | - "arn:aws:logs:*:*:*"
61 | -
62 | Effect: Allow
63 | Action:
64 | - "dynamodb:*"
65 | Resource:
66 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${AutoSubnetTable}
67 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${AutoSubnetTable}/index/*
68 | subnetpicker:
69 | Type: AWS::Lambda::Function
70 | DependsOn:
71 | - IAMRole
72 | - IAMPolicy
73 | Properties:
74 | Role: !GetAtt IAMRole.Arn
75 | Code:
76 | S3Bucket: !ImportValue sharedinf-lambdabucketname
77 | S3Key: autosubnet.zip
78 | Handler: autosubnet.handler
79 | Runtime: "python2.7"
80 | Timeout: "300"
81 | MemorySize: "128"
82 | Outputs:
83 | autosubnetlambdaarn:
84 | Description: ARN of AutoSubnet Lambda
85 | Value: !GetAtt subnetpicker.Arn
86 | Export:
87 | Name: sharedinf-autosubnetarn
88 | autosubnettablename:
89 | Description: Table Name of AutoSubnet DDB Table
90 | Value: !Ref AutoSubnetTable
91 | Export:
92 | Name: sharedinf-autosubnetddbtablename
93 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/chardetect.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """
3 | Script which takes one or more file paths and reports on their detected
4 | encodings
5 |
6 | Example::
7 |
8 | % chardetect somefile someotherfile
9 | somefile: windows-1252 with confidence 0.5
10 | someotherfile: ascii with confidence 1.0
11 |
12 | If no paths are provided, it takes its input from stdin.
13 |
14 | """
15 |
16 | from __future__ import absolute_import, print_function, unicode_literals
17 |
18 | import argparse
19 | import sys
20 | from io import open
21 |
22 | from chardet import __version__
23 | from chardet.universaldetector import UniversalDetector
24 |
25 |
26 | def description_of(lines, name='stdin'):
27 | """
28 | Return a string describing the probable encoding of a file or
29 | list of strings.
30 |
31 | :param lines: The lines to get the encoding of.
32 | :type lines: Iterable of bytes
33 | :param name: Name of file or collection of lines
34 | :type name: str
35 | """
36 | u = UniversalDetector()
37 | for line in lines:
38 | u.feed(line)
39 | u.close()
40 | result = u.result
41 | if result['encoding']:
42 | return '{0}: {1} with confidence {2}'.format(name, result['encoding'],
43 | result['confidence'])
44 | else:
45 | return '{0}: no result'.format(name)
46 |
47 |
48 | def main(argv=None):
49 | '''
50 | Handles command line arguments and gets things started.
51 |
52 | :param argv: List of arguments, as if specified on the command-line.
53 | If None, ``sys.argv[1:]`` is used instead.
54 | :type argv: list of str
55 | '''
56 | # Get command line arguments
57 | parser = argparse.ArgumentParser(
58 | description="Takes one or more file paths and reports their detected \
59 | encodings",
60 | formatter_class=argparse.ArgumentDefaultsHelpFormatter,
61 | conflict_handler='resolve')
62 | parser.add_argument('input',
63 | help='File whose encoding we would like to determine.',
64 | type=argparse.FileType('rb'), nargs='*',
65 | default=[sys.stdin])
66 | parser.add_argument('--version', action='version',
67 | version='%(prog)s {0}'.format(__version__))
68 | args = parser.parse_args(argv)
69 |
70 | for f in args.input:
71 | if f.isatty():
72 | print("You are running chardetect interactively. Press " +
73 | "CTRL-D twice at the start of a blank line to signal the " +
74 | "end of your input. If you want help, run chardetect " +
75 | "--help\n", file=sys.stderr)
76 | print(description_of(f, f.name))
77 |
78 |
79 | if __name__ == '__main__':
80 | main()
81 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/utf8prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from . import constants
29 | from .charsetprober import CharSetProber
30 | from .codingstatemachine import CodingStateMachine
31 | from .mbcssm import UTF8SMModel
32 |
33 | ONE_CHAR_PROB = 0.5
34 |
35 |
36 | class UTF8Prober(CharSetProber):
37 | def __init__(self):
38 | CharSetProber.__init__(self)
39 | self._mCodingSM = CodingStateMachine(UTF8SMModel)
40 | self.reset()
41 |
42 | def reset(self):
43 | CharSetProber.reset(self)
44 | self._mCodingSM.reset()
45 | self._mNumOfMBChar = 0
46 |
47 | def get_charset_name(self):
48 | return "utf-8"
49 |
50 | def feed(self, aBuf):
51 | for c in aBuf:
52 | codingState = self._mCodingSM.next_state(c)
53 | if codingState == constants.eError:
54 | self._mState = constants.eNotMe
55 | break
56 | elif codingState == constants.eItsMe:
57 | self._mState = constants.eFoundIt
58 | break
59 | elif codingState == constants.eStart:
60 | if self._mCodingSM.get_current_charlen() >= 2:
61 | self._mNumOfMBChar += 1
62 |
63 | if self.get_state() == constants.eDetecting:
64 | if self.get_confidence() > constants.SHORTCUT_THRESHOLD:
65 | self._mState = constants.eFoundIt
66 |
67 | return self.get_state()
68 |
69 | def get_confidence(self):
70 | unlike = 0.99
71 | if self._mNumOfMBChar < 6:
72 | for i in range(0, self._mNumOfMBChar):
73 | unlike = unlike * ONE_CHAR_PROB
74 | return 1.0 - unlike
75 | else:
76 | return unlike
77 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr-0.7.18.dist-info/metadata.json:
--------------------------------------------------------------------------------
1 | {"summary": "A network address manipulation library for Python", "version": "0.7.18", "metadata_version": "2.0", "name": "netaddr", "platform": "OS Independent", "download_url": "https://pypi.python.org/pypi/netaddr/", "keywords": ["Networking", "Systems", "Administration", "IANA", "IEEE", "CIDR", "IP", "IPv4", "IPv6", "CIDR", "EUI", "MAC", "MAC-48", "EUI-48", "EUI-64"], "license": "BSD License", "extensions": {"python.details": {"document_names": {"description": "DESCRIPTION.rst"}, "contacts": [{"name": "David P. D. Moss", "email": "drkjam@gmail.com", "role": "author"}], "project_urls": {"Home": "https://github.com/drkjam/netaddr/"}}}, "generator": "bdist_wheel (0.24.0)", "classifiers": ["Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Information Technology", "Intended Audience :: Science/Research", "Intended Audience :: System Administrators", "Intended Audience :: Telecommunications Industry", "License :: OSI Approved :: BSD License", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Communications", "Topic :: Documentation", "Topic :: Education", "Topic :: Education :: Testing", "Topic :: Home Automation", "Topic :: Internet", "Topic :: Internet :: Log Analysis", "Topic :: Internet :: Name Service (DNS)", "Topic :: Internet :: Proxy Servers", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Indexing/Search", "Topic :: Internet :: WWW/HTTP :: Site Management", "Topic :: Security", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Quality Assurance", "Topic :: Software Development :: Testing", "Topic :: Software Development :: Testing :: Traffic Generation", "Topic :: System :: Benchmark", "Topic :: System :: Clustering", "Topic :: System :: Distributed Computing", "Topic :: System :: Installation/Setup", "Topic :: System :: Logging", "Topic :: System :: Monitoring", "Topic :: System :: Networking", "Topic :: System :: Networking :: Firewalls", "Topic :: System :: Networking :: Monitoring", "Topic :: System :: Networking :: Time Synchronization", "Topic :: System :: Recovery Tools", "Topic :: System :: Shells", "Topic :: System :: Software Distribution", "Topic :: System :: Systems Administration", "Topic :: System :: System Shells", "Topic :: Text Processing", "Topic :: Text Processing :: Filters", "Topic :: Utilities"]}
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr/compat.py:
--------------------------------------------------------------------------------
1 | #-----------------------------------------------------------------------------
2 | # Copyright (c) 2008-2015, David P. D. Moss. All rights reserved.
3 | #
4 | # Released under the BSD license. See the LICENSE file for details.
5 | #-----------------------------------------------------------------------------
6 | """
7 | Compatibility wrappers providing uniform behaviour for Python code required to
8 | run under both Python 2.x and 3.x.
9 |
10 | All operations emulate 2.x behaviour where applicable.
11 | """
12 | import sys as _sys
13 |
14 | if _sys.version_info[0] == 3:
15 | # Python 3.x specific logic.
16 | _sys_maxint = _sys.maxsize
17 |
18 | _int_type = int
19 |
20 | _str_type = str
21 |
22 | _is_str = lambda x: isinstance(x, (str, type(''.encode())))
23 |
24 | _is_int = lambda x: isinstance(x, int)
25 |
26 | _callable = lambda x: hasattr(x, '__call__')
27 |
28 | _func_doc = lambda x: x.__doc__
29 |
30 | _dict_keys = lambda x: list(x.keys())
31 |
32 | _dict_items = lambda x: list(x.items())
33 |
34 | _iter_dict_keys = lambda x: x.keys()
35 |
36 | def _bytes_join(*args):
37 | return ''.encode().join(*args)
38 |
39 | def _zip(*args):
40 | return list(zip(*args))
41 |
42 | def _range(*args, **kwargs):
43 | return list(range(*args, **kwargs))
44 |
45 | _iter_range = range
46 |
47 | def _func_name(f, name=None):
48 | if name is not None:
49 | f.__name__ = name
50 | else:
51 | return f.__name__
52 |
53 | def _func_doc(f, docstring=None):
54 | if docstring is not None:
55 | f.__doc__ = docstring
56 | else:
57 | return f.__doc__
58 |
59 | def _iter_next(x):
60 | return next(x)
61 |
62 | elif _sys.version_info[0:2] > [2, 3]:
63 | # Python 2.4 or higher.
64 | _sys_maxint = _sys.maxint
65 |
66 | _int_type = (int, long)
67 |
68 | _str_type = basestring
69 |
70 | _is_str = lambda x: isinstance(x, basestring)
71 |
72 | _is_int = lambda x: isinstance(x, (int, long))
73 |
74 | _callable = lambda x: callable(x)
75 |
76 | _dict_keys = lambda x: x.keys()
77 |
78 | _dict_items = lambda x: x.items()
79 |
80 | _iter_dict_keys = lambda x: iter(x.keys())
81 |
82 | def _bytes_join(*args):
83 | return ''.join(*args)
84 |
85 | def _zip(*args):
86 | return zip(*args)
87 |
88 | def _range(*args, **kwargs):
89 | return range(*args, **kwargs)
90 |
91 | _iter_range = xrange
92 |
93 | def _func_name(f, name=None):
94 | if name is not None:
95 | f.func_name = name
96 | else:
97 | return f.func_name
98 |
99 | def _func_doc(f, docstring=None):
100 | if docstring is not None:
101 | f.func_doc = docstring
102 | else:
103 | return f.func_doc
104 |
105 | def _iter_next(x):
106 | return x.next()
107 | else:
108 | # Unsupported versions.
109 | raise RuntimeError(
110 | 'this module only supports Python 2.4.x or higher (including 3.x)!')
111 |
112 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | urllib3 - Thread-safe connection pooling and re-using.
3 | """
4 |
5 | from __future__ import absolute_import
6 | import warnings
7 |
8 | from .connectionpool import (
9 | HTTPConnectionPool,
10 | HTTPSConnectionPool,
11 | connection_from_url
12 | )
13 |
14 | from . import exceptions
15 | from .filepost import encode_multipart_formdata
16 | from .poolmanager import PoolManager, ProxyManager, proxy_from_url
17 | from .response import HTTPResponse
18 | from .util.request import make_headers
19 | from .util.url import get_host
20 | from .util.timeout import Timeout
21 | from .util.retry import Retry
22 |
23 |
24 | # Set default logging handler to avoid "No handler found" warnings.
25 | import logging
26 | try: # Python 2.7+
27 | from logging import NullHandler
28 | except ImportError:
29 | class NullHandler(logging.Handler):
30 | def emit(self, record):
31 | pass
32 |
33 | __author__ = 'Andrey Petrov (andrey.petrov@shazow.net)'
34 | __license__ = 'MIT'
35 | __version__ = '1.16'
36 |
37 | __all__ = (
38 | 'HTTPConnectionPool',
39 | 'HTTPSConnectionPool',
40 | 'PoolManager',
41 | 'ProxyManager',
42 | 'HTTPResponse',
43 | 'Retry',
44 | 'Timeout',
45 | 'add_stderr_logger',
46 | 'connection_from_url',
47 | 'disable_warnings',
48 | 'encode_multipart_formdata',
49 | 'get_host',
50 | 'make_headers',
51 | 'proxy_from_url',
52 | )
53 |
54 | logging.getLogger(__name__).addHandler(NullHandler())
55 |
56 |
57 | def add_stderr_logger(level=logging.DEBUG):
58 | """
59 | Helper for quickly adding a StreamHandler to the logger. Useful for
60 | debugging.
61 |
62 | Returns the handler after adding it.
63 | """
64 | # This method needs to be in this __init__.py to get the __name__ correct
65 | # even if urllib3 is vendored within another package.
66 | logger = logging.getLogger(__name__)
67 | handler = logging.StreamHandler()
68 | handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
69 | logger.addHandler(handler)
70 | logger.setLevel(level)
71 | logger.debug('Added a stderr logging handler to logger: %s', __name__)
72 | return handler
73 |
74 | # ... Clean up.
75 | del NullHandler
76 |
77 |
78 | # All warning filters *must* be appended unless you're really certain that they
79 | # shouldn't be: otherwise, it's very hard for users to use most Python
80 | # mechanisms to silence them.
81 | # SecurityWarning's always go off by default.
82 | warnings.simplefilter('always', exceptions.SecurityWarning, append=True)
83 | # SubjectAltNameWarning's should go off once per host
84 | warnings.simplefilter('default', exceptions.SubjectAltNameWarning, append=True)
85 | # InsecurePlatformWarning's don't vary between requests, so we keep it default.
86 | warnings.simplefilter('default', exceptions.InsecurePlatformWarning,
87 | append=True)
88 | # SNIMissingWarnings should go off only once.
89 | warnings.simplefilter('default', exceptions.SNIMissingWarning, append=True)
90 |
91 |
92 | def disable_warnings(category=exceptions.HTTPWarning):
93 | """
94 | Helper for quickly disabling all urllib3 warnings.
95 | """
96 | warnings.simplefilter('ignore', category)
97 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr-0.7.18.dist-info/RECORD:
--------------------------------------------------------------------------------
1 | netaddr/__init__.py,sha256=iCKdGtSodDL9yP_EthghUIEsqRCTWcU1eG0LkaGmw7A,2959
2 | netaddr/compat.py,sha256=EL1EtABfoIGMclSrnt8iQD3BwXVvtxBcfbXbBPj66pU,2619
3 | netaddr/core.py,sha256=rbRV-mGNEykU88pKLxOBdc47hyAeE5QyAPerR2F-4PY,6335
4 | netaddr/fbsocket.py,sha256=Rqa6LEH1OHddAq6sPbRriUVPwhqAZc3ahJv08PFBzGA,8255
5 | netaddr/eui/__init__.py,sha256=EPtoKvqwj5HvciB0HVbfDiM-Scm6NX0hc4msZ2hDeVA,24939
6 | netaddr/eui/iab.idx,sha256=VKfBDxCRbfFjdrbQOyJ44U8YRyUH5LU_fZUBkpo7NX8,92230
7 | netaddr/eui/iab.txt,sha256=B79j3_kqZAVpkRPVFMlX4JJeLuPefhLW6I6trShEfBY,727240
8 | netaddr/eui/ieee.py,sha256=6bORnm5Y8M4APEF3g9QeXbA5474Fmvf_os3JWb46iPA,9061
9 | netaddr/eui/oui.idx,sha256=AVLKWUlPSWzJbH6ZQfo757Rqic1QEn4vzjeDJo4gs4E,376362
10 | netaddr/eui/oui.txt,sha256=GdjLp64V4iUClQ9VZy-nliqa2pCxo3NJ_9ldASFeNoQ,3523057
11 | netaddr/ip/__init__.py,sha256=SHzJcdAV7pJhlg_hbzlP_OB53PwnhvAm9HCDDD2LCLA,66022
12 | netaddr/ip/glob.py,sha256=cf0aemyf28NOFCvwsgwcKNWzvAwXpn0b01kghyMyp70,10474
13 | netaddr/ip/iana.py,sha256=rgwY9Kesax5RGjM_0CAeEqyby3VBfaglcb74y-9ZB8I,13621
14 | netaddr/ip/ipv4-address-space.xml,sha256=tNdAT5UXqS3GYw5o3w8LJ52ZZNY9FsALxStSzDUoB8M,53439
15 | netaddr/ip/ipv6-address-space.xml,sha256=9Dr7llOoPs4IPcpozee5uu1OFFCFWQX8U7lGEyhnDmk,7560
16 | netaddr/ip/ipv6-unicast-address-assignments.xml,sha256=gTGvKXQ-KiRJSKPSX5PswOlDI9LRBajxeBJIZEQRWr8,14573
17 | netaddr/ip/multicast-addresses.xml,sha256=QcCDXmTX32tBY2MN-hZbrW-gLx35frEyfEW4lEd1csk,132214
18 | netaddr/ip/nmap.py,sha256=_mGuyvF1T13R_rAyEwRU4Q9_ODrEsOuBpZbUQcAPXbA,4066
19 | netaddr/ip/rfc1924.py,sha256=2DfYMq02rIi4IbGUKiWfVVhaAjMJHhCq2q4XGLS3ioQ,1750
20 | netaddr/ip/sets.py,sha256=-NIAWfsplMf8uAS2ZAyvpiNwmSSvFKRqppl7hKLWi8g,26561
21 | netaddr/strategy/__init__.py,sha256=RDcPS8dBR2tOlPKed08eA8bntASALwQ4jZ22r50cYes,7471
22 | netaddr/strategy/eui48.py,sha256=fvHf6K2VEFNGsVRYd4lnxy9u2ym-tQUJsk2E9DNT4-4,8633
23 | netaddr/strategy/eui64.py,sha256=-3jpc7mgum0f8TrCBfEfTHMO5iizgV1JBFhuWHZrncM,7710
24 | netaddr/strategy/ipv4.py,sha256=hmqPhEZZweSQU3bS8581RdcH_N9gfE3GgW6PDj2PheI,8086
25 | netaddr/strategy/ipv6.py,sha256=i7Fhea1jsp-DTFuGpcucHxgGYpUyClfqhMJHn2p3lTo,7629
26 | ../../bin/netaddr,sha256=nKoZ-oIp8869frIOEdN6yGg2VbStgOiYjpnYpTFL3xc,1161
27 | netaddr-0.7.18.dist-info/DESCRIPTION.rst,sha256=PTOuqnZD2kw1K6vUu0whiRGt8P0G5IzaiaBqFLg_OMo,977
28 | netaddr-0.7.18.dist-info/METADATA,sha256=Wp8Fm-DzqX_QTD1MNIO9lGWrLL2aMXLeAJypSdGllk8,4322
29 | netaddr-0.7.18.dist-info/metadata.json,sha256=ac2lwQhkUcQHdrr_P6fMQCpCtxQFEiPgcyIk2S7qYLU,3076
30 | netaddr-0.7.18.dist-info/RECORD,,
31 | netaddr-0.7.18.dist-info/top_level.txt,sha256=GlouRmUZSQCg0kloRWKY6qxTHAsQo_rE8QvlxYBHwOE,8
32 | netaddr-0.7.18.dist-info/WHEEL,sha256=AvR0WeTpDaxT645bl5FQxUK6NPsTls2ttpcGJg3j1Xg,110
33 | netaddr-0.7.18.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
34 | netaddr/strategy/eui64.pyc,,
35 | netaddr/__init__.pyc,,
36 | netaddr/ip/glob.pyc,,
37 | netaddr/strategy/ipv4.pyc,,
38 | netaddr/ip/__init__.pyc,,
39 | netaddr/strategy/eui48.pyc,,
40 | netaddr/compat.pyc,,
41 | netaddr/core.pyc,,
42 | netaddr/eui/__init__.pyc,,
43 | netaddr/fbsocket.pyc,,
44 | netaddr/ip/rfc1924.pyc,,
45 | netaddr/ip/sets.pyc,,
46 | netaddr/ip/iana.pyc,,
47 | netaddr/ip/nmap.pyc,,
48 | netaddr/strategy/__init__.pyc,,
49 | netaddr/eui/ieee.pyc,,
50 | netaddr/strategy/ipv6.pyc,,
51 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr/__init__.py:
--------------------------------------------------------------------------------
1 | #-----------------------------------------------------------------------------
2 | # Copyright (c) 2008-2015, David P. D. Moss. All rights reserved.
3 | #
4 | # Released under the BSD license. See the LICENSE file for details.
5 | #-----------------------------------------------------------------------------
6 | """A Python library for manipulating IP and EUI network addresses."""
7 |
8 | #: Version info (major, minor, maintenance, status)
9 | VERSION = (0, 7, 18)
10 | STATUS = ''
11 | __version__ = '%d.%d.%d' % VERSION[0:3] + STATUS
12 |
13 | import sys as _sys
14 |
15 | if _sys.version_info[0:2] < (2, 4):
16 | raise RuntimeError('Python 2.4.x or higher is required!')
17 |
18 | from netaddr.core import (AddrConversionError, AddrFormatError,
19 | NotRegisteredError, ZEROFILL, Z, INET_PTON, P, NOHOST, N)
20 |
21 | from netaddr.ip import (IPAddress, IPNetwork, IPRange, all_matching_cidrs,
22 | cidr_abbrev_to_verbose, cidr_exclude, cidr_merge, iprange_to_cidrs,
23 | iter_iprange, iter_unique_ips, largest_matching_cidr,
24 | smallest_matching_cidr, spanning_cidr)
25 |
26 | from netaddr.ip.sets import IPSet
27 |
28 | from netaddr.ip.glob import (IPGlob, cidr_to_glob, glob_to_cidrs,
29 | glob_to_iprange, glob_to_iptuple, iprange_to_globs, valid_glob)
30 |
31 | from netaddr.ip.nmap import valid_nmap_range, iter_nmap_range
32 |
33 | from netaddr.ip.rfc1924 import base85_to_ipv6, ipv6_to_base85
34 |
35 | from netaddr.eui import EUI, IAB, OUI
36 |
37 | from netaddr.strategy.ipv4 import valid_str as valid_ipv4
38 |
39 | from netaddr.strategy.ipv6 import (valid_str as valid_ipv6, ipv6_compact,
40 | ipv6_full, ipv6_verbose)
41 |
42 | from netaddr.strategy.eui48 import (mac_eui48, mac_unix, mac_unix_expanded,
43 | mac_cisco, mac_bare, mac_pgsql, valid_str as valid_mac)
44 |
45 | from netaddr.strategy.eui64 import (eui64_base, eui64_unix, eui64_unix_expanded,
46 | eui64_cisco, eui64_bare, valid_str as valid_eui64)
47 |
48 | __all__ = [
49 | # Constants.
50 | 'ZEROFILL', 'Z', 'INET_PTON', 'P', 'NOHOST', 'N',
51 |
52 | # Custom Exceptions.
53 | 'AddrConversionError', 'AddrFormatError', 'NotRegisteredError',
54 |
55 | # IP classes.
56 | 'IPAddress', 'IPNetwork', 'IPRange', 'IPSet',
57 |
58 | # IPv6 dialect classes.
59 | 'ipv6_compact', 'ipv6_full', 'ipv6_verbose',
60 |
61 | # IP functions and generators.
62 | 'all_matching_cidrs', 'cidr_abbrev_to_verbose', 'cidr_exclude',
63 | 'cidr_merge', 'iprange_to_cidrs', 'iter_iprange', 'iter_unique_ips',
64 | 'largest_matching_cidr', 'smallest_matching_cidr', 'spanning_cidr',
65 |
66 | # IP globbing class.
67 | 'IPGlob',
68 |
69 | # IP globbing functions.
70 | 'cidr_to_glob', 'glob_to_cidrs', 'glob_to_iprange', 'glob_to_iptuple',
71 | 'iprange_to_globs',
72 |
73 | # IEEE EUI classes.
74 | 'EUI', 'IAB', 'OUI',
75 |
76 | # EUI-48 (MAC) dialect classes.
77 | 'mac_bare', 'mac_cisco', 'mac_eui48', 'mac_pgsql', 'mac_unix',
78 | 'mac_unix_expanded',
79 |
80 | # Validation functions.
81 | 'valid_ipv4', 'valid_ipv6', 'valid_glob', 'valid_mac',
82 |
83 | # nmap-style range functions.
84 | 'valid_nmap_range', 'iter_nmap_range',
85 |
86 | # RFC 1924 functions.
87 | 'base85_to_ipv6', 'ipv6_to_base85',
88 | ]
89 |
--------------------------------------------------------------------------------
/103-UserData Installing WordPress/wp-infrastructure-103-Linux1-distro.yaml:
--------------------------------------------------------------------------------
1 | Parameters:
2 | EnvironmentSize:
3 | Type: String
4 | Default: SMALL
5 | AllowedValues:
6 | - SMALL
7 | - MEDIUM
8 | - LARGE
9 | Description: Select Environment Size (S,M,L)
10 | DatabaseName:
11 | Type: String
12 | Default: wordpress
13 | DatabaseUser:
14 | Type: String
15 | Default: wordpress
16 | DatabasePassword:
17 | Type: String
18 | Default: w0rdpr355
19 | NoEcho: true
20 | Mappings:
21 | RegionMap:
22 | us-east-1:
23 | AMALINUX: ami-0080e4c5bc078760e
24 | us-east-2:
25 | AMALINUX: ami-0cd3dfa4e37921605
26 | us-west-1:
27 | AMALINUX: ami-0ec6517f6edbf8044
28 | us-west-2:
29 | AMALINUX: ami-01e24be29428c15b2
30 | sa-east-1:
31 | AMALINUX: ami-05145e0b28ad8e0b2
32 | ca-central-1:
33 | AMALINUX: ami-07423fb63ea0a0930
34 | eu-west-1:
35 | AMALINUX: ami-08935252a36e25f85
36 | eu-west-2:
37 | AMALINUX: ami-01419b804382064e4
38 | eu-west-3:
39 | AMALINUX: ami-0dd7e7ed60da8fb83
40 | eu-central-1:
41 | AMALINUX: ami-0cfbf4f6db41068ac
42 | ap-southeast-1:
43 | AMALINUX: ami-05b3bcf7f311194b3
44 | ap-southeast-2:
45 | AMALINUX: ami-02fd0b06f06d93dfc
46 | ap-northeast-1:
47 | AMALINUX: ami-00a5245b4816c38e6
48 | ap-northeast-2:
49 | AMALINUX: ami-00dc207f8ba6dc919
50 | ap-south-1:
51 | AMALINUX: ami-0ad42f4f66f6c1cc9
52 | cn-north-1:
53 | AMALINUX: ami-8e6aa0e3
54 |
55 | InstanceSize:
56 | SMALL:
57 | "EC2" : "t2.micro"
58 | "DB" : "db.t2.micro"
59 | MEDIUM:
60 | "EC2" : "t2.small"
61 | "DB" : "db.t2.small"
62 | LARGE:
63 | "EC2" : "t2.medium"
64 | "DB" : "db.t2.medium"
65 | Resources:
66 | DB:
67 | Type: "AWS::RDS::DBInstance"
68 | Properties:
69 | AllocatedStorage: 5
70 | StorageType: gp2
71 | DBInstanceClass: !FindInMap [InstanceSize, !Ref EnvironmentSize, DB] # Dynamic mapping + Pseudo Parameter
72 | DBName: !Ref DatabaseName
73 | Engine: MySQL
74 | MasterUsername: !Ref DatabaseUser
75 | MasterUserPassword: !Ref DatabasePassword
76 | EC2:
77 | Type: "AWS::EC2::Instance"
78 | Properties:
79 | ImageId: !FindInMap [RegionMap, !Ref "AWS::Region", AMALINUX] # Dynamic mapping + Pseudo Parameter
80 | InstanceType: !FindInMap [InstanceSize, !Ref EnvironmentSize, EC2]
81 | KeyName: AdvancedCFN
82 | UserData:
83 | "Fn::Base64":
84 | !Sub |
85 | #!/bin/bash
86 | yum install httpd php mysql php-mysql -y
87 | yum update -y
88 | chkconfig httpd on
89 | service httpd start
90 | cd /var/www/html
91 | wget https://wordpress.org/latest.tar.gz
92 | tar -zxvf latest.tar.gz --strip 1
93 | rm latest.tar.gz
94 | cp wp-config-sample.php wp-config.php
95 | sed -i 's/database_name_here/${DatabaseName}/g' wp-config.php
96 | sed -i 's/localhost/${DB.Endpoint.Address}/g' wp-config.php
97 | sed -i 's/username_here/${DatabaseUser}/g' wp-config.php
98 | sed -i 's/password_here/${DatabasePassword}/g' wp-config.php
99 | S3:
100 | Type: "AWS::S3::Bucket"
101 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/exceptions.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | requests.exceptions
5 | ~~~~~~~~~~~~~~~~~~~
6 |
7 | This module contains the set of Requests' exceptions.
8 | """
9 | from .packages.urllib3.exceptions import HTTPError as BaseHTTPError
10 |
11 |
12 | class RequestException(IOError):
13 | """There was an ambiguous exception that occurred while handling your
14 | request.
15 | """
16 |
17 | def __init__(self, *args, **kwargs):
18 | """Initialize RequestException with `request` and `response` objects."""
19 | response = kwargs.pop('response', None)
20 | self.response = response
21 | self.request = kwargs.pop('request', None)
22 | if (response is not None and not self.request and
23 | hasattr(response, 'request')):
24 | self.request = self.response.request
25 | super(RequestException, self).__init__(*args, **kwargs)
26 |
27 |
28 | class HTTPError(RequestException):
29 | """An HTTP error occurred."""
30 |
31 |
32 | class ConnectionError(RequestException):
33 | """A Connection error occurred."""
34 |
35 |
36 | class ProxyError(ConnectionError):
37 | """A proxy error occurred."""
38 |
39 |
40 | class SSLError(ConnectionError):
41 | """An SSL error occurred."""
42 |
43 |
44 | class Timeout(RequestException):
45 | """The request timed out.
46 |
47 | Catching this error will catch both
48 | :exc:`~requests.exceptions.ConnectTimeout` and
49 | :exc:`~requests.exceptions.ReadTimeout` errors.
50 | """
51 |
52 |
53 | class ConnectTimeout(ConnectionError, Timeout):
54 | """The request timed out while trying to connect to the remote server.
55 |
56 | Requests that produced this error are safe to retry.
57 | """
58 |
59 |
60 | class ReadTimeout(Timeout):
61 | """The server did not send any data in the allotted amount of time."""
62 |
63 |
64 | class URLRequired(RequestException):
65 | """A valid URL is required to make a request."""
66 |
67 |
68 | class TooManyRedirects(RequestException):
69 | """Too many redirects."""
70 |
71 |
72 | class MissingSchema(RequestException, ValueError):
73 | """The URL schema (e.g. http or https) is missing."""
74 |
75 |
76 | class InvalidSchema(RequestException, ValueError):
77 | """See defaults.py for valid schemas."""
78 |
79 |
80 | class InvalidURL(RequestException, ValueError):
81 | """The URL provided was somehow invalid."""
82 |
83 |
84 | class InvalidHeader(RequestException, ValueError):
85 | """The header value provided was somehow invalid."""
86 |
87 |
88 | class ChunkedEncodingError(RequestException):
89 | """The server declared chunked encoding but sent an invalid chunk."""
90 |
91 |
92 | class ContentDecodingError(RequestException, BaseHTTPError):
93 | """Failed to decode response content"""
94 |
95 |
96 | class StreamConsumedError(RequestException, TypeError):
97 | """The content for this response was already consumed"""
98 |
99 |
100 | class RetryError(RequestException):
101 | """Custom retries logic failed"""
102 |
103 |
104 | # Warnings
105 |
106 |
107 | class RequestsWarning(Warning):
108 | """Base warning for Requests."""
109 | pass
110 |
111 |
112 | class FileModeWarning(RequestsWarning, DeprecationWarning):
113 | """A file was opened in text mode, but Requests determined its binary length."""
114 | pass
115 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/escprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from . import constants
29 | from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel,
30 | ISO2022KRSMModel)
31 | from .charsetprober import CharSetProber
32 | from .codingstatemachine import CodingStateMachine
33 | from .compat import wrap_ord
34 |
35 |
36 | class EscCharSetProber(CharSetProber):
37 | def __init__(self):
38 | CharSetProber.__init__(self)
39 | self._mCodingSM = [
40 | CodingStateMachine(HZSMModel),
41 | CodingStateMachine(ISO2022CNSMModel),
42 | CodingStateMachine(ISO2022JPSMModel),
43 | CodingStateMachine(ISO2022KRSMModel)
44 | ]
45 | self.reset()
46 |
47 | def reset(self):
48 | CharSetProber.reset(self)
49 | for codingSM in self._mCodingSM:
50 | if not codingSM:
51 | continue
52 | codingSM.active = True
53 | codingSM.reset()
54 | self._mActiveSM = len(self._mCodingSM)
55 | self._mDetectedCharset = None
56 |
57 | def get_charset_name(self):
58 | return self._mDetectedCharset
59 |
60 | def get_confidence(self):
61 | if self._mDetectedCharset:
62 | return 0.99
63 | else:
64 | return 0.00
65 |
66 | def feed(self, aBuf):
67 | for c in aBuf:
68 | # PY3K: aBuf is a byte array, so c is an int, not a byte
69 | for codingSM in self._mCodingSM:
70 | if not codingSM:
71 | continue
72 | if not codingSM.active:
73 | continue
74 | codingState = codingSM.next_state(wrap_ord(c))
75 | if codingState == constants.eError:
76 | codingSM.active = False
77 | self._mActiveSM -= 1
78 | if self._mActiveSM <= 0:
79 | self._mState = constants.eNotMe
80 | return self.get_state()
81 | elif codingState == constants.eItsMe:
82 | self._mState = constants.eFoundIt
83 | self._mDetectedCharset = codingSM.get_coding_state_machine() # nopep8
84 | return self.get_state()
85 |
86 | return self.get_state()
87 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/structures.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | requests.structures
5 | ~~~~~~~~~~~~~~~~~~~
6 |
7 | Data structures that power Requests.
8 | """
9 |
10 | import collections
11 |
12 | from .compat import OrderedDict
13 |
14 |
15 | class CaseInsensitiveDict(collections.MutableMapping):
16 | """A case-insensitive ``dict``-like object.
17 |
18 | Implements all methods and operations of
19 | ``collections.MutableMapping`` as well as dict's ``copy``. Also
20 | provides ``lower_items``.
21 |
22 | All keys are expected to be strings. The structure remembers the
23 | case of the last key to be set, and ``iter(instance)``,
24 | ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()``
25 | will contain case-sensitive keys. However, querying and contains
26 | testing is case insensitive::
27 |
28 | cid = CaseInsensitiveDict()
29 | cid['Accept'] = 'application/json'
30 | cid['aCCEPT'] == 'application/json' # True
31 | list(cid) == ['Accept'] # True
32 |
33 | For example, ``headers['content-encoding']`` will return the
34 | value of a ``'Content-Encoding'`` response header, regardless
35 | of how the header name was originally stored.
36 |
37 | If the constructor, ``.update``, or equality comparison
38 | operations are given keys that have equal ``.lower()``s, the
39 | behavior is undefined.
40 | """
41 |
42 | def __init__(self, data=None, **kwargs):
43 | self._store = OrderedDict()
44 | if data is None:
45 | data = {}
46 | self.update(data, **kwargs)
47 |
48 | def __setitem__(self, key, value):
49 | # Use the lowercased key for lookups, but store the actual
50 | # key alongside the value.
51 | self._store[key.lower()] = (key, value)
52 |
53 | def __getitem__(self, key):
54 | return self._store[key.lower()][1]
55 |
56 | def __delitem__(self, key):
57 | del self._store[key.lower()]
58 |
59 | def __iter__(self):
60 | return (casedkey for casedkey, mappedvalue in self._store.values())
61 |
62 | def __len__(self):
63 | return len(self._store)
64 |
65 | def lower_items(self):
66 | """Like iteritems(), but with all lowercase keys."""
67 | return (
68 | (lowerkey, keyval[1])
69 | for (lowerkey, keyval)
70 | in self._store.items()
71 | )
72 |
73 | def __eq__(self, other):
74 | if isinstance(other, collections.Mapping):
75 | other = CaseInsensitiveDict(other)
76 | else:
77 | return NotImplemented
78 | # Compare insensitively
79 | return dict(self.lower_items()) == dict(other.lower_items())
80 |
81 | # Copy is required
82 | def copy(self):
83 | return CaseInsensitiveDict(self._store.values())
84 |
85 | def __repr__(self):
86 | return str(dict(self.items()))
87 |
88 |
89 | class LookupDict(dict):
90 | """Dictionary lookup object."""
91 |
92 | def __init__(self, name=None):
93 | self.name = name
94 | super(LookupDict, self).__init__()
95 |
96 | def __repr__(self):
97 | return '' % (self.name)
98 |
99 | def __getitem__(self, key):
100 | # We allow fall-through here, so values default to None
101 |
102 | return self.__dict__.get(key, None)
103 |
104 | def get(self, key, default=None):
105 | return self.__dict__.get(key, default)
106 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/sbcsgroupprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | #
13 | # This library is free software; you can redistribute it and/or
14 | # modify it under the terms of the GNU Lesser General Public
15 | # License as published by the Free Software Foundation; either
16 | # version 2.1 of the License, or (at your option) any later version.
17 | #
18 | # This library is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 | # Lesser General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU Lesser General Public
24 | # License along with this library; if not, write to the Free Software
25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 | # 02110-1301 USA
27 | ######################### END LICENSE BLOCK #########################
28 |
29 | from .charsetgroupprober import CharSetGroupProber
30 | from .sbcharsetprober import SingleByteCharSetProber
31 | from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel,
32 | Latin5CyrillicModel, MacCyrillicModel,
33 | Ibm866Model, Ibm855Model)
34 | from .langgreekmodel import Latin7GreekModel, Win1253GreekModel
35 | from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel
36 | from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel
37 | from .langthaimodel import TIS620ThaiModel
38 | from .langhebrewmodel import Win1255HebrewModel
39 | from .hebrewprober import HebrewProber
40 |
41 |
42 | class SBCSGroupProber(CharSetGroupProber):
43 | def __init__(self):
44 | CharSetGroupProber.__init__(self)
45 | self._mProbers = [
46 | SingleByteCharSetProber(Win1251CyrillicModel),
47 | SingleByteCharSetProber(Koi8rModel),
48 | SingleByteCharSetProber(Latin5CyrillicModel),
49 | SingleByteCharSetProber(MacCyrillicModel),
50 | SingleByteCharSetProber(Ibm866Model),
51 | SingleByteCharSetProber(Ibm855Model),
52 | SingleByteCharSetProber(Latin7GreekModel),
53 | SingleByteCharSetProber(Win1253GreekModel),
54 | SingleByteCharSetProber(Latin5BulgarianModel),
55 | SingleByteCharSetProber(Win1251BulgarianModel),
56 | SingleByteCharSetProber(Latin2HungarianModel),
57 | SingleByteCharSetProber(Win1250HungarianModel),
58 | SingleByteCharSetProber(TIS620ThaiModel),
59 | ]
60 | hebrewProber = HebrewProber()
61 | logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel,
62 | False, hebrewProber)
63 | visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True,
64 | hebrewProber)
65 | hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber)
66 | self._mProbers.extend([hebrewProber, logicalHebrewProber,
67 | visualHebrewProber])
68 |
69 | self.reset()
70 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/mbcharsetprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | # Proofpoint, Inc.
13 | #
14 | # This library is free software; you can redistribute it and/or
15 | # modify it under the terms of the GNU Lesser General Public
16 | # License as published by the Free Software Foundation; either
17 | # version 2.1 of the License, or (at your option) any later version.
18 | #
19 | # This library is distributed in the hope that it will be useful,
20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 | # Lesser General Public License for more details.
23 | #
24 | # You should have received a copy of the GNU Lesser General Public
25 | # License along with this library; if not, write to the Free Software
26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 | # 02110-1301 USA
28 | ######################### END LICENSE BLOCK #########################
29 |
30 | import sys
31 | from . import constants
32 | from .charsetprober import CharSetProber
33 |
34 |
35 | class MultiByteCharSetProber(CharSetProber):
36 | def __init__(self):
37 | CharSetProber.__init__(self)
38 | self._mDistributionAnalyzer = None
39 | self._mCodingSM = None
40 | self._mLastChar = [0, 0]
41 |
42 | def reset(self):
43 | CharSetProber.reset(self)
44 | if self._mCodingSM:
45 | self._mCodingSM.reset()
46 | if self._mDistributionAnalyzer:
47 | self._mDistributionAnalyzer.reset()
48 | self._mLastChar = [0, 0]
49 |
50 | def get_charset_name(self):
51 | pass
52 |
53 | def feed(self, aBuf):
54 | aLen = len(aBuf)
55 | for i in range(0, aLen):
56 | codingState = self._mCodingSM.next_state(aBuf[i])
57 | if codingState == constants.eError:
58 | if constants._debug:
59 | sys.stderr.write(self.get_charset_name()
60 | + ' prober hit error at byte ' + str(i)
61 | + '\n')
62 | self._mState = constants.eNotMe
63 | break
64 | elif codingState == constants.eItsMe:
65 | self._mState = constants.eFoundIt
66 | break
67 | elif codingState == constants.eStart:
68 | charLen = self._mCodingSM.get_current_charlen()
69 | if i == 0:
70 | self._mLastChar[1] = aBuf[0]
71 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
72 | else:
73 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
74 | charLen)
75 |
76 | self._mLastChar[0] = aBuf[aLen - 1]
77 |
78 | if self.get_state() == constants.eDetecting:
79 | if (self._mDistributionAnalyzer.got_enough_data() and
80 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
81 | self._mState = constants.eFoundIt
82 |
83 | return self.get_state()
84 |
85 | def get_confidence(self):
86 | return self._mDistributionAnalyzer.get_confidence()
87 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/status_codes.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | from .structures import LookupDict
4 |
5 | _codes = {
6 |
7 | # Informational.
8 | 100: ('continue',),
9 | 101: ('switching_protocols',),
10 | 102: ('processing',),
11 | 103: ('checkpoint',),
12 | 122: ('uri_too_long', 'request_uri_too_long'),
13 | 200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/', '✓'),
14 | 201: ('created',),
15 | 202: ('accepted',),
16 | 203: ('non_authoritative_info', 'non_authoritative_information'),
17 | 204: ('no_content',),
18 | 205: ('reset_content', 'reset'),
19 | 206: ('partial_content', 'partial'),
20 | 207: ('multi_status', 'multiple_status', 'multi_stati', 'multiple_stati'),
21 | 208: ('already_reported',),
22 | 226: ('im_used',),
23 |
24 | # Redirection.
25 | 300: ('multiple_choices',),
26 | 301: ('moved_permanently', 'moved', '\\o-'),
27 | 302: ('found',),
28 | 303: ('see_other', 'other'),
29 | 304: ('not_modified',),
30 | 305: ('use_proxy',),
31 | 306: ('switch_proxy',),
32 | 307: ('temporary_redirect', 'temporary_moved', 'temporary'),
33 | 308: ('permanent_redirect',
34 | 'resume_incomplete', 'resume',), # These 2 to be removed in 3.0
35 |
36 | # Client Error.
37 | 400: ('bad_request', 'bad'),
38 | 401: ('unauthorized',),
39 | 402: ('payment_required', 'payment'),
40 | 403: ('forbidden',),
41 | 404: ('not_found', '-o-'),
42 | 405: ('method_not_allowed', 'not_allowed'),
43 | 406: ('not_acceptable',),
44 | 407: ('proxy_authentication_required', 'proxy_auth', 'proxy_authentication'),
45 | 408: ('request_timeout', 'timeout'),
46 | 409: ('conflict',),
47 | 410: ('gone',),
48 | 411: ('length_required',),
49 | 412: ('precondition_failed', 'precondition'),
50 | 413: ('request_entity_too_large',),
51 | 414: ('request_uri_too_large',),
52 | 415: ('unsupported_media_type', 'unsupported_media', 'media_type'),
53 | 416: ('requested_range_not_satisfiable', 'requested_range', 'range_not_satisfiable'),
54 | 417: ('expectation_failed',),
55 | 418: ('im_a_teapot', 'teapot', 'i_am_a_teapot'),
56 | 421: ('misdirected_request',),
57 | 422: ('unprocessable_entity', 'unprocessable'),
58 | 423: ('locked',),
59 | 424: ('failed_dependency', 'dependency'),
60 | 425: ('unordered_collection', 'unordered'),
61 | 426: ('upgrade_required', 'upgrade'),
62 | 428: ('precondition_required', 'precondition'),
63 | 429: ('too_many_requests', 'too_many'),
64 | 431: ('header_fields_too_large', 'fields_too_large'),
65 | 444: ('no_response', 'none'),
66 | 449: ('retry_with', 'retry'),
67 | 450: ('blocked_by_windows_parental_controls', 'parental_controls'),
68 | 451: ('unavailable_for_legal_reasons', 'legal_reasons'),
69 | 499: ('client_closed_request',),
70 |
71 | # Server Error.
72 | 500: ('internal_server_error', 'server_error', '/o\\', '✗'),
73 | 501: ('not_implemented',),
74 | 502: ('bad_gateway',),
75 | 503: ('service_unavailable', 'unavailable'),
76 | 504: ('gateway_timeout',),
77 | 505: ('http_version_not_supported', 'http_version'),
78 | 506: ('variant_also_negotiates',),
79 | 507: ('insufficient_storage',),
80 | 509: ('bandwidth_limit_exceeded', 'bandwidth'),
81 | 510: ('not_extended',),
82 | 511: ('network_authentication_required', 'network_auth', 'network_authentication'),
83 | }
84 |
85 | codes = LookupDict(name='status_codes')
86 |
87 | for code, titles in _codes.items():
88 | for title in titles:
89 | setattr(codes, title, code)
90 | if not title.startswith('\\'):
91 | setattr(codes, title.upper(), code)
92 |
--------------------------------------------------------------------------------
/103-UserData Installing WordPress/wp-infrastructure-103-Linux1-distro.json:
--------------------------------------------------------------------------------
1 | {
2 | "Parameters": {
3 | "EnvironmentSize": {
4 | "Type": "String",
5 | "Default": "SMALL",
6 | "AllowedValues": [
7 | "SMALL",
8 | "MEDIUM",
9 | "LARGE"
10 | ],
11 | "Description": "Select Environment Size (S,M,L)"
12 | },
13 | "DatabaseName" : {
14 | "Type" : "String",
15 | "Default" : "wordpress"
16 | },
17 | "DatabaseUser" : {
18 | "Type" : "String",
19 | "Default" : "wordpress"
20 | },
21 | "DatabasePassword" : {
22 | "Type" : "String",
23 | "Default" : "w0rdpr355"
24 | }
25 | },
26 | "Mappings": {
27 | "RegionMap": {
28 | "us-east-1" : { "AMALINUX": "ami-0080e4c5bc078760e" },
29 | "us-east-2" : { "AMALINUX": "ami-0cd3dfa4e37921605" },
30 |
31 | "us-west-1" : { "AMALINUX": "ami-0ec6517f6edbf8044" },
32 | "us-west-2" : { "AMALINUX": "ami-01e24be29428c15b2" },
33 |
34 | "sa-east-1" : { "AMALINUX": "ami-05145e0b28ad8e0b2" },
35 | "ca-central-1" : { "AMALINUX": "ami-07423fb63ea0a0930" },
36 |
37 | "eu-west-1" : { "AMALINUX": "ami-08935252a36e25f85" },
38 | "eu-west-2" : { "AMALINUX": "ami-01419b804382064e4" },
39 | "eu-west-3" : { "AMALINUX": "ami-0dd7e7ed60da8fb83" },
40 | "eu-central-1" : { "AMALINUX": "ami-0cfbf4f6db41068ac" },
41 |
42 | "ap-southeast-1": { "AMALINUX": "ami-05b3bcf7f311194b3" },
43 | "ap-southeast-2": { "AMALINUX": "ami-02fd0b06f06d93dfc" },
44 | "ap-northeast-1": { "AMALINUX": "ami-00a5245b4816c38e6" },
45 | "ap-northeast-2": { "AMALINUX": "ami-00dc207f8ba6dc919" },
46 | "ap-south-1" : { "AMALINUX": "ami-0ad42f4f66f6c1cc9" },
47 |
48 | "cn-north-1" : { "AMALINUX": "ami-8e6aa0e3" }
49 | },
50 |
51 | "InstanceSize": {
52 | "SMALL" : { "EC2": "t2.micro", "DB": "db.t2.micro" },
53 | "MEDIUM": { "EC2": "t2.small", "DB": "db.t2.small" },
54 | "LARGE" : { "EC2": "t2.medium", "DB": "db.t2.medium" }
55 | }
56 | },
57 | "Resources": {
58 | "DB": {
59 | "Type": "AWS::RDS::DBInstance",
60 | "Properties": {
61 | "AllocatedStorage": 5,
62 | "StorageType" : "gp2",
63 | "DBInstanceClass": {"Fn::FindInMap" : ["InstanceSize", {"Ref" : "EnvironmentSize"}, "DB"]},
64 | "DBName": {"Ref" : "DatabaseName"},
65 | "Engine": "MySQL",
66 | "MasterUsername": {"Ref" : "DatabaseUser"},
67 | "MasterUserPassword": {"Ref" : "DatabasePassword"}
68 | }
69 | },
70 | "EC2": {
71 | "Type": "AWS::EC2::Instance",
72 | "Properties": {
73 | "ImageId": {"Fn::FindInMap" : ["RegionMap", {"Ref" : "AWS::Region"}, "AMALINUX"]},
74 | "InstanceType": {"Fn::FindInMap" : ["InstanceSize", {"Ref" : "EnvironmentSize"}, "EC2"]},
75 | "KeyName" : "AdvancedCFN",
76 | "UserData" : {"Fn::Base64" : {"Fn::Join" : ["", [
77 | "#!/bin/bash", "\n",
78 | "yum install httpd php mysql php-mysql -y", "\n",
79 | "yum update -y", "\n",
80 | "chkconfig httpd on", "\n",
81 | "service httpd start", "\n",
82 | "cd /var/www/html", "\n",
83 | "wget https://wordpress.org/latest.tar.gz", "\n",
84 | "tar -zxvf latest.tar.gz --strip 1", "\n",
85 | "rm latest.tar.gz", "\n",
86 | "cp wp-config-sample.php wp-config.php", "\n",
87 | "sed -i 's/database_name_here/", {"Ref" : "DatabaseName"}, "/g' wp-config.php", "\n",
88 | "sed -i 's/localhost/", {"Fn::GetAtt" : ["DB", "Endpoint.Address"]}, "/g' wp-config.php", "\n",
89 | "sed -i 's/username_here/", {"Ref" : "DatabaseUser"}, "/g' wp-config.php", "\n",
90 | "sed -i 's/password_here/", {"Ref" : "DatabasePassword"},"/g' wp-config.php", "\n"
91 | ]]}}
92 | }
93 | },
94 | "S3": {
95 | "Type": "AWS::S3::Bucket"
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/eucjpprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | import sys
29 | from . import constants
30 | from .mbcharsetprober import MultiByteCharSetProber
31 | from .codingstatemachine import CodingStateMachine
32 | from .chardistribution import EUCJPDistributionAnalysis
33 | from .jpcntx import EUCJPContextAnalysis
34 | from .mbcssm import EUCJPSMModel
35 |
36 |
37 | class EUCJPProber(MultiByteCharSetProber):
38 | def __init__(self):
39 | MultiByteCharSetProber.__init__(self)
40 | self._mCodingSM = CodingStateMachine(EUCJPSMModel)
41 | self._mDistributionAnalyzer = EUCJPDistributionAnalysis()
42 | self._mContextAnalyzer = EUCJPContextAnalysis()
43 | self.reset()
44 |
45 | def reset(self):
46 | MultiByteCharSetProber.reset(self)
47 | self._mContextAnalyzer.reset()
48 |
49 | def get_charset_name(self):
50 | return "EUC-JP"
51 |
52 | def feed(self, aBuf):
53 | aLen = len(aBuf)
54 | for i in range(0, aLen):
55 | # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte
56 | codingState = self._mCodingSM.next_state(aBuf[i])
57 | if codingState == constants.eError:
58 | if constants._debug:
59 | sys.stderr.write(self.get_charset_name()
60 | + ' prober hit error at byte ' + str(i)
61 | + '\n')
62 | self._mState = constants.eNotMe
63 | break
64 | elif codingState == constants.eItsMe:
65 | self._mState = constants.eFoundIt
66 | break
67 | elif codingState == constants.eStart:
68 | charLen = self._mCodingSM.get_current_charlen()
69 | if i == 0:
70 | self._mLastChar[1] = aBuf[0]
71 | self._mContextAnalyzer.feed(self._mLastChar, charLen)
72 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
73 | else:
74 | self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen)
75 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
76 | charLen)
77 |
78 | self._mLastChar[0] = aBuf[aLen - 1]
79 |
80 | if self.get_state() == constants.eDetecting:
81 | if (self._mContextAnalyzer.got_enough_data() and
82 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
83 | self._mState = constants.eFoundIt
84 |
85 | return self.get_state()
86 |
87 | def get_confidence(self):
88 | contxtCf = self._mContextAnalyzer.get_confidence()
89 | distribCf = self._mDistributionAnalyzer.get_confidence()
90 | return max(contxtCf, distribCf)
91 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/sjisprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | import sys
29 | from .mbcharsetprober import MultiByteCharSetProber
30 | from .codingstatemachine import CodingStateMachine
31 | from .chardistribution import SJISDistributionAnalysis
32 | from .jpcntx import SJISContextAnalysis
33 | from .mbcssm import SJISSMModel
34 | from . import constants
35 |
36 |
37 | class SJISProber(MultiByteCharSetProber):
38 | def __init__(self):
39 | MultiByteCharSetProber.__init__(self)
40 | self._mCodingSM = CodingStateMachine(SJISSMModel)
41 | self._mDistributionAnalyzer = SJISDistributionAnalysis()
42 | self._mContextAnalyzer = SJISContextAnalysis()
43 | self.reset()
44 |
45 | def reset(self):
46 | MultiByteCharSetProber.reset(self)
47 | self._mContextAnalyzer.reset()
48 |
49 | def get_charset_name(self):
50 | return self._mContextAnalyzer.get_charset_name()
51 |
52 | def feed(self, aBuf):
53 | aLen = len(aBuf)
54 | for i in range(0, aLen):
55 | codingState = self._mCodingSM.next_state(aBuf[i])
56 | if codingState == constants.eError:
57 | if constants._debug:
58 | sys.stderr.write(self.get_charset_name()
59 | + ' prober hit error at byte ' + str(i)
60 | + '\n')
61 | self._mState = constants.eNotMe
62 | break
63 | elif codingState == constants.eItsMe:
64 | self._mState = constants.eFoundIt
65 | break
66 | elif codingState == constants.eStart:
67 | charLen = self._mCodingSM.get_current_charlen()
68 | if i == 0:
69 | self._mLastChar[1] = aBuf[0]
70 | self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:],
71 | charLen)
72 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
73 | else:
74 | self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3
75 | - charLen], charLen)
76 | self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
77 | charLen)
78 |
79 | self._mLastChar[0] = aBuf[aLen - 1]
80 |
81 | if self.get_state() == constants.eDetecting:
82 | if (self._mContextAnalyzer.got_enough_data() and
83 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
84 | self._mState = constants.eFoundIt
85 |
86 | return self.get_state()
87 |
88 | def get_confidence(self):
89 | contxtCf = self._mContextAnalyzer.get_confidence()
90 | distribCf = self._mDistributionAnalyzer.get_confidence()
91 | return max(contxtCf, distribCf)
92 |
--------------------------------------------------------------------------------
/110-SelfServicePortal/Customer/customeriamandrole.json:
--------------------------------------------------------------------------------
1 | {
2 | "Resources" : {
3 | "iamuser" : {
4 | "Type" : "AWS::IAM::User",
5 | "Properties" : {
6 | "UserName" : "whicustomer",
7 | "ManagedPolicyArns" : [
8 | "arn:aws:iam::aws:policy/ReadOnlyAccess"
9 | ],
10 | "LoginProfile": {
11 | "Password" : "P@55w0rd",
12 | "PasswordResetRequired" : "false"
13 | }
14 | }
15 | },
16 | "iamkeys" : {
17 | "DependsOn" : "iamuser",
18 | "Type" : "AWS::IAM::AccessKey",
19 | "Properties" : {
20 | "UserName" : "whicustomer"
21 | }
22 | },
23 | "iamrole" : {
24 | "Type" : "AWS::IAM::Role",
25 | "Properties" : {
26 | "AssumeRolePolicyDocument" : {
27 | "Version" : "2012-10-17",
28 | "Statement" : [
29 | {
30 | "Effect" : "Allow",
31 | "Action" : [
32 | "sts:AssumeRoleWithWebIdentity"
33 | ],
34 | "Condition" : {
35 | "ForAnyValue:StringLike" : {
36 | "cognito-identity.amazonaws.com:amr": "authenticated"
37 | }
38 | },
39 | "Principal" : {
40 | "Federated" : [
41 | "cognito-identity.amazonaws.com"
42 | ]
43 | }
44 | }
45 | ]
46 | },
47 | "Path" : "/",
48 | "Policies" : [
49 | {
50 | "PolicyName" : "main",
51 | "PolicyDocument" : {
52 | "Version" : "2012-10-17",
53 | "Statement": [
54 | {
55 | "Effect" : "Allow",
56 | "Resource" : "*",
57 | "Action" : [
58 | "cloudformation:CreateStack",
59 | "cloudformation:UpdateStack",
60 | "cloudformation:DeleteStack",
61 | "cloudformation:CreateUploadBucket",
62 | "cloudformation:DescribeStacks",
63 | "cloudformation:DescribeStackEvents",
64 | "cloudformation:GetTemplateSummary",
65 | "cloudformation:ListStacks",
66 | "cloudformation:ListStackResources",
67 | "s3:CreateBucket",
68 | "s3:GetObject",
69 | "s3:PutObject",
70 | "mobileanalytics:PutEvent",
71 | "cognito-sync:*",
72 | "cognito-identity:*"
73 | ]
74 | }
75 | ]
76 | }
77 | }
78 | ]
79 | }
80 | }
81 | },
82 | "Outputs" : {
83 | "customerakid" : {
84 | "Description" : "Customer Access Key ID",
85 | "Value" : {"Ref" : "iamkeys"}
86 | },
87 | "customersecretkey" : {
88 | "Description" : "Customer Secret Access Key",
89 | "Value" : {"Fn::GetAtt" : ["iamkeys", "SecretAccessKey"]}
90 | },
91 | "customerrole" : {
92 | "Description" : "Customer Role arn",
93 | "Value" : {"Fn::GetAtt": ["iamrole", "Arn"]}
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/charsetgroupprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Communicator client code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from . import constants
29 | import sys
30 | from .charsetprober import CharSetProber
31 |
32 |
33 | class CharSetGroupProber(CharSetProber):
34 | def __init__(self):
35 | CharSetProber.__init__(self)
36 | self._mActiveNum = 0
37 | self._mProbers = []
38 | self._mBestGuessProber = None
39 |
40 | def reset(self):
41 | CharSetProber.reset(self)
42 | self._mActiveNum = 0
43 | for prober in self._mProbers:
44 | if prober:
45 | prober.reset()
46 | prober.active = True
47 | self._mActiveNum += 1
48 | self._mBestGuessProber = None
49 |
50 | def get_charset_name(self):
51 | if not self._mBestGuessProber:
52 | self.get_confidence()
53 | if not self._mBestGuessProber:
54 | return None
55 | # self._mBestGuessProber = self._mProbers[0]
56 | return self._mBestGuessProber.get_charset_name()
57 |
58 | def feed(self, aBuf):
59 | for prober in self._mProbers:
60 | if not prober:
61 | continue
62 | if not prober.active:
63 | continue
64 | st = prober.feed(aBuf)
65 | if not st:
66 | continue
67 | if st == constants.eFoundIt:
68 | self._mBestGuessProber = prober
69 | return self.get_state()
70 | elif st == constants.eNotMe:
71 | prober.active = False
72 | self._mActiveNum -= 1
73 | if self._mActiveNum <= 0:
74 | self._mState = constants.eNotMe
75 | return self.get_state()
76 | return self.get_state()
77 |
78 | def get_confidence(self):
79 | st = self.get_state()
80 | if st == constants.eFoundIt:
81 | return 0.99
82 | elif st == constants.eNotMe:
83 | return 0.01
84 | bestConf = 0.0
85 | self._mBestGuessProber = None
86 | for prober in self._mProbers:
87 | if not prober:
88 | continue
89 | if not prober.active:
90 | if constants._debug:
91 | sys.stderr.write(prober.get_charset_name()
92 | + ' not active\n')
93 | continue
94 | cf = prober.get_confidence()
95 | if constants._debug:
96 | sys.stderr.write('%s confidence = %s\n' %
97 | (prober.get_charset_name(), cf))
98 | if bestConf < cf:
99 | bestConf = cf
100 | self._mBestGuessProber = prober
101 | if not self._mBestGuessProber:
102 | return 0.0
103 | return bestConf
104 | # else:
105 | # self._mBestGuessProber = self._mProbers[0]
106 | # return self._mBestGuessProber.get_confidence()
107 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py:
--------------------------------------------------------------------------------
1 | """The match_hostname() function from Python 3.3.3, essential when using SSL."""
2 |
3 | # Note: This file is under the PSF license as the code comes from the python
4 | # stdlib. http://docs.python.org/3/license.html
5 |
6 | import re
7 |
8 | __version__ = '3.4.0.2'
9 |
10 | class CertificateError(ValueError):
11 | pass
12 |
13 |
14 | def _dnsname_match(dn, hostname, max_wildcards=1):
15 | """Matching according to RFC 6125, section 6.4.3
16 |
17 | http://tools.ietf.org/html/rfc6125#section-6.4.3
18 | """
19 | pats = []
20 | if not dn:
21 | return False
22 |
23 | # Ported from python3-syntax:
24 | # leftmost, *remainder = dn.split(r'.')
25 | parts = dn.split(r'.')
26 | leftmost = parts[0]
27 | remainder = parts[1:]
28 |
29 | wildcards = leftmost.count('*')
30 | if wildcards > max_wildcards:
31 | # Issue #17980: avoid denials of service by refusing more
32 | # than one wildcard per fragment. A survey of established
33 | # policy among SSL implementations showed it to be a
34 | # reasonable choice.
35 | raise CertificateError(
36 | "too many wildcards in certificate DNS name: " + repr(dn))
37 |
38 | # speed up common case w/o wildcards
39 | if not wildcards:
40 | return dn.lower() == hostname.lower()
41 |
42 | # RFC 6125, section 6.4.3, subitem 1.
43 | # The client SHOULD NOT attempt to match a presented identifier in which
44 | # the wildcard character comprises a label other than the left-most label.
45 | if leftmost == '*':
46 | # When '*' is a fragment by itself, it matches a non-empty dotless
47 | # fragment.
48 | pats.append('[^.]+')
49 | elif leftmost.startswith('xn--') or hostname.startswith('xn--'):
50 | # RFC 6125, section 6.4.3, subitem 3.
51 | # The client SHOULD NOT attempt to match a presented identifier
52 | # where the wildcard character is embedded within an A-label or
53 | # U-label of an internationalized domain name.
54 | pats.append(re.escape(leftmost))
55 | else:
56 | # Otherwise, '*' matches any dotless string, e.g. www*
57 | pats.append(re.escape(leftmost).replace(r'\*', '[^.]*'))
58 |
59 | # add the remaining fragments, ignore any wildcards
60 | for frag in remainder:
61 | pats.append(re.escape(frag))
62 |
63 | pat = re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE)
64 | return pat.match(hostname)
65 |
66 |
67 | def match_hostname(cert, hostname):
68 | """Verify that *cert* (in decoded format as returned by
69 | SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
70 | rules are followed, but IP addresses are not accepted for *hostname*.
71 |
72 | CertificateError is raised on failure. On success, the function
73 | returns nothing.
74 | """
75 | if not cert:
76 | raise ValueError("empty or no certificate")
77 | dnsnames = []
78 | san = cert.get('subjectAltName', ())
79 | for key, value in san:
80 | if key == 'DNS':
81 | if _dnsname_match(value, hostname):
82 | return
83 | dnsnames.append(value)
84 | if not dnsnames:
85 | # The subject is only checked when there is no dNSName entry
86 | # in subjectAltName
87 | for sub in cert.get('subject', ()):
88 | for key, value in sub:
89 | # XXX according to RFC 2818, the most specific Common Name
90 | # must be used.
91 | if key == 'commonName':
92 | if _dnsname_match(value, hostname):
93 | return
94 | dnsnames.append(value)
95 | if len(dnsnames) > 1:
96 | raise CertificateError("hostname %r "
97 | "doesn't match either of %s"
98 | % (hostname, ', '.join(map(repr, dnsnames))))
99 | elif len(dnsnames) == 1:
100 | raise CertificateError("hostname %r "
101 | "doesn't match %r"
102 | % (hostname, dnsnames[0]))
103 | else:
104 | raise CertificateError("no appropriate commonName or "
105 | "subjectAltName fields were found")
106 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr/ip/nmap.py:
--------------------------------------------------------------------------------
1 | #-----------------------------------------------------------------------------
2 | # Copyright (c) 2008-2015, David P. D. Moss. All rights reserved.
3 | #
4 | # Released under the BSD license. See the LICENSE file for details.
5 | #-----------------------------------------------------------------------------
6 | """
7 | Routines for dealing with nmap-style IPv4 address ranges.
8 |
9 | Based on nmap's Target Specification :-
10 |
11 | http://nmap.org/book/man-target-specification.html
12 | """
13 |
14 | from netaddr.core import AddrFormatError
15 | from netaddr.ip import IPAddress, IPNetwork
16 | from netaddr.compat import _iter_range, _is_str, _iter_next
17 |
18 |
19 | def _nmap_octet_target_values(spec):
20 | # Generates sequence of values for an individual octet as defined in the
21 | # nmap Target Specification.
22 | values = set()
23 |
24 | for element in spec.split(','):
25 | if '-' in element:
26 | left, right = element.split('-', 1)
27 | if not left:
28 | left = 0
29 | if not right:
30 | right = 255
31 | low = int(left)
32 | high = int(right)
33 | if not ((0 <= low <= 255) and (0 <= high <= 255)):
34 | raise ValueError('octet value overflow for spec %s!' % spec)
35 | if low > high:
36 | raise ValueError('left side of hyphen must be <= right %r' % element)
37 | for octet in _iter_range(low, high + 1):
38 | values.add(octet)
39 | else:
40 | octet = int(element)
41 | if not (0 <= octet <= 255):
42 | raise ValueError('octet value overflow for spec %s!' % spec)
43 | values.add(octet)
44 |
45 | return sorted(values)
46 |
47 |
48 | def _generate_nmap_octet_ranges(nmap_target_spec):
49 | # Generate 4 lists containing all octets defined by a given nmap Target
50 | # specification.
51 | if not _is_str(nmap_target_spec):
52 | raise TypeError('string expected, not %s' % type(nmap_target_spec))
53 |
54 | if not nmap_target_spec:
55 | raise ValueError('nmap target specification cannot be blank!')
56 |
57 | tokens = nmap_target_spec.split('.')
58 |
59 | if len(tokens) != 4:
60 | raise AddrFormatError('invalid nmap range: %s' % nmap_target_spec)
61 |
62 | return (_nmap_octet_target_values(tokens[0]),
63 | _nmap_octet_target_values(tokens[1]),
64 | _nmap_octet_target_values(tokens[2]),
65 | _nmap_octet_target_values(tokens[3]))
66 |
67 |
68 | def _parse_nmap_target_spec(target_spec):
69 | if '/' in target_spec:
70 | _, prefix = target_spec.split('/', 1)
71 | if not (0 < int(prefix) < 33):
72 | raise AddrFormatError('CIDR prefix expected, not %s' % prefix)
73 | net = IPNetwork(target_spec)
74 | if net.version != 4:
75 | raise AddrFormatError('CIDR only support for IPv4!')
76 | for ip in net:
77 | yield ip
78 | elif ':' in target_spec:
79 | # nmap only currently supports IPv6 addresses without prefixes.
80 | yield IPAddress(target_spec)
81 | else:
82 | octet_ranges = _generate_nmap_octet_ranges(target_spec)
83 | for w in octet_ranges[0]:
84 | for x in octet_ranges[1]:
85 | for y in octet_ranges[2]:
86 | for z in octet_ranges[3]:
87 | yield IPAddress("%d.%d.%d.%d" % (w, x, y, z), 4)
88 |
89 |
90 | def valid_nmap_range(target_spec):
91 | """
92 | :param target_spec: an nmap-style IP range target specification.
93 |
94 | :return: ``True`` if IP range target spec is valid, ``False`` otherwise.
95 | """
96 | try:
97 | _iter_next(_parse_nmap_target_spec(target_spec))
98 | return True
99 | except (TypeError, ValueError, AddrFormatError):
100 | pass
101 | return False
102 |
103 |
104 | def iter_nmap_range(*nmap_target_spec):
105 | """
106 | An generator that yields IPAddress objects from defined by nmap target
107 | specifications.
108 |
109 | See https://nmap.org/book/man-target-specification.html for details.
110 |
111 | :param *nmap_target_spec: one or more nmap IP range target specification.
112 |
113 | :return: an iterator producing IPAddress objects for each IP in the target spec(s).
114 | """
115 | for target_spec in nmap_target_spec:
116 | for addr in _parse_nmap_target_spec(target_spec):
117 | yield addr
118 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/netaddr-0.7.18.dist-info/METADATA:
--------------------------------------------------------------------------------
1 | Metadata-Version: 2.0
2 | Name: netaddr
3 | Version: 0.7.18
4 | Summary: A network address manipulation library for Python
5 | Home-page: https://github.com/drkjam/netaddr/
6 | Author: David P. D. Moss
7 | Author-email: drkjam@gmail.com
8 | License: BSD License
9 | Download-URL: https://pypi.python.org/pypi/netaddr/
10 | Keywords: Networking,Systems Administration,IANA,IEEE,CIDR,IP,IPv4,IPv6,CIDR,EUI,MAC,MAC-48,EUI-48,EUI-64
11 | Platform: OS Independent
12 | Classifier: Development Status :: 5 - Production/Stable
13 | Classifier: Environment :: Console
14 | Classifier: Intended Audience :: Developers
15 | Classifier: Intended Audience :: Education
16 | Classifier: Intended Audience :: Information Technology
17 | Classifier: Intended Audience :: Science/Research
18 | Classifier: Intended Audience :: System Administrators
19 | Classifier: Intended Audience :: Telecommunications Industry
20 | Classifier: License :: OSI Approved :: BSD License
21 | Classifier: License :: OSI Approved :: MIT License
22 | Classifier: Natural Language :: English
23 | Classifier: Operating System :: OS Independent
24 | Classifier: Programming Language :: Python
25 | Classifier: Programming Language :: Python :: 2
26 | Classifier: Programming Language :: Python :: 2.5
27 | Classifier: Programming Language :: Python :: 2.6
28 | Classifier: Programming Language :: Python :: 2.7
29 | Classifier: Programming Language :: Python :: 3
30 | Classifier: Programming Language :: Python :: 3.0
31 | Classifier: Programming Language :: Python :: 3.1
32 | Classifier: Programming Language :: Python :: 3.2
33 | Classifier: Programming Language :: Python :: 3.3
34 | Classifier: Programming Language :: Python :: 3.4
35 | Classifier: Programming Language :: Python :: 3.5
36 | Classifier: Topic :: Communications
37 | Classifier: Topic :: Documentation
38 | Classifier: Topic :: Education
39 | Classifier: Topic :: Education :: Testing
40 | Classifier: Topic :: Home Automation
41 | Classifier: Topic :: Internet
42 | Classifier: Topic :: Internet :: Log Analysis
43 | Classifier: Topic :: Internet :: Name Service (DNS)
44 | Classifier: Topic :: Internet :: Proxy Servers
45 | Classifier: Topic :: Internet :: WWW/HTTP
46 | Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
47 | Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
48 | Classifier: Topic :: Security
49 | Classifier: Topic :: Software Development
50 | Classifier: Topic :: Software Development :: Libraries
51 | Classifier: Topic :: Software Development :: Libraries :: Python Modules
52 | Classifier: Topic :: Software Development :: Quality Assurance
53 | Classifier: Topic :: Software Development :: Testing
54 | Classifier: Topic :: Software Development :: Testing :: Traffic Generation
55 | Classifier: Topic :: System :: Benchmark
56 | Classifier: Topic :: System :: Clustering
57 | Classifier: Topic :: System :: Distributed Computing
58 | Classifier: Topic :: System :: Installation/Setup
59 | Classifier: Topic :: System :: Logging
60 | Classifier: Topic :: System :: Monitoring
61 | Classifier: Topic :: System :: Networking
62 | Classifier: Topic :: System :: Networking :: Firewalls
63 | Classifier: Topic :: System :: Networking :: Monitoring
64 | Classifier: Topic :: System :: Networking :: Time Synchronization
65 | Classifier: Topic :: System :: Recovery Tools
66 | Classifier: Topic :: System :: Shells
67 | Classifier: Topic :: System :: Software Distribution
68 | Classifier: Topic :: System :: Systems Administration
69 | Classifier: Topic :: System :: System Shells
70 | Classifier: Topic :: Text Processing
71 | Classifier: Topic :: Text Processing :: Filters
72 | Classifier: Topic :: Utilities
73 |
74 | Provides provides support for:
75 |
76 | Layer 3 addresses
77 |
78 | - IPv4 and IPv6 addresses, subnets, masks, prefixes
79 | - iterating, slicing, sorting, summarizing and classifying IP networks
80 | - dealing with various ranges formats (CIDR, arbitrary ranges and globs, nmap)
81 | - set based operations (unions, intersections etc) over IP addresses and subnets
82 | - parsing a large variety of different formats and notations
83 | - looking up IANA IP block information
84 | - generating DNS reverse lookups
85 | - supernetting and subnetting
86 |
87 | Layer 2 addresses
88 |
89 | - representation and manipulation MAC addresses and EUI-64 identifiers
90 | - looking up IEEE organisational information (OUI, IAB)
91 | - generating derived IPv6 addresses
92 |
93 | Changes
94 | -------
95 |
96 | For details on the latest updates and changes, see
97 |
98 | https://github.com/drkjam/netaddr/blob/rel-0.7.x/CHANGELOG
99 |
100 | Documentation
101 | -------------
102 | - https://pythonhosted.org/netaddr/
103 | - https://netaddr.readthedocs.org/en/latest/
104 |
105 |
106 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/contrib/ntlmpool.py:
--------------------------------------------------------------------------------
1 | """
2 | NTLM authenticating pool, contributed by erikcederstran
3 |
4 | Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10
5 | """
6 | from __future__ import absolute_import
7 |
8 | try:
9 | from http.client import HTTPSConnection
10 | except ImportError:
11 | from httplib import HTTPSConnection
12 | from logging import getLogger
13 | from ntlm import ntlm
14 |
15 | from urllib3 import HTTPSConnectionPool
16 |
17 |
18 | log = getLogger(__name__)
19 |
20 |
21 | class NTLMConnectionPool(HTTPSConnectionPool):
22 | """
23 | Implements an NTLM authentication version of an urllib3 connection pool
24 | """
25 |
26 | scheme = 'https'
27 |
28 | def __init__(self, user, pw, authurl, *args, **kwargs):
29 | """
30 | authurl is a random URL on the server that is protected by NTLM.
31 | user is the Windows user, probably in the DOMAIN\\username format.
32 | pw is the password for the user.
33 | """
34 | super(NTLMConnectionPool, self).__init__(*args, **kwargs)
35 | self.authurl = authurl
36 | self.rawuser = user
37 | user_parts = user.split('\\', 1)
38 | self.domain = user_parts[0].upper()
39 | self.user = user_parts[1]
40 | self.pw = pw
41 |
42 | def _new_conn(self):
43 | # Performs the NTLM handshake that secures the connection. The socket
44 | # must be kept open while requests are performed.
45 | self.num_connections += 1
46 | log.debug('Starting NTLM HTTPS connection no. %d: https://%s%s',
47 | self.num_connections, self.host, self.authurl)
48 |
49 | headers = {}
50 | headers['Connection'] = 'Keep-Alive'
51 | req_header = 'Authorization'
52 | resp_header = 'www-authenticate'
53 |
54 | conn = HTTPSConnection(host=self.host, port=self.port)
55 |
56 | # Send negotiation message
57 | headers[req_header] = (
58 | 'NTLM %s' % ntlm.create_NTLM_NEGOTIATE_MESSAGE(self.rawuser))
59 | log.debug('Request headers: %s', headers)
60 | conn.request('GET', self.authurl, None, headers)
61 | res = conn.getresponse()
62 | reshdr = dict(res.getheaders())
63 | log.debug('Response status: %s %s', res.status, res.reason)
64 | log.debug('Response headers: %s', reshdr)
65 | log.debug('Response data: %s [...]', res.read(100))
66 |
67 | # Remove the reference to the socket, so that it can not be closed by
68 | # the response object (we want to keep the socket open)
69 | res.fp = None
70 |
71 | # Server should respond with a challenge message
72 | auth_header_values = reshdr[resp_header].split(', ')
73 | auth_header_value = None
74 | for s in auth_header_values:
75 | if s[:5] == 'NTLM ':
76 | auth_header_value = s[5:]
77 | if auth_header_value is None:
78 | raise Exception('Unexpected %s response header: %s' %
79 | (resp_header, reshdr[resp_header]))
80 |
81 | # Send authentication message
82 | ServerChallenge, NegotiateFlags = \
83 | ntlm.parse_NTLM_CHALLENGE_MESSAGE(auth_header_value)
84 | auth_msg = ntlm.create_NTLM_AUTHENTICATE_MESSAGE(ServerChallenge,
85 | self.user,
86 | self.domain,
87 | self.pw,
88 | NegotiateFlags)
89 | headers[req_header] = 'NTLM %s' % auth_msg
90 | log.debug('Request headers: %s', headers)
91 | conn.request('GET', self.authurl, None, headers)
92 | res = conn.getresponse()
93 | log.debug('Response status: %s %s', res.status, res.reason)
94 | log.debug('Response headers: %s', dict(res.getheaders()))
95 | log.debug('Response data: %s [...]', res.read()[:100])
96 | if res.status != 200:
97 | if res.status == 401:
98 | raise Exception('Server rejected request: wrong '
99 | 'username or password')
100 | raise Exception('Wrong server response: %s %s' %
101 | (res.status, res.reason))
102 |
103 | res.fp = None
104 | log.debug('Connection established')
105 | return conn
106 |
107 | def urlopen(self, method, url, body=None, headers=None, retries=3,
108 | redirect=True, assert_same_host=True):
109 | if headers is None:
110 | headers = {}
111 | headers['Connection'] = 'Keep-Alive'
112 | return super(NTLMConnectionPool, self).urlopen(method, url, body,
113 | headers, retries,
114 | redirect,
115 | assert_same_host)
116 |
--------------------------------------------------------------------------------
/110-SelfServicePortal/Business/support.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
12 |
16 |
17 |
18 |
19 |
Wordpress Hosting Inc - Provisioning POC
20 |
21 |
22 |
47 |
75 |
90 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/204-CrossStackReferences/sharedinfrastructure.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Parameters:
3 | vpccidr:
4 | Type: String
5 | MinLength: 9
6 | MaxLength: 18
7 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
8 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/16
9 | Default: 10.20.0.0/16
10 | psharedacidr:
11 | Type: String
12 | MinLength: 9
13 | MaxLength: 18
14 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
15 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
16 | Default: 10.20.0.0/22
17 | psharedbcidr:
18 | Type: String
19 | MinLength: 9
20 | MaxLength: 18
21 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
22 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
23 | Default: 10.20.4.0/22
24 | Resources:
25 | VPC:
26 | Type: "AWS::EC2::VPC"
27 | Properties:
28 | CidrBlock: !Ref vpccidr
29 | IGW:
30 | Type: "AWS::EC2::InternetGateway"
31 | S3AppBucket:
32 | DeletionPolicy: Retain
33 | Type: "AWS::S3::Bucket"
34 | Properties:
35 | AccessControl: PublicRead
36 | WebsiteConfiguration:
37 | ErrorDocument: index.html
38 | IndexDocument: index.html
39 | BucketPolicyApp:
40 | Type: "AWS::S3::BucketPolicy"
41 | Properties:
42 | Bucket: !Ref S3AppBucket
43 | PolicyDocument:
44 | Statement:
45 | -
46 | Sid: "ABC123"
47 | Action:
48 | - "s3:GetObject"
49 | Effect: Allow
50 | Resource: !Join ["", ["arn:aws:s3:::", !Ref S3AppBucket, "/*"]]
51 | Principal:
52 | AWS:
53 | - "*"
54 | GatewayAttach:
55 | Type: "AWS::EC2::VPCGatewayAttachment"
56 | Properties:
57 | InternetGatewayId: !Ref IGW
58 | VpcId: !Ref VPC
59 | SubnetPublicSharedA:
60 | Type: "AWS::EC2::Subnet"
61 | Properties:
62 | AvailabilityZone: !Select [0, !GetAZs ]
63 | CidrBlock: !Ref psharedacidr
64 | MapPublicIpOnLaunch: true
65 | VpcId: !Ref VPC
66 | SubnetPublicSharedB:
67 | Type: "AWS::EC2::Subnet"
68 | Properties:
69 | AvailabilityZone: !Select [1, !GetAZs ]
70 | CidrBlock: !Ref psharedbcidr
71 | MapPublicIpOnLaunch: true
72 | VpcId: !Ref VPC
73 | SubnetRouteTableAssociatePublicA:
74 | Type: "AWS::EC2::SubnetRouteTableAssociation"
75 | Properties:
76 | RouteTableId: !Ref RouteTablePublic
77 | SubnetId: !Ref SubnetPublicSharedA
78 | SubnetRouteTableAssociatePublicB:
79 | Type: "AWS::EC2::SubnetRouteTableAssociation"
80 | Properties:
81 | RouteTableId: !Ref RouteTablePublic
82 | SubnetId: !Ref SubnetPublicSharedB
83 | RouteDefaultPublic:
84 | Type: "AWS::EC2::Route"
85 | DependsOn: GatewayAttach
86 | Properties:
87 | DestinationCidrBlock: 0.0.0.0/0
88 | GatewayId: !Ref IGW
89 | RouteTableId: !Ref RouteTablePublic
90 | RouteDefaultPrivateA:
91 | Type: "AWS::EC2::Route"
92 | Properties:
93 | DestinationCidrBlock: 0.0.0.0/0
94 | NatGatewayId: !Ref NatGatewayA
95 | RouteTableId: !Ref RouteTablePrivateA
96 | RouteDefaultPrivateB:
97 | Type: "AWS::EC2::Route"
98 | Properties:
99 | DestinationCidrBlock: 0.0.0.0/0
100 | NatGatewayId: !Ref NatGatewayB
101 | RouteTableId: !Ref RouteTablePrivateB
102 | RouteTablePublic:
103 | Type: "AWS::EC2::RouteTable"
104 | Properties:
105 | VpcId: !Ref VPC
106 | RouteTablePrivateA:
107 | Type: "AWS::EC2::RouteTable"
108 | Properties:
109 | VpcId: !Ref VPC
110 | RouteTablePrivateB:
111 | Type: "AWS::EC2::RouteTable"
112 | Properties:
113 | VpcId: !Ref VPC
114 | EIPNatGWA:
115 | DependsOn: GatewayAttach
116 | Type: "AWS::EC2::EIP"
117 | Properties:
118 | Domain: vpc
119 | EIPNatGWB:
120 | DependsOn: GatewayAttach
121 | Type: "AWS::EC2::EIP"
122 | Properties:
123 | Domain: vpc
124 | NatGatewayA:
125 | Type: "AWS::EC2::NatGateway"
126 | Properties:
127 | AllocationId: !GetAtt EIPNatGWA.AllocationId
128 | SubnetId: !Ref SubnetPublicSharedA
129 | NatGatewayB:
130 | Type: "AWS::EC2::NatGateway"
131 | Properties:
132 | AllocationId: !GetAtt EIPNatGWB.AllocationId
133 | SubnetId: !Ref SubnetPublicSharedB
134 | Outputs:
135 | vpcid:
136 | Description: ID of Shared Infrastructure VPC
137 | Value: !Ref VPC
138 | natgatewayaid:
139 | Description: ID of NAT Gateway A
140 | Value: !Ref NatGatewayA
141 | natgatewaybid:
142 | Description: ID of NAT Gateway B
143 | Value: !Ref NatGatewayB
144 | publicroutetable:
145 | Description: ID of Public Route Table
146 | Value: !Ref RouteTablePublic
147 | privateroutetablea:
148 | Description: ID of Private Route Table - A
149 | Value: !Ref RouteTablePrivateA
150 | privateroutetableb:
151 | Description: ID of Private Route Table - B
152 | Value: !Ref RouteTablePrivateB
153 | appbucketurl:
154 | Description: Shared Infrastructure App Bucket
155 | Value: !GetAtt S3AppBucket.WebsiteURL
156 |
--------------------------------------------------------------------------------
/201-SharedInfrastructure/sharedinfrastructure-201.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Parameters:
3 | vpccidr:
4 | Type: String
5 | MinLength: 9
6 | MaxLength: 18
7 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
8 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/16
9 | Default: 10.20.0.0/16
10 | psharedacidr:
11 | Type: String
12 | MinLength: 9
13 | MaxLength: 18
14 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
15 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
16 | Default: 10.20.0.0/22
17 | psharedbcidr:
18 | Type: String
19 | MinLength: 9
20 | MaxLength: 18
21 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
22 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
23 | Default: 10.20.4.0/22
24 | Resources:
25 | VPC:
26 | Type: "AWS::EC2::VPC"
27 | Properties:
28 | CidrBlock: !Ref vpccidr
29 | IGW:
30 | Type: "AWS::EC2::InternetGateway"
31 | S3AppBucket:
32 | DeletionPolicy: Retain
33 | Type: "AWS::S3::Bucket"
34 | Properties:
35 | AccessControl: PublicRead
36 | WebsiteConfiguration:
37 | ErrorDocument: index.html
38 | IndexDocument: index.html
39 | BucketPolicyApp:
40 | Type: "AWS::S3::BucketPolicy"
41 | Properties:
42 | Bucket: !Ref S3AppBucket
43 | PolicyDocument:
44 | Statement:
45 | -
46 | Sid: "ABC123"
47 | Action:
48 | - "s3:GetObject"
49 | Effect: Allow
50 | Resource: !Join ["", ["arn:aws:s3:::", !Ref S3AppBucket, "/*"]]
51 | Principal:
52 | AWS:
53 | - "*"
54 | GatewayAttach:
55 | Type: "AWS::EC2::VPCGatewayAttachment"
56 | Properties:
57 | InternetGatewayId: !Ref IGW
58 | VpcId: !Ref VPC
59 | SubnetPublicSharedA:
60 | Type: "AWS::EC2::Subnet"
61 | Properties:
62 | AvailabilityZone: !Select [0, !GetAZs ]
63 | CidrBlock: !Ref psharedacidr
64 | MapPublicIpOnLaunch: true
65 | VpcId: !Ref VPC
66 | SubnetPublicSharedB:
67 | Type: "AWS::EC2::Subnet"
68 | Properties:
69 | AvailabilityZone: !Select [1, !GetAZs ]
70 | CidrBlock: !Ref psharedbcidr
71 | MapPublicIpOnLaunch: true
72 | VpcId: !Ref VPC
73 | SubnetRouteTableAssociatePublicA:
74 | Type: "AWS::EC2::SubnetRouteTableAssociation"
75 | Properties:
76 | RouteTableId: !Ref RouteTablePublic
77 | SubnetId: !Ref SubnetPublicSharedA
78 | SubnetRouteTableAssociatePublicB:
79 | Type: "AWS::EC2::SubnetRouteTableAssociation"
80 | Properties:
81 | RouteTableId: !Ref RouteTablePublic
82 | SubnetId: !Ref SubnetPublicSharedB
83 | RouteDefaultPublic:
84 | Type: "AWS::EC2::Route"
85 | DependsOn: GatewayAttach
86 | Properties:
87 | DestinationCidrBlock: 0.0.0.0/0
88 | GatewayId: !Ref IGW
89 | RouteTableId: !Ref RouteTablePublic
90 | RouteDefaultPrivateA:
91 | Type: "AWS::EC2::Route"
92 | Properties:
93 | DestinationCidrBlock: 0.0.0.0/0
94 | NatGatewayId: !Ref NatGatewayA
95 | RouteTableId: !Ref RouteTablePrivateA
96 | RouteDefaultPrivateB:
97 | Type: "AWS::EC2::Route"
98 | Properties:
99 | DestinationCidrBlock: 0.0.0.0/0
100 | NatGatewayId: !Ref NatGatewayB
101 | RouteTableId: !Ref RouteTablePrivateB
102 | RouteTablePublic:
103 | Type: "AWS::EC2::RouteTable"
104 | Properties:
105 | VpcId: !Ref VPC
106 | RouteTablePrivateA:
107 | Type: "AWS::EC2::RouteTable"
108 | Properties:
109 | VpcId: !Ref VPC
110 | RouteTablePrivateB:
111 | Type: "AWS::EC2::RouteTable"
112 | Properties:
113 | VpcId: !Ref VPC
114 | EIPNatGWA:
115 | DependsOn: GatewayAttach
116 | Type: "AWS::EC2::EIP"
117 | Properties:
118 | Domain: vpc
119 | EIPNatGWB:
120 | DependsOn: GatewayAttach
121 | Type: "AWS::EC2::EIP"
122 | Properties:
123 | Domain: vpc
124 | NatGatewayA:
125 | Type: "AWS::EC2::NatGateway"
126 | Properties:
127 | AllocationId: !GetAtt EIPNatGWA.AllocationId
128 | SubnetId: !Ref SubnetPublicSharedA
129 | NatGatewayB:
130 | Type: "AWS::EC2::NatGateway"
131 | Properties:
132 | AllocationId: !GetAtt EIPNatGWB.AllocationId
133 | SubnetId: !Ref SubnetPublicSharedB
134 | Outputs:
135 | vpcid:
136 | Description: ID of Shared Infrastructure VPC
137 | Value: !Ref VPC
138 | natgatewayaid:
139 | Description: ID of NAT Gateway A
140 | Value: !Ref NatGatewayA
141 | natgatewaybid:
142 | Description: ID of NAT Gateway B
143 | Value: !Ref NatGatewayB
144 | publicroutetable:
145 | Description: ID of Public Route Table
146 | Value: !Ref RouteTablePublic
147 | privateroutetablea:
148 | Description: ID of Private Route Table - A
149 | Value: !Ref RouteTablePrivateA
150 | privateroutetableb:
151 | Description: ID of Private Route Table - B
152 | Value: !Ref RouteTablePrivateB
153 | appbucketurl:
154 | Description: Shared Infrastructure App Bucket
155 | Value: !GetAtt S3AppBucket.WebsiteURL
156 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/sbcharsetprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | #
13 | # This library is free software; you can redistribute it and/or
14 | # modify it under the terms of the GNU Lesser General Public
15 | # License as published by the Free Software Foundation; either
16 | # version 2.1 of the License, or (at your option) any later version.
17 | #
18 | # This library is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 | # Lesser General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU Lesser General Public
24 | # License along with this library; if not, write to the Free Software
25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 | # 02110-1301 USA
27 | ######################### END LICENSE BLOCK #########################
28 |
29 | import sys
30 | from . import constants
31 | from .charsetprober import CharSetProber
32 | from .compat import wrap_ord
33 |
34 | SAMPLE_SIZE = 64
35 | SB_ENOUGH_REL_THRESHOLD = 1024
36 | POSITIVE_SHORTCUT_THRESHOLD = 0.95
37 | NEGATIVE_SHORTCUT_THRESHOLD = 0.05
38 | SYMBOL_CAT_ORDER = 250
39 | NUMBER_OF_SEQ_CAT = 4
40 | POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 1
41 | #NEGATIVE_CAT = 0
42 |
43 |
44 | class SingleByteCharSetProber(CharSetProber):
45 | def __init__(self, model, reversed=False, nameProber=None):
46 | CharSetProber.__init__(self)
47 | self._mModel = model
48 | # TRUE if we need to reverse every pair in the model lookup
49 | self._mReversed = reversed
50 | # Optional auxiliary prober for name decision
51 | self._mNameProber = nameProber
52 | self.reset()
53 |
54 | def reset(self):
55 | CharSetProber.reset(self)
56 | # char order of last character
57 | self._mLastOrder = 255
58 | self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT
59 | self._mTotalSeqs = 0
60 | self._mTotalChar = 0
61 | # characters that fall in our sampling range
62 | self._mFreqChar = 0
63 |
64 | def get_charset_name(self):
65 | if self._mNameProber:
66 | return self._mNameProber.get_charset_name()
67 | else:
68 | return self._mModel['charsetName']
69 |
70 | def feed(self, aBuf):
71 | if not self._mModel['keepEnglishLetter']:
72 | aBuf = self.filter_without_english_letters(aBuf)
73 | aLen = len(aBuf)
74 | if not aLen:
75 | return self.get_state()
76 | for c in aBuf:
77 | order = self._mModel['charToOrderMap'][wrap_ord(c)]
78 | if order < SYMBOL_CAT_ORDER:
79 | self._mTotalChar += 1
80 | if order < SAMPLE_SIZE:
81 | self._mFreqChar += 1
82 | if self._mLastOrder < SAMPLE_SIZE:
83 | self._mTotalSeqs += 1
84 | if not self._mReversed:
85 | i = (self._mLastOrder * SAMPLE_SIZE) + order
86 | model = self._mModel['precedenceMatrix'][i]
87 | else: # reverse the order of the letters in the lookup
88 | i = (order * SAMPLE_SIZE) + self._mLastOrder
89 | model = self._mModel['precedenceMatrix'][i]
90 | self._mSeqCounters[model] += 1
91 | self._mLastOrder = order
92 |
93 | if self.get_state() == constants.eDetecting:
94 | if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD:
95 | cf = self.get_confidence()
96 | if cf > POSITIVE_SHORTCUT_THRESHOLD:
97 | if constants._debug:
98 | sys.stderr.write('%s confidence = %s, we have a'
99 | 'winner\n' %
100 | (self._mModel['charsetName'], cf))
101 | self._mState = constants.eFoundIt
102 | elif cf < NEGATIVE_SHORTCUT_THRESHOLD:
103 | if constants._debug:
104 | sys.stderr.write('%s confidence = %s, below negative'
105 | 'shortcut threshhold %s\n' %
106 | (self._mModel['charsetName'], cf,
107 | NEGATIVE_SHORTCUT_THRESHOLD))
108 | self._mState = constants.eNotMe
109 |
110 | return self.get_state()
111 |
112 | def get_confidence(self):
113 | r = 0.01
114 | if self._mTotalSeqs > 0:
115 | r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs
116 | / self._mModel['mTypicalPositiveRatio'])
117 | r = r * self._mFreqChar / self._mTotalChar
118 | if r >= 1.0:
119 | r = 0.99
120 | return r
121 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/urllib3/util/connection.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | import socket
3 | try:
4 | from select import poll, POLLIN
5 | except ImportError: # `poll` doesn't exist on OSX and other platforms
6 | poll = False
7 | try:
8 | from select import select
9 | except ImportError: # `select` doesn't exist on AppEngine.
10 | select = False
11 |
12 |
13 | def is_connection_dropped(conn): # Platform-specific
14 | """
15 | Returns True if the connection is dropped and should be closed.
16 |
17 | :param conn:
18 | :class:`httplib.HTTPConnection` object.
19 |
20 | Note: For platforms like AppEngine, this will always return ``False`` to
21 | let the platform handle connection recycling transparently for us.
22 | """
23 | sock = getattr(conn, 'sock', False)
24 | if sock is False: # Platform-specific: AppEngine
25 | return False
26 | if sock is None: # Connection already closed (such as by httplib).
27 | return True
28 |
29 | if not poll:
30 | if not select: # Platform-specific: AppEngine
31 | return False
32 |
33 | try:
34 | return select([sock], [], [], 0.0)[0]
35 | except socket.error:
36 | return True
37 |
38 | # This version is better on platforms that support it.
39 | p = poll()
40 | p.register(sock, POLLIN)
41 | for (fno, ev) in p.poll(0.0):
42 | if fno == sock.fileno():
43 | # Either data is buffered (bad), or the connection is dropped.
44 | return True
45 |
46 |
47 | # This function is copied from socket.py in the Python 2.7 standard
48 | # library test suite. Added to its signature is only `socket_options`.
49 | # One additional modification is that we avoid binding to IPv6 servers
50 | # discovered in DNS if the system doesn't have IPv6 functionality.
51 | def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
52 | source_address=None, socket_options=None):
53 | """Connect to *address* and return the socket object.
54 |
55 | Convenience function. Connect to *address* (a 2-tuple ``(host,
56 | port)``) and return the socket object. Passing the optional
57 | *timeout* parameter will set the timeout on the socket instance
58 | before attempting to connect. If no *timeout* is supplied, the
59 | global default timeout setting returned by :func:`getdefaulttimeout`
60 | is used. If *source_address* is set it must be a tuple of (host, port)
61 | for the socket to bind as a source address before making the connection.
62 | An host of '' or port 0 tells the OS to use the default.
63 | """
64 |
65 | host, port = address
66 | if host.startswith('['):
67 | host = host.strip('[]')
68 | err = None
69 |
70 | # Using the value from allowed_gai_family() in the context of getaddrinfo lets
71 | # us select whether to work with IPv4 DNS records, IPv6 records, or both.
72 | # The original create_connection function always returns all records.
73 | family = allowed_gai_family()
74 |
75 | for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
76 | af, socktype, proto, canonname, sa = res
77 | sock = None
78 | try:
79 | sock = socket.socket(af, socktype, proto)
80 |
81 | # If provided, set socket level options before connecting.
82 | _set_socket_options(sock, socket_options)
83 |
84 | if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
85 | sock.settimeout(timeout)
86 | if source_address:
87 | sock.bind(source_address)
88 | sock.connect(sa)
89 | return sock
90 |
91 | except socket.error as e:
92 | err = e
93 | if sock is not None:
94 | sock.close()
95 | sock = None
96 |
97 | if err is not None:
98 | raise err
99 |
100 | raise socket.error("getaddrinfo returns an empty list")
101 |
102 |
103 | def _set_socket_options(sock, options):
104 | if options is None:
105 | return
106 |
107 | for opt in options:
108 | sock.setsockopt(*opt)
109 |
110 |
111 | def allowed_gai_family():
112 | """This function is designed to work in the context of
113 | getaddrinfo, where family=socket.AF_UNSPEC is the default and
114 | will perform a DNS search for both IPv6 and IPv4 records."""
115 |
116 | family = socket.AF_INET
117 | if HAS_IPV6:
118 | family = socket.AF_UNSPEC
119 | return family
120 |
121 |
122 | def _has_ipv6(host):
123 | """ Returns True if the system can bind an IPv6 address. """
124 | sock = None
125 | has_ipv6 = False
126 |
127 | if socket.has_ipv6:
128 | # has_ipv6 returns true if cPython was compiled with IPv6 support.
129 | # It does not tell us if the system has IPv6 support enabled. To
130 | # determine that we must bind to an IPv6 address.
131 | # https://github.com/shazow/urllib3/pull/611
132 | # https://bugs.python.org/issue658327
133 | try:
134 | sock = socket.socket(socket.AF_INET6)
135 | sock.bind((host, 0))
136 | has_ipv6 = True
137 | except Exception:
138 | pass
139 |
140 | if sock:
141 | sock.close()
142 | return has_ipv6
143 |
144 | HAS_IPV6 = _has_ipv6('::1')
145 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet.json:
--------------------------------------------------------------------------------
1 | {
2 | "Resources" : {
3 | "AutoSubnetTable" : {
4 | "Type" : "AWS::DynamoDB::Table",
5 | "Properties" : {
6 | "AttributeDefinitions" : [
7 | {
8 | "AttributeName" : "Cidr",
9 | "AttributeType" : "S"
10 | },
11 | {
12 | "AttributeName" : "StackId",
13 | "AttributeType" : "S"
14 | }
15 | ],
16 | "KeySchema" :
17 | [
18 | {
19 | "AttributeName" : "Cidr",
20 | "KeyType" : "HASH"
21 | }
22 | ],
23 | "ProvisionedThroughput" : {
24 | "ReadCapacityUnits" : "5",
25 | "WriteCapacityUnits" : "5"
26 | },
27 | "GlobalSecondaryIndexes" : [
28 | {
29 | "IndexName" : "rangesforstack",
30 | "KeySchema" : [
31 | {
32 | "AttributeName" : "StackId",
33 | "KeyType" : "HASH"
34 | }
35 | ],
36 | "Projection" : {
37 | "ProjectionType" : "ALL"
38 | },
39 | "ProvisionedThroughput" : {
40 | "ReadCapacityUnits" : "5",
41 | "WriteCapacityUnits" : "5"
42 | }
43 | }
44 | ]
45 | }
46 | },
47 | "IAMRole" : {
48 | "Type" : "AWS::IAM::Role",
49 | "Properties" : {
50 | "AssumeRolePolicyDocument" : {
51 | "Version" : "2012-10-17",
52 | "Statement" : [
53 | {
54 | "Effect" : "Allow",
55 | "Principal" : {
56 | "Service" : [
57 | "lambda.amazonaws.com"
58 | ]
59 | },
60 | "Action" : [
61 | "sts:AssumeRole"
62 | ]
63 | }
64 | ]
65 | },
66 | "Path" : "/"
67 | }
68 | },
69 | "IAMPolicy" : {
70 | "Type" : "AWS::IAM::Policy",
71 | "DependsOn" : [
72 | "IAMRole"
73 | ],
74 | "Properties" : {
75 | "PolicyName" : "autosubnetrole",
76 | "Roles" : [
77 | {"Ref" : "IAMRole"}
78 | ],
79 | "PolicyDocument" : {
80 | "Version" : "2012-10-17",
81 | "Statement" : [
82 | {
83 | "Effect" : "Allow",
84 | "Action" : [
85 | "logs:*"
86 | ],
87 | "Resource" : [
88 | "arn:aws:logs:*:*:*"
89 | ]
90 | },
91 | {
92 | "Effect" : "Allow",
93 | "Action" : [
94 | "dynamodb:*"
95 | ],
96 | "Resource" : [
97 | {"Fn::Join" : ["",["arn:aws:dynamodb:", {"Ref" : "AWS::Region"}, ":", {"Ref": "AWS::AccountId"}, ":table/", {"Ref" : "AutoSubnetTable"}]]},
98 | {"Fn::Join" : ["",["arn:aws:dynamodb:", {"Ref" : "AWS::Region"}, ":", {"Ref": "AWS::AccountId"}, ":table/", {"Ref" : "AutoSubnetTable"},"/index/*"]]}
99 | ]
100 | }
101 | ]
102 | }
103 | }
104 | },
105 | "subnetpicker" : {
106 | "Type" : "AWS::Lambda::Function",
107 | "DependsOn" : [
108 | "IAMRole",
109 | "IAMPolicy"
110 | ],
111 | "Properties" : {
112 | "Role" : {"Fn::GetAtt" : ["IAMRole", "Arn"]},
113 | "Code" : {
114 | "S3Bucket" : {"Fn::ImportValue" : "sharedinf-lambdabucketname"},
115 | "S3Key" : "autosubnet.zip"
116 | },
117 | "Handler" : "autosubnet.handler",
118 | "Runtime" : "python2.7",
119 | "Timeout" : "300",
120 | "MemorySize" : "128"
121 | }
122 | }
123 | },
124 | "Outputs" : {
125 | "autosubnetlambdaarn" : {
126 | "Description" : "ARN of AutoSubnet Lambda",
127 | "Value" : {"Fn::GetAtt" : ["subnetpicker", "Arn"]},
128 | "Export" : {
129 | "Name" : "sharedinf-autosubnetarn"
130 | }
131 | },
132 | "autosubnettablename" : {
133 | "Description" : "Table Name of AutoSubnet DDB Table",
134 | "Value" : {"Ref" : "AutoSubnetTable"},
135 | "Export" : {
136 | "Name" : "sharedinf-autosubnetddbtablename"
137 | }
138 | }
139 | }
140 | }
--------------------------------------------------------------------------------
/204-CrossStackReferences/sharedinfrastructure2.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Parameters:
3 | vpccidr:
4 | Type: String
5 | MinLength: 9
6 | MaxLength: 18
7 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
8 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/16
9 | Default: 10.20.0.0/16
10 | psharedacidr:
11 | Type: String
12 | MinLength: 9
13 | MaxLength: 18
14 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
15 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
16 | Default: 10.20.0.0/22
17 | psharedbcidr:
18 | Type: String
19 | MinLength: 9
20 | MaxLength: 18
21 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
22 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
23 | Default: 10.20.4.0/22
24 | Resources:
25 | VPC:
26 | Type: "AWS::EC2::VPC"
27 | Properties:
28 | CidrBlock: !Ref vpccidr
29 | IGW:
30 | Type: "AWS::EC2::InternetGateway"
31 | S3AppBucket:
32 | DeletionPolicy: Retain
33 | Type: "AWS::S3::Bucket"
34 | Properties:
35 | AccessControl: PublicRead
36 | WebsiteConfiguration:
37 | ErrorDocument: index.html
38 | IndexDocument: index.html
39 | BucketPolicyApp:
40 | Type: "AWS::S3::BucketPolicy"
41 | Properties:
42 | Bucket: !Ref S3AppBucket
43 | PolicyDocument:
44 | Statement:
45 | -
46 | Sid: "ABC123"
47 | Action:
48 | - "s3:GetObject"
49 | Effect: Allow
50 | Resource: !Join ["", ["arn:aws:s3:::", !Ref S3AppBucket, "/*"]]
51 | Principal:
52 | AWS:
53 | - "*"
54 | GatewayAttach:
55 | Type: "AWS::EC2::VPCGatewayAttachment"
56 | Properties:
57 | InternetGatewayId: !Ref IGW
58 | VpcId: !Ref VPC
59 | SubnetPublicSharedA:
60 | Type: "AWS::EC2::Subnet"
61 | Properties:
62 | AvailabilityZone: !Select [0, !GetAZs ]
63 | CidrBlock: !Ref psharedacidr
64 | MapPublicIpOnLaunch: true
65 | VpcId: !Ref VPC
66 | SubnetPublicSharedB:
67 | Type: "AWS::EC2::Subnet"
68 | Properties:
69 | AvailabilityZone: !Select [1, !GetAZs ]
70 | CidrBlock: !Ref psharedbcidr
71 | MapPublicIpOnLaunch: true
72 | VpcId: !Ref VPC
73 | SubnetRouteTableAssociatePublicA:
74 | Type: "AWS::EC2::SubnetRouteTableAssociation"
75 | Properties:
76 | RouteTableId: !Ref RouteTablePublic
77 | SubnetId: !Ref SubnetPublicSharedA
78 | SubnetRouteTableAssociatePublicB:
79 | Type: "AWS::EC2::SubnetRouteTableAssociation"
80 | Properties:
81 | RouteTableId: !Ref RouteTablePublic
82 | SubnetId: !Ref SubnetPublicSharedB
83 | RouteDefaultPublic:
84 | Type: "AWS::EC2::Route"
85 | DependsOn: GatewayAttach
86 | Properties:
87 | DestinationCidrBlock: 0.0.0.0/0
88 | GatewayId: !Ref IGW
89 | RouteTableId: !Ref RouteTablePublic
90 | RouteDefaultPrivateA:
91 | Type: "AWS::EC2::Route"
92 | Properties:
93 | DestinationCidrBlock: 0.0.0.0/0
94 | NatGatewayId: !Ref NatGatewayA
95 | RouteTableId: !Ref RouteTablePrivateA
96 | RouteDefaultPrivateB:
97 | Type: "AWS::EC2::Route"
98 | Properties:
99 | DestinationCidrBlock: 0.0.0.0/0
100 | NatGatewayId: !Ref NatGatewayB
101 | RouteTableId: !Ref RouteTablePrivateB
102 | RouteTablePublic:
103 | Type: "AWS::EC2::RouteTable"
104 | Properties:
105 | VpcId: !Ref VPC
106 | RouteTablePrivateA:
107 | Type: "AWS::EC2::RouteTable"
108 | Properties:
109 | VpcId: !Ref VPC
110 | RouteTablePrivateB:
111 | Type: "AWS::EC2::RouteTable"
112 | Properties:
113 | VpcId: !Ref VPC
114 | EIPNatGWA:
115 | DependsOn: GatewayAttach
116 | Type: "AWS::EC2::EIP"
117 | Properties:
118 | Domain: vpc
119 | EIPNatGWB:
120 | DependsOn: GatewayAttach
121 | Type: "AWS::EC2::EIP"
122 | Properties:
123 | Domain: vpc
124 | NatGatewayA:
125 | Type: "AWS::EC2::NatGateway"
126 | Properties:
127 | AllocationId: !GetAtt EIPNatGWA.AllocationId
128 | SubnetId: !Ref SubnetPublicSharedA
129 | NatGatewayB:
130 | Type: "AWS::EC2::NatGateway"
131 | Properties:
132 | AllocationId: !GetAtt EIPNatGWB.AllocationId
133 | SubnetId: !Ref SubnetPublicSharedB
134 | Outputs:
135 | vpcid:
136 | Description: ID of Shared Infrastructure VPC
137 | Value: !Ref VPC
138 | Export: # added to export
139 | Name: sharedinf-vpcid
140 | natgatewayaid:
141 | Description: ID of NAT Gateway A
142 | Value: !Ref NatGatewayA
143 | natgatewaybid:
144 | Description: ID of NAT Gateway B
145 | Value: !Ref NatGatewayB
146 | publicroutetable:
147 | Description: ID of Public Route Table
148 | Value: !Ref RouteTablePublic
149 | Export: # added to export
150 | Name: sharedinf-publicrt
151 | privateroutetablea:
152 | Description: ID of Private Route Table - A
153 | Value: !Ref RouteTablePrivateA
154 | Export: # added to export
155 | Name: sharedinf-privaterta
156 | privateroutetableb:
157 | Description: ID of Private Route Table - B
158 | Value: !Ref RouteTablePrivateB
159 | Export: # added to export
160 | Name: sharedinf-privatertb
161 | appbucketurl:
162 | Description: Shared Infrastructure App Bucket
163 | Value: !GetAtt S3AppBucket.WebsiteURL
164 | Export: # added to export
165 | Name: sharedinf-appbucketurl
166 |
--------------------------------------------------------------------------------
/205-StackUpdateImprovements/sharedinfrastructure2.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Parameters:
3 | vpccidr:
4 | Type: String
5 | MinLength: 9
6 | MaxLength: 18
7 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
8 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/16
9 | Default: 10.20.0.0/16
10 | psharedacidr:
11 | Type: String
12 | MinLength: 9
13 | MaxLength: 18
14 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
15 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
16 | Default: 10.20.0.0/22
17 | psharedbcidr:
18 | Type: String
19 | MinLength: 9
20 | MaxLength: 18
21 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
22 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
23 | Default: 10.20.4.0/22
24 | Resources:
25 | VPC:
26 | Type: "AWS::EC2::VPC"
27 | Properties:
28 | CidrBlock: !Ref vpccidr
29 | IGW:
30 | Type: "AWS::EC2::InternetGateway"
31 | S3AppBucket:
32 | DeletionPolicy: Retain
33 | Type: "AWS::S3::Bucket"
34 | Properties:
35 | AccessControl: PublicRead
36 | WebsiteConfiguration:
37 | ErrorDocument: index.html
38 | IndexDocument: index.html
39 | BucketPolicyApp:
40 | Type: "AWS::S3::BucketPolicy"
41 | Properties:
42 | Bucket: !Ref S3AppBucket
43 | PolicyDocument:
44 | Statement:
45 | -
46 | Sid: "ABC123"
47 | Action:
48 | - "s3:GetObject"
49 | Effect: Allow
50 | Resource: !Join ["", ["arn:aws:s3:::", !Ref S3AppBucket, "/*"]]
51 | Principal:
52 | AWS:
53 | - "*"
54 | GatewayAttach:
55 | Type: "AWS::EC2::VPCGatewayAttachment"
56 | Properties:
57 | InternetGatewayId: !Ref IGW
58 | VpcId: !Ref VPC
59 | SubnetPublicSharedA:
60 | Type: "AWS::EC2::Subnet"
61 | Properties:
62 | AvailabilityZone: !Select [0, !GetAZs ]
63 | CidrBlock: !Ref psharedacidr
64 | MapPublicIpOnLaunch: true
65 | VpcId: !Ref VPC
66 | SubnetPublicSharedB:
67 | Type: "AWS::EC2::Subnet"
68 | Properties:
69 | AvailabilityZone: !Select [1, !GetAZs ]
70 | CidrBlock: !Ref psharedbcidr
71 | MapPublicIpOnLaunch: true
72 | VpcId: !Ref VPC
73 | SubnetRouteTableAssociatePublicA:
74 | Type: "AWS::EC2::SubnetRouteTableAssociation"
75 | Properties:
76 | RouteTableId: !Ref RouteTablePublic
77 | SubnetId: !Ref SubnetPublicSharedA
78 | SubnetRouteTableAssociatePublicB:
79 | Type: "AWS::EC2::SubnetRouteTableAssociation"
80 | Properties:
81 | RouteTableId: !Ref RouteTablePublic
82 | SubnetId: !Ref SubnetPublicSharedB
83 | RouteDefaultPublic:
84 | Type: "AWS::EC2::Route"
85 | DependsOn: GatewayAttach
86 | Properties:
87 | DestinationCidrBlock: 0.0.0.0/0
88 | GatewayId: !Ref IGW
89 | RouteTableId: !Ref RouteTablePublic
90 | RouteDefaultPrivateA:
91 | Type: "AWS::EC2::Route"
92 | Properties:
93 | DestinationCidrBlock: 0.0.0.0/0
94 | NatGatewayId: !Ref NatGatewayA
95 | RouteTableId: !Ref RouteTablePrivateA
96 | RouteDefaultPrivateB:
97 | Type: "AWS::EC2::Route"
98 | Properties:
99 | DestinationCidrBlock: 0.0.0.0/0
100 | NatGatewayId: !Ref NatGatewayB
101 | RouteTableId: !Ref RouteTablePrivateB
102 | RouteTablePublic:
103 | Type: "AWS::EC2::RouteTable"
104 | Properties:
105 | VpcId: !Ref VPC
106 | RouteTablePrivateA:
107 | Type: "AWS::EC2::RouteTable"
108 | Properties:
109 | VpcId: !Ref VPC
110 | RouteTablePrivateB:
111 | Type: "AWS::EC2::RouteTable"
112 | Properties:
113 | VpcId: !Ref VPC
114 | EIPNatGWA:
115 | DependsOn: GatewayAttach
116 | Type: "AWS::EC2::EIP"
117 | Properties:
118 | Domain: vpc
119 | EIPNatGWB:
120 | DependsOn: GatewayAttach
121 | Type: "AWS::EC2::EIP"
122 | Properties:
123 | Domain: vpc
124 | NatGatewayA:
125 | Type: "AWS::EC2::NatGateway"
126 | Properties:
127 | AllocationId: !GetAtt EIPNatGWA.AllocationId
128 | SubnetId: !Ref SubnetPublicSharedA
129 | NatGatewayB:
130 | Type: "AWS::EC2::NatGateway"
131 | Properties:
132 | AllocationId: !GetAtt EIPNatGWB.AllocationId
133 | SubnetId: !Ref SubnetPublicSharedB
134 | Outputs:
135 | vpcid:
136 | Description: ID of Shared Infrastructure VPC
137 | Value: !Ref VPC
138 | Export: # added to export
139 | Name: sharedinf-vpcid
140 | natgatewayaid:
141 | Description: ID of NAT Gateway A
142 | Value: !Ref NatGatewayA
143 | natgatewaybid:
144 | Description: ID of NAT Gateway B
145 | Value: !Ref NatGatewayB
146 | publicroutetable:
147 | Description: ID of Public Route Table
148 | Value: !Ref RouteTablePublic
149 | Export: # added to export
150 | Name: sharedinf-publicrt
151 | privateroutetablea:
152 | Description: ID of Private Route Table - A
153 | Value: !Ref RouteTablePrivateA
154 | Export: # added to export
155 | Name: sharedinf-privaterta
156 | privateroutetableb:
157 | Description: ID of Private Route Table - B
158 | Value: !Ref RouteTablePrivateB
159 | Export: # added to export
160 | Name: sharedinf-privatertb
161 | appbucketurl:
162 | Description: Shared Infrastructure App Bucket
163 | Value: !GetAtt S3AppBucket.WebsiteURL
164 | Export: # added to export
165 | Name: sharedinf-appbucketurl
166 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/sharedinfrastructure2.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Parameters:
3 | vpccidr:
4 | Type: String
5 | MinLength: 9
6 | MaxLength: 18
7 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
8 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/16
9 | Default: 10.20.0.0/16
10 | psharedacidr:
11 | Type: String
12 | MinLength: 9
13 | MaxLength: 18
14 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
15 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
16 | Default: 10.20.0.0/22
17 | psharedbcidr:
18 | Type: String
19 | MinLength: 9
20 | MaxLength: 18
21 | AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
22 | ConstraintDescription: Must be a valid CIDR range in the form x.x.x.x/22
23 | Default: 10.20.4.0/22
24 | Resources:
25 | VPC:
26 | Type: "AWS::EC2::VPC"
27 | Properties:
28 | CidrBlock: !Ref vpccidr
29 | IGW:
30 | Type: "AWS::EC2::InternetGateway"
31 | S3AppBucket:
32 | DeletionPolicy: Retain
33 | Type: "AWS::S3::Bucket"
34 | Properties:
35 | AccessControl: PublicRead
36 | WebsiteConfiguration:
37 | ErrorDocument: index.html
38 | IndexDocument: index.html
39 |
40 | BucketPolicyApp:
41 | Type: "AWS::S3::BucketPolicy"
42 | Properties:
43 | Bucket: !Ref S3AppBucket
44 | PolicyDocument:
45 | Statement:
46 | -
47 | Sid: "ABC123"
48 | Action:
49 | - "s3:GetObject"
50 | Effect: Allow
51 | Resource: !Join ["", ["arn:aws:s3:::", !Ref S3AppBucket, "/*"]]
52 | Principal:
53 | AWS:
54 | - "*"
55 | GatewayAttach:
56 | Type: "AWS::EC2::VPCGatewayAttachment"
57 | Properties:
58 | InternetGatewayId: !Ref IGW
59 | VpcId: !Ref VPC
60 | SubnetPublicSharedA:
61 | Type: "AWS::EC2::Subnet"
62 | Properties:
63 | AvailabilityZone: !Select [0, !GetAZs ]
64 | CidrBlock: !Ref psharedacidr
65 | MapPublicIpOnLaunch: true
66 | VpcId: !Ref VPC
67 | SubnetPublicSharedB:
68 | Type: "AWS::EC2::Subnet"
69 | Properties:
70 | AvailabilityZone: !Select [1, !GetAZs ]
71 | CidrBlock: !Ref psharedbcidr
72 | MapPublicIpOnLaunch: true
73 | VpcId: !Ref VPC
74 | SubnetRouteTableAssociatePublicA:
75 | Type: "AWS::EC2::SubnetRouteTableAssociation"
76 | Properties:
77 | RouteTableId: !Ref RouteTablePublic
78 | SubnetId: !Ref SubnetPublicSharedA
79 | SubnetRouteTableAssociatePublicB:
80 | Type: "AWS::EC2::SubnetRouteTableAssociation"
81 | Properties:
82 | RouteTableId: !Ref RouteTablePublic
83 | SubnetId: !Ref SubnetPublicSharedB
84 | RouteDefaultPublic:
85 | Type: "AWS::EC2::Route"
86 | DependsOn: GatewayAttach
87 | Properties:
88 | DestinationCidrBlock: 0.0.0.0/0
89 | GatewayId: !Ref IGW
90 | RouteTableId: !Ref RouteTablePublic
91 | RouteDefaultPrivateA:
92 | Type: "AWS::EC2::Route"
93 | Properties:
94 | DestinationCidrBlock: 0.0.0.0/0
95 | NatGatewayId: !Ref NatGatewayA
96 | RouteTableId: !Ref RouteTablePrivateA
97 | RouteDefaultPrivateB:
98 | Type: "AWS::EC2::Route"
99 | Properties:
100 | DestinationCidrBlock: 0.0.0.0/0
101 | NatGatewayId: !Ref NatGatewayB
102 | RouteTableId: !Ref RouteTablePrivateB
103 | RouteTablePublic:
104 | Type: "AWS::EC2::RouteTable"
105 | Properties:
106 | VpcId: !Ref VPC
107 | RouteTablePrivateA:
108 | Type: "AWS::EC2::RouteTable"
109 | Properties:
110 | VpcId: !Ref VPC
111 | RouteTablePrivateB:
112 | Type: "AWS::EC2::RouteTable"
113 | Properties:
114 | VpcId: !Ref VPC
115 | EIPNatGWA:
116 | DependsOn: GatewayAttach
117 | Type: "AWS::EC2::EIP"
118 | Properties:
119 | Domain: vpc
120 | EIPNatGWB:
121 | DependsOn: GatewayAttach
122 | Type: "AWS::EC2::EIP"
123 | Properties:
124 | Domain: vpc
125 | NatGatewayA:
126 | Type: "AWS::EC2::NatGateway"
127 | Properties:
128 | AllocationId: !GetAtt EIPNatGWA.AllocationId
129 | SubnetId: !Ref SubnetPublicSharedA
130 | NatGatewayB:
131 | Type: "AWS::EC2::NatGateway"
132 | Properties:
133 | AllocationId: !GetAtt EIPNatGWB.AllocationId
134 | SubnetId: !Ref SubnetPublicSharedB
135 | Outputs:
136 | vpcid:
137 | Description: ID of Shared Infrastructure VPC
138 | Value: !Ref VPC
139 | Export: # added to export
140 | Name: sharedinf-vpcid
141 | natgatewayaid:
142 | Description: ID of NAT Gateway A
143 | Value: !Ref NatGatewayA
144 | natgatewaybid:
145 | Description: ID of NAT Gateway B
146 | Value: !Ref NatGatewayB
147 | publicroutetable:
148 | Description: ID of Public Route Table
149 | Value: !Ref RouteTablePublic
150 | Export: # added to export
151 | Name: sharedinf-publicrt
152 | privateroutetablea:
153 | Description: ID of Private Route Table - A
154 | Value: !Ref RouteTablePrivateA
155 | Export: # added to export
156 | Name: sharedinf-privaterta
157 | privateroutetableb:
158 | Description: ID of Private Route Table - B
159 | Value: !Ref RouteTablePrivateB
160 | Export: # added to export
161 | Name: sharedinf-privatertb
162 | appbucketurl:
163 | Description: Shared Infrastructure App Bucket
164 | Value: !GetAtt S3AppBucket.WebsiteURL
165 | Export: # added to export
166 | Name: sharedinf-appbucketurl
167 |
--------------------------------------------------------------------------------
/206-LambdaCustomEnhancements/autosubnet/requests/packages/chardet/latin1prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Universal charset detector code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 2001
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | # Shy Shalom - original C code
12 | #
13 | # This library is free software; you can redistribute it and/or
14 | # modify it under the terms of the GNU Lesser General Public
15 | # License as published by the Free Software Foundation; either
16 | # version 2.1 of the License, or (at your option) any later version.
17 | #
18 | # This library is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 | # Lesser General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU Lesser General Public
24 | # License along with this library; if not, write to the Free Software
25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 | # 02110-1301 USA
27 | ######################### END LICENSE BLOCK #########################
28 |
29 | from .charsetprober import CharSetProber
30 | from .constants import eNotMe
31 | from .compat import wrap_ord
32 |
33 | FREQ_CAT_NUM = 4
34 |
35 | UDF = 0 # undefined
36 | OTH = 1 # other
37 | ASC = 2 # ascii capital letter
38 | ASS = 3 # ascii small letter
39 | ACV = 4 # accent capital vowel
40 | ACO = 5 # accent capital other
41 | ASV = 6 # accent small vowel
42 | ASO = 7 # accent small other
43 | CLASS_NUM = 8 # total classes
44 |
45 | Latin1_CharToClass = (
46 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 07
47 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F
48 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 17
49 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F
50 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 27
51 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F
52 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 37
53 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F
54 | OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 47
55 | ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F
56 | ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 57
57 | ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F
58 | OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 67
59 | ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F
60 | ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 77
61 | ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F
62 | OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 87
63 | OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F
64 | UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 97
65 | OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F
66 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A7
67 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF
68 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B7
69 | OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF
70 | ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C7
71 | ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF
72 | ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D7
73 | ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF
74 | ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E7
75 | ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF
76 | ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F7
77 | ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF
78 | )
79 |
80 | # 0 : illegal
81 | # 1 : very unlikely
82 | # 2 : normal
83 | # 3 : very likely
84 | Latin1ClassModel = (
85 | # UDF OTH ASC ASS ACV ACO ASV ASO
86 | 0, 0, 0, 0, 0, 0, 0, 0, # UDF
87 | 0, 3, 3, 3, 3, 3, 3, 3, # OTH
88 | 0, 3, 3, 3, 3, 3, 3, 3, # ASC
89 | 0, 3, 3, 3, 1, 1, 3, 3, # ASS
90 | 0, 3, 3, 3, 1, 2, 1, 2, # ACV
91 | 0, 3, 3, 3, 3, 3, 3, 3, # ACO
92 | 0, 3, 1, 3, 1, 1, 1, 3, # ASV
93 | 0, 3, 1, 3, 1, 1, 3, 3, # ASO
94 | )
95 |
96 |
97 | class Latin1Prober(CharSetProber):
98 | def __init__(self):
99 | CharSetProber.__init__(self)
100 | self.reset()
101 |
102 | def reset(self):
103 | self._mLastCharClass = OTH
104 | self._mFreqCounter = [0] * FREQ_CAT_NUM
105 | CharSetProber.reset(self)
106 |
107 | def get_charset_name(self):
108 | return "windows-1252"
109 |
110 | def feed(self, aBuf):
111 | aBuf = self.filter_with_english_letters(aBuf)
112 | for c in aBuf:
113 | charClass = Latin1_CharToClass[wrap_ord(c)]
114 | freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM)
115 | + charClass]
116 | if freq == 0:
117 | self._mState = eNotMe
118 | break
119 | self._mFreqCounter[freq] += 1
120 | self._mLastCharClass = charClass
121 |
122 | return self.get_state()
123 |
124 | def get_confidence(self):
125 | if self.get_state() == eNotMe:
126 | return 0.01
127 |
128 | total = sum(self._mFreqCounter)
129 | if total < 0.01:
130 | confidence = 0.0
131 | else:
132 | confidence = ((self._mFreqCounter[3] - self._mFreqCounter[1] * 20.0)
133 | / total)
134 | if confidence < 0.0:
135 | confidence = 0.0
136 | # lower the confidence of latin1 so that other more accurate
137 | # detector can take priority.
138 | confidence = confidence * 0.73
139 | return confidence
140 |
--------------------------------------------------------------------------------