primaryActive = False
primarySubnetSet = config['Primary']['subnet'] != 'no'
secondarySubnetSet = config['Secondary']['subnet'] != 'no'
if primarySubnetSet:
    primarySubnet = ipaddress.ip_network(config['Primary']['subnet'])
if secondarySubnetSet:
    secondarySubnet = ipaddress.ip_network(config['Secondary']['subnet'])
bothSubnetSet = not (primarySubnetSet ^ secondarySubnetSet)
oldExternalIPv4 = None
try:
    while True:
        # Get the external ip and validate primary cname allowance
        try:
            logger.debug('Resolving external IPv4...')
            if config['General']['external_resolver'] == 'default':
                externalIPv4 = ipaddress.ip_address(str(getter.get().v4))
            else:
                externalIPv4 = ipaddress.ip_address(
                    str(
                        getter.get_from(
                            config['General']['external_resolver']).v4))

            # Update the cname to the external ip...
            if CloudflareDynDnsRecordId is not None and oldExternalIPv4 != externalIPv4:
                try:
                    data = {
                        'type': 'A',
                        'name': config['DynDns']['dyndns_target'],
                        'content': str(externalIPv4),
                        'ttl': config['DynDns']['dyndns_ttl'],
                        'proxied': False
    Ref,
    Template,
)
from troposphere.iam import (InstanceProfile, PolicyType as IAMPolicy, Role)
from awacs.aws import (Action, Allow, Policy, Principal, Statement)
from awacs.sts import AssumeRole

getter = IPGetter()

ApplicationName = "nodeserver"
ApplicationPort = "3000"
GithubAccount = "garbhsoft"
GithubAnsibleUrl = "https://github.com/{}/ansible".format(GithubAccount)
AnsiblePullCmd = "/usr/bin/ansible-pull -U {} {}.yml -i localhost".format(
    GithubAnsibleUrl, ApplicationName)
PublicCidrIp = str(ip_network(getter.get().v4))

t = Template()

t.set_description("Effective DevOps in AWS: HelloWorld web application")

t.add_parameter(
    Parameter(
        "KeyPair",
        Description="Name of an existing EC2 KeyPair to SSH",
        Type="AWS::EC2::KeyPair::KeyName",
        ConstraintDescription="must be the name of an existing EC2 KeyPair.",
    ))

t.add_resource(
    ec2.SecurityGroup(
Beispiel #3
0
def ip(update, context):
    getter = IPGetter()
    ips=getter.get()
    update.message.reply_text('Your ips:\n v4:{0}\n v6:{1}'.format(ips.v4,ips.v6))