Skip to content

Commit cd47e8c

Browse files
Workaround AWS session error in multi-thread process
1 parent a2f6c12 commit cd47e8c

8 files changed

Lines changed: 30 additions & 30 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.7-alpine
22

3-
RUN pip install stackuchin==1.3.0
3+
RUN pip install stackuchin==1.4.0
44

55
VOLUME /project
66

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
here = path.abspath(path.dirname(__file__))
66

7-
current_version = str('1.3.0')
7+
current_version = str('1.4.0')
88

99
# Get the long description from the README file
1010
with open(path.join(here, 'README.md'), encoding='utf-8') as f:

src/stackuchin/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self):
4343

4444
# noinspection PyMethodMayBeStatic
4545
def version(self):
46-
print("1.3.0")
46+
print("1.4.0")
4747

4848
# noinspection PyMethodMayBeStatic
4949
def create(self):

src/stackuchin/create.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ def create(profile_name, stack_file, stack_name, secret, slack_webhook_url,
100100
exit(1)
101101

102102
# Get auth
103-
if profile_name is not None:
104-
try:
105-
boto3.setup_default_session(profile_name=profile_name)
106-
except Exception as exc:
107-
print(exc)
108-
exit(1)
103+
if not from_pipeline:
104+
if profile_name is not None:
105+
try:
106+
boto3.setup_default_session(profile_name=profile_name)
107+
except Exception as exc:
108+
print(exc)
109+
exit(1)
109110

110111
# Verify integrity of stack
111112
stacks = None

src/stackuchin/delete.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ def delete(profile_name, stack_file, stack_name,
9898
exit(1)
9999

100100
# Get auth
101-
if profile_name is not None:
102-
try:
103-
boto3.setup_default_session(profile_name=profile_name)
104-
except Exception as exc:
105-
print(exc)
106-
exit(1)
101+
if not from_pipeline:
102+
if profile_name is not None:
103+
try:
104+
boto3.setup_default_session(profile_name=profile_name)
105+
except Exception as exc:
106+
print(exc)
107+
exit(1)
108+
107109
# Verify integrity of stack
108110
stacks = None
109111
try:

src/stackuchin/start_pipeline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import yaml
22
import concurrent.futures
3+
import boto3
34

45

56
from stackuchin.create import create
@@ -64,6 +65,9 @@ def start_pipeline(profile_name, stack_file, pipeline_file,
6465
if 'pipeline_type' in pipeline:
6566
pipeline_type = pipeline['pipeline_type']
6667

68+
if profile_name is not None:
69+
boto3.setup_default_session(profile_name=profile_name)
70+
6771
if pipeline_type == "sequential":
6872
# First create new stacks (if any)
6973
if "create" in pipeline:

src/stackuchin/update.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ def update(profile_name, stack_file, stack_name, secret, slack_webhook_url,
100100
exit(1)
101101

102102
# Get auth
103-
if profile_name is not None:
104-
try:
105-
boto3.setup_default_session(profile_name=profile_name)
106-
except Exception as exc:
107-
print(exc)
108-
exit(1)
103+
if not from_pipeline:
104+
if profile_name is not None:
105+
try:
106+
boto3.setup_default_session(profile_name=profile_name)
107+
except Exception as exc:
108+
print(exc)
109+
exit(1)
110+
109111
# Verify integrity of stack
110112
stacks = None
111113
try:

src/stackuchin/utilities.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77

88
def current_user(profile_name):
9-
if profile_name is not None:
10-
try:
11-
boto3.setup_default_session(profile_name=profile_name)
12-
except Exception as e:
13-
print(e)
14-
exit(1)
159
sts = boto3.client('sts')
1610
return sts.get_caller_identity()['Arn']
1711

@@ -249,9 +243,6 @@ def alert(stack_name, error=None, stack_region=None, stack_account=None, action=
249243
profile_name=None, slack_webhook_url=None):
250244

251245
if slack_webhook_url is not None:
252-
if profile_name is not None:
253-
boto3.setup_default_session(profile_name=profile_name)
254-
255246
iam_user = current_user(profile_name)
256247
action = str(action).upper()
257248

0 commit comments

Comments
 (0)