diff --git a/moto/iam/policy_validation.py b/moto/iam/policy_validation.py index 6ee286072..d9a4b0282 100644 --- a/moto/iam/policy_validation.py +++ b/moto/iam/policy_validation.py @@ -152,8 +152,10 @@ class IAMPolicyDocumentValidator: sids = [] for statement in self._statements: if "Sid" in statement: - assert statement["Sid"] not in sids - sids.append(statement["Sid"]) + statementId = statement["Sid"] + if statementId: + assert statementId not in sids + sids.append(statementId) def _validate_statements_syntax(self): assert "Statement" in self._policy_json diff --git a/tests/test_iam/test_iam_policies.py b/tests/test_iam/test_iam_policies.py index e1924a559..adb8bd990 100644 --- a/tests/test_iam/test_iam_policies.py +++ b/tests/test_iam/test_iam_policies.py @@ -1827,6 +1827,23 @@ valid_policy_documents = [ "Resource": ["*"] } ] + }, + { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "", + "Effect": "Allow", + "Action": "rds:*", + "Resource": ["arn:aws:rds:region:*:*"] + }, + { + "Sid": "", + "Effect": "Allow", + "Action": ["rds:Describe*"], + "Resource": ["*"] + } + ] } ]