コード例 #1
0
def test_infra():

    infra = Infra('test')
    test_infra = infra.create_sub_infra('test')
    vpc_stack = test_infra.add_stack(vpc.VPCStack())

    return {'infra': infra, 'test_infra': test_infra, 'vpc_stack': vpc_stack}
コード例 #2
0
def infra():

    infra = Infra("test")

    prod_infra = infra.create_sub_infra("prod")

    iam_stack = prod_infra.add_stack(iam.IAMStack("roles"))

    web_profile = iam_stack.add_role(iam.EC2AdminProfile("test"))

    vpc_stack = prod_infra.add_stack(vpc.VPCStack())

    eip_stack = prod_infra.add_stack(eip.EIPStack("test"))

    ebs_stack = prod_infra.add_stack(ebs.EBSStack("test", vpc_stack))

    sns_stack = prod_infra.add_stack(sns.SNSTopicStack('test'))

    return {
        'infra': infra,
        'prod_infra': prod_infra,
        'iam_stack': iam_stack,
        'web_profile': web_profile,
        'vpc_stack': vpc_stack,
        'eip_stack': eip_stack,
        'ebs_stack': ebs_stack,
        'sns_stack': sns_stack
    }
コード例 #3
0
def prod_infra():

    infra = Infra("test")

    prod_infra = infra.create_sub_infra("prod")

    return (infra, prod_infra)
コード例 #4
0
def test_infra(sess_mock):

    sess_mock.return_value = True

    session = BotoSession()

    infra = Infra('Test', session)

    vpc_stack = infra.add_stack(vpc.VPCStack())
    s3_one = infra.add_stack(s3.S3Stack('one'))
    s3_two = infra.add_stack(s3.S3Stack('two'))

    # test find stack
    vpc_find = infra.find_stack(vpc.VPCStack)

    assert isinstance(vpc_find, (vpc.VPCStack))

    assert infra.find_stack(s3.S3Stack, 'one').stack_name == 'one'
    assert infra.find_stack(s3.S3Stack, 'two').stack_name == 'two'

    # test list_stacks
    assert len(infra.list_stacks()) == 3

    # test sub
    sub = infra.create_sub_infra('sub')
    sub_sub = sub.create_sub_infra('sub')

    assert sub_sub.prefix == ['sub', 'sub']
コード例 #5
0
def infra():

    infra = Infra("test")

    prod_infra = infra.create_sub_infra("prod")

    iam_stack = prod_infra.add_stack(iam.IAMStack("roles"))

    web_profile = iam_stack.add_role(iam.EC2AdminProfile("test"))

    vpc_stack = prod_infra.add_stack(vpc.VPCStack())

    eip_stack = prod_infra.add_stack(eip.EIPStack("test"))

    ebs_stack = prod_infra.add_stack(ebs.EBSStack("test", vpc_stack))

    return (infra, prod_infra, iam_stack, web_profile, vpc_stack, eip_stack,
            ebs_stack)
コード例 #6
0
def ubuntu_ami():
    ami = Ami("WebUbuntu", "ubuntu")
    ami.add_role('sudo-nopw', {}, 100)
    ami.add_role('users', {'githubusers':[ 'ibejohn818'] }, 200)
    return ami

def aws_linux_ami():
    ami = Ami("WebUbuntu", "awslinux")
    ami.add_role('sudo-nopw', {}, 100)
    ami.add_role('users', {'githubusers':[ 'ibejohn818'] }, 200)
    return ami

# set path to ansible directory
Ami.ANSIBLE_DIR='./ansible'
# set list to individual ansible roles
# Ami.ANSIBLE_ROLES = [
    # '/path/to/role',
    # '/path/to/another/role'
# ]


session = BotoSession(region_name='us-west-1')

infra = Infra('StackDemo', session)

infra.add_image(ubuntu_ami())

prod_infra = prod_stacks(infra)
dev_infra = dev_stacks(infra)
staging_infra = staging_stacks(infra)
コード例 #7
0
def test_infra():

    infra = Infra('test')
    test_infra = infra.create_sub_infra('test')

    return {'infra': infra, 'test_infra': test_infra}
コード例 #8
0
def aws_bastion_ami():

    ami = Ami("BastionAwsNatGateway", 'awslinux')
    ami.add_role('common-pkgs', {}, 1)
    ami.add_role('sudo-nopw', {}, 100)
    ami.add_role('users', {'githubusers': ['ibejohn818']}, 200)
    return ami


# ANSIBLE PATH
Ami.ANSIBLE_DIR = "{}/ansible".format(
    os.path.dirname(os.path.realpath(__file__)))

session = BotoSession(region_name='us-east-2')

infra = Infra('NatDemo', session)

# create sns topic for alarms
# top level sns topic
sns_stack = infra.add_stack(sns.SNSTopicStack("AlarmNotifications"))
# topic subscriptions
## slack subscription
slack_sub = sns_stack.add_subscription(sns.SlackSubscription("AwsAlarms"))
## email subscription
email_sub = sns_stack.add_subscription(sns.EmailSubscription('EmailNotify'))
infra.add_vars({'InputEmailNotifySNSEmailAddress': '*****@*****.**'})

# add ami's to infra
web_ubuntu = web_ubuntu_ami()
aws_bastion = aws_bastion_ami()