Skip to main content

Associates route53 PTR records to particular vpc.

Project description

r53_ptr_vpc_associator

This is a program to association reverse zones to vpcs. It is associated with https://github.com/aws-samples/aws-lambda-ddns-function

Prerequisites

It is highly recommended you run this package within a python virtual environment, so you do not affect your desktop/laptop. To setup a python virtual environment, you should make sure you have python3 installed, and do the following.

NOTE: Why am I doing this. With a python virtual environment, you can create as many virtual environmentsa as you would like, and with different python versions. These virtual environments are isolated in a directory, and will not affect anything else on your computer. This way, you can test and ensure things will work.

First, figure out the path to the python version installed on your machine.

which python3
/usr/local/bin/python3

Next, you should pip install the virtualenv package

pip install virtualenv

Next, you should create a directory, where you are going to keep the virtual environments, and create a new virtualenv by using the path to the python version you found above.

mkdir ~/virtual_environments
cd virtual_environments
virtualenv -p /usr/local/bin/python3 my_python3_virtualenv

To activate the virtual environment

source ~/virtual_environments/my_python3_virutalenv/bin/activate

NOTE: To deactivate the virtual environment

deactivate

Installation

For general usage:

pip install r53_ptr_vpc_associator

For local development:

git clone https://github.com/rubelw/r53_ptr_vpc_associator
cd r53_ptr_vpc_associator
pip install --editable .  # Install the local dir as a package, including the 'dev' extras

Example

Getting help

$ associator --help
Usage: associator [OPTIONS] COMMAND [ARGS]...

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  associate  Associated hosted zones to vpc
  zone-list  List vpcs for hosted zones

Listing current zone/vpc associations

$ associator zone-list --profile-name default
{
        '/hostedzone/Z1H1CDD4PZKKPB': [
        {
            'VPCRegion': 'us-east-1',
            'VPCId': 'vpc-99999999'
        },
        {
            'VPCRegion': 'us-east-2',
            'VPCId': 'vpc-99999999'
        }
    ]
}

Associating zones

$ associator associate --profile-name default --vpc-id vpc-99999999  --vpc-region us-east-2
[
    'Successfully associated zone: /hostedzone/A3G1CDD4PZKKPB with vpc: vpc-99999999',
    'Successfully associated zone: /hostedzone/HR2F2BVHDW5UD with vpc: vpc-99999999',
    'Successfully associated zone: /hostedzone/V6B06KVZ0ZL9U5 with vpc: vpc-99999999',
    'Successfully associated zone: /hostedzone/D7JTQ7EDFFYOWN with vpc: vpc-99999999'
]

To run as a lambda

Run the make_lambda-zip command. This will utilize the /tmp directory to create the package.

associator make-lambda-zip

################################################################################
Zip package located at: /tmp/r53_ptr_vpc_associator/LambdaDeploymentPackage.zip
################################################################################

Deploy the lambda and you would any other lambda package, but ensure the following environmental variables are set.

PROFILE_NAME = lambda
VPC_ID       = vpc-xxxxxxx
VPC_REGION   = us-east-1

Once deployed, you can test the lambda by creating any test in the console. The lambda does not use the event message, so any event message will work to trigger the lambda.

Testing

Before commiting changes, be sure to run the test suite:

tox

Python 3 Compatibility

This tool is compatible with python 3.5+.

The tox library is used to run tests with multiple python versions. To run these tests, first ensure that all supported python versions are installed locally. Then, simply run:

tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

r53_ptr_vpc_associator-0.1.2.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

r53_ptr_vpc_associator-0.1.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file r53_ptr_vpc_associator-0.1.2.tar.gz.

File metadata

  • Download URL: r53_ptr_vpc_associator-0.1.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0

File hashes

Hashes for r53_ptr_vpc_associator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3b48514c133ebfbf0f9a636f4970d99cc2e77a5bf04e2cf0fa2602213bcd9e92
MD5 fbcbd70686d84bdc15127b9dd83d03dd
BLAKE2b-256 cca89a6c674f3fd0563a5dfbcb3e8e739dcf9d8fb2ed87b73a5c749bba7d336c

See more details on using hashes here.

File details

Details for the file r53_ptr_vpc_associator-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: r53_ptr_vpc_associator-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0

File hashes

Hashes for r53_ptr_vpc_associator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7ed00c1387222a21d71b2966f2ac099d88e5daf93c3fec489bdf5ebf99b66264
MD5 4483b032c38f43ad6fefc67d2362e7d6
BLAKE2b-256 1a5ae8756ac9f56402b68c993c53d8f379d3592c1e2d2f0bf892c6f0f9ace797

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page