diff --git a/.gitignore b/.gitignore index e12bd9f..4abe4b7 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ /.installed.cfg /.python-version /.vagrant +/.idea __pycache__ *.pyc diff --git a/src/awsenv/__init__.py b/src/awsenv/__init__.py index c9bd966..d89cce6 100644 --- a/src/awsenv/__init__.py +++ b/src/awsenv/__init__.py @@ -162,12 +162,14 @@ def format(self, export=True): return "\n".join([ "{}AWS_ACCESS_KEY_ID={}".format("export " if export else "", self.aws_access_key_id), "{}AWS_SECRET_ACCESS_KEY={}".format("export " if export else "", self.aws_secret_access_key), - "{}AWS_SESSION_TOKEN={}".format("export " if export else "", self.aws_session_token) + "{}AWS_SESSION_TOKEN={}".format("export " if export else "", self.aws_session_token), + "{}AWS_PROFILE={}".format("export " if export else "", self.name) ]) else: return "\n".join([ "{}AWS_ACCESS_KEY_ID={}".format("export " if export else "", self.aws_access_key_id), - "{}AWS_SECRET_ACCESS_KEY={}".format("export " if export else "", self.aws_secret_access_key) + "{}AWS_SECRET_ACCESS_KEY={}".format("export " if export else "", self.aws_secret_access_key), + "{}AWS_PROFILE={}".format("export " if export else "", self.name) ]) @property def aws_access_key_id(self): diff --git a/src/awsenv/tests.py b/src/awsenv/tests.py index 5a69f0c..c515825 100644 --- a/src/awsenv/tests.py +++ b/src/awsenv/tests.py @@ -164,9 +164,9 @@ def test_constructor(self): self.assertEqual('session token', fixture.session_token) def test_format(self): - fixture = AWSProfile(None, 'a', 'b', 'c') - result_export = "export AWS_ACCESS_KEY_ID=a\nexport AWS_SECRET_ACCESS_KEY=b\nexport AWS_SESSION_TOKEN=c" - result_no_export = "AWS_ACCESS_KEY_ID=a\nAWS_SECRET_ACCESS_KEY=b\nAWS_SESSION_TOKEN=c" + fixture = AWSProfile('p', 'a', 'b', 'c') + result_export = "export AWS_ACCESS_KEY_ID=a\nexport AWS_SECRET_ACCESS_KEY=b\nexport AWS_SESSION_TOKEN=c\nexport AWS_PROFILE=p" + result_no_export = "AWS_ACCESS_KEY_ID=a\nAWS_SECRET_ACCESS_KEY=b\nAWS_SESSION_TOKEN=c\nAWS_PROFILE=p" self.assertEqual(result_export, fixture.format()) self.assertEqual(result_no_export, fixture.format(export=False))