Skip to content

Commit 881c115

Browse files
authored
Merge pull request #48 from AllenInstitute/add-sqs-policy-statement
Fix bug (and tests) in `sqs_policy_statement` function
2 parents 8dd3c48 + c274f5c commit 881c115

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/aibs_informatics_cdk_lib/common/aws/iam_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ def sqs_policy_statement(
482482
build_arn(
483483
service="sqs",
484484
resource_id=f"{env_base or ''}*",
485-
resource_type="*",
486485
)
487486
],
488487
)

test/aibs_informatics_cdk_lib/common/aws/test_iam_utils.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def test__secrets_manager_policy_args(generate_policy_args, expected_resource, e
5656
assert set(generated_policy_statement.actions) == set(expected_actions)
5757

5858

59+
# https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-overview-of-managing-access.html#sqs-resource-and-operations
60+
# https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-basic-examples-of-sqs-policies.html
5961
@pytest.mark.parametrize(
6062
"env_base, expected_actions, expected_resource_patterns",
6163
[
@@ -66,9 +68,9 @@ def test__secrets_manager_policy_args(generate_policy_args, expected_resource, e
6668
SQS_FULL_ACCESS_ACTIONS,
6769
# expected_resource_patterns
6870
[
69-
r"arn:aws:sqs:\$\{Token\[AWS\.Region\.[\d]+\]\}:\$\{Token\[AWS\.AccountId\.[\d]+\]\}:\*:\*"
71+
r"arn:aws:sqs:\$\{Token\[AWS\.Region\.[\d]+\]\}:\$\{Token\[AWS\.AccountId\.[\d]+\]\}:\*"
7072
],
71-
id="Test SQS policystatment (env_base=None)",
73+
id="Test SQS policystatement (env_base=None)",
7274
),
7375
pytest.param(
7476
# env_base
@@ -77,9 +79,9 @@ def test__secrets_manager_policy_args(generate_policy_args, expected_resource, e
7779
SQS_FULL_ACCESS_ACTIONS,
7880
# expected_resource_patterns
7981
[
80-
r"arn:aws:sqs:\$\{Token\[AWS\.Region\.[\d]+\]\}:\$\{Token\[AWS\.AccountId\.[\d]+\]\}:\*:dev\*"
82+
r"arn:aws:sqs:\$\{Token\[AWS\.Region\.[\d]+\]\}:\$\{Token\[AWS\.AccountId\.[\d]+\]\}:dev\*"
8183
],
82-
id="Test SQS policystatment (env_base=dev)",
84+
id="Test SQS policystatement (env_base=dev)",
8385
),
8486
pytest.param(
8587
# env_base
@@ -88,9 +90,9 @@ def test__secrets_manager_policy_args(generate_policy_args, expected_resource, e
8890
SQS_FULL_ACCESS_ACTIONS,
8991
# expected_resource_patterns
9092
[
91-
r"arn:aws:sqs:\$\{Token\[AWS\.Region\.[\d]+\]\}:\$\{Token\[AWS\.AccountId\.[\d]+\]\}:\*:test\*"
93+
r"arn:aws:sqs:\$\{Token\[AWS\.Region\.[\d]+\]\}:\$\{Token\[AWS\.AccountId\.[\d]+\]\}:test\*"
9294
],
93-
id="Test SQS policystatment (env_base=test)",
95+
id="Test SQS policystatement (env_base=test)",
9496
),
9597
],
9698
)
@@ -104,4 +106,4 @@ def test__sqs_policy_statement(
104106
obt_resource = obt.resources[indx]
105107
assert re.fullmatch(
106108
expected_pattern, obt_resource
107-
), f"expected_pattern: {expected_pattern}, obt: {obt_resource}"
109+
), f"expected_pattern: {expected_pattern}, obtained: {obt_resource}"

0 commit comments

Comments
 (0)