Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciprian Ciubotariu committed Apr 20, 2015
1 parent a394a8a commit 1f6903a
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions bootstrap_cfn/utils.py
@@ -1,10 +1,13 @@
import boto.exception
import boto.provider
import boto.sts
import sys
import time
import os

import bootstrap_cfn.errors as errors
from fabric.colors import green, red, yellow
from copy import deepcopy


def timeout(timeout, interval):
Expand All @@ -25,6 +28,22 @@ def wrapper(*args, **kwargs):

def connect_to_aws(module, instance):
try:
if instance.aws_profile_name == 'cross-account':
sts = boto.sts.connect_to_region(
region_name=instance.aws_region_name,
profile_name=instance.aws_profile_name
)
role = sts.assume_role(
role_arn=os.environ['AWS_ROLE_ARN_ID'],
role_session_name="AssumeRoleSession1"
)
conn = module.connect_to_region(
region_name=instance.aws_region_name,
aws_access_key_id=role.credentials.access_key,
aws_secret_access_key=role.credentials.secret_key,
security_token=role.credentials.session_token
)
return conn
conn = module.connect_to_region(
region_name=instance.aws_region_name,
profile_name=instance.aws_profile_name
Expand All @@ -36,6 +55,25 @@ def connect_to_aws(module, instance):
raise errors.ProfileNotFoundError(instance.aws_profile_name)


def dict_merge(target, *args):
# Merge multiple dicts
if len(args) > 1:
for obj in args:
dict_merge(target, obj)
return target

# Recursively merge dicts and set non-dict values
obj = args[0]
if not isinstance(obj, dict):
return obj
for k, v in obj.iteritems():
if k in target and isinstance(target[k], dict):
dict_merge(target[k], v)
else:
target[k] = deepcopy(v)
return target


def tail(stack, stack_name):
"""Show and then tail the event log"""

Expand Down Expand Up @@ -89,5 +127,3 @@ def get_events(stack, stack_name):
next = events.next_token
time.sleep(1)
return reversed(sum(event_list, []))


0 comments on commit 1f6903a

Please sign in to comment.