Skip to content

Commit

Permalink
Merge pull request #130 from Skyscanner/kms_keypolicy_optional
Browse files Browse the repository at this point in the history
KeyPolicy made optional for KMS Key
  • Loading branch information
ignaciobolonio committed Feb 8, 2024
2 parents d6e2ba7 + 097a8c2 commit 4b52ade
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.

## 0.22.0
### Fixes
- KeyPolicy made optional for KMS Key resource type.

## 0.21.2
### Fixes
- Add the BypassPolicyLockoutSafetyCheck and Origin fields in the KMS resource
Expand Down
2 changes: 1 addition & 1 deletion pycfmodel/model/resources/kms_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class KMSKeyProperties(CustomModel):
Description: Optional[ResolvableStr] = None
Enabled: Optional[ResolvableBool] = None
EnableKeyRotation: Optional[ResolvableBool] = None
KeyPolicy: Resolvable[PolicyDocument]
KeyPolicy: Optional[Resolvable[PolicyDocument]] = None
KeySpec: Optional[ResolvableStr] = None
KeyUsage: Optional[ResolvableStr] = None
MultiRegion: Optional[ResolvableBool] = None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

setup(
name="pycfmodel",
version="0.21.2",
version="0.22.0",
description="A python model for CloudFormation scripts",
author="Skyscanner Product Security",
author_email="security@skyscanner.net",
Expand Down
17 changes: 17 additions & 0 deletions tests/resources/test_kms_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ def kms_key():
)


@pytest.fixture()
def kms_key_no_policy():
return KMSKey(
**{
"Type": "AWS::KMS::Key",
"Properties": {
"Enabled": True,
"EnableKeyRotation": True,
},
}
)


def test_actions(kms_key):
assert [
"kms:CancelKeyDeletion",
Expand Down Expand Up @@ -168,3 +181,7 @@ def test_kms_policy_documents(kms_key):
),
)
]


def test_kms_no_policy(kms_key_no_policy):
assert kms_key_no_policy.Properties.KeyPolicy is None

0 comments on commit 4b52ade

Please sign in to comment.