Skip to content

Commit 3abe5ab

Browse files
authored
Merge pull request #4 from NarrativeScience/account-id-sts
QPT-28740 Source default aws account id value from sts
2 parents 37e5ad2 + 400bd30 commit 3abe5ab

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Enhanced, asyncio-compatible client for AWS Step Functions."""
22

3-
__version__ = "0.3.0"
3+
__version__ = "0.4.0"

src/sfn_workflow_client/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
"""Constants and configuration for the workflow client"""
22
import os
33

4-
AWS_ACCOUNT_ID = os.environ.get("AWS_ACCOUNT_ID")
4+
import boto3
5+
6+
AWS_ACCOUNT_ID = os.environ.get(
7+
"AWS_ACCOUNT_ID", boto3.client("sts").get_caller_identity()["Account"]
8+
)
59

610
# URL for making requests to the Step Functions API. You would most likely only set
711
# this in order to hit the local py2sfn mock server.

tests/unit/test_workflow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import unittest
55

6+
from sfn_workflow_client.config import AWS_ACCOUNT_ID
67
from sfn_workflow_client.workflow import Workflow
78

89

@@ -15,7 +16,7 @@ def test_init(self):
1516
self.assertEqual(workflow.name, "test")
1617
self.assertEqual(
1718
workflow.state_machine_arn,
18-
f"arn:aws:states:{os.environ.get('AWS_DEFAULT_REGION')}:{os.environ.get('AWS_ACCOUNT_ID')}:stateMachine:test",
19+
f"arn:aws:states:{os.environ.get('AWS_DEFAULT_REGION')}:{AWS_ACCOUNT_ID}:stateMachine:test",
1920
)
2021
self.assertEqual(len(workflow.executions), 0)
2122

0 commit comments

Comments
 (0)