Skip to content

Commit a14bbac

Browse files
committed
feat: kinesis stream and functional test harness
1 parent fb74b5d commit a14bbac

File tree

5 files changed

+136
-54
lines changed

5 files changed

+136
-54
lines changed

poetry.lock

Lines changed: 111 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jsonschema = "^3.2.0"
1818
[tool.poetry.dev-dependencies]
1919
pytest = "^6.2.4"
2020
black = "^21.7b0"
21+
pytest-terraform = { git = "https://github.com/cloud-custodian/pytest-terraform.git", branch = "work-dir-test-api" }
2122

2223
[build-system]
2324
requires = ["poetry-core>=1.0.0"]

tests/unit/conftest.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

tests/unit/test_resources.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ def test_app_lb(validate):
1414
resource = load_data("app_lb.json")
1515
props = translator.get_properties(resource)
1616
validate(translator, props)
17+
18+
19+
def test_kinesis(validate):
20+
translator = Translator.get_translator("kinesis_stream")()
21+
resource = load_data("kinesis_stream.json")
22+
validate(translator, translator.get_properties(resource))

tfdevops/cli.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,9 @@ def _camel_str(self, k):
597597
parts = [p.capitalize() for p in k.split("_")]
598598
return "".join(parts)
599599

600+
def get_tags(self, tag_map):
601+
return [{"Key": k, "Value": v} for k, v in tag_map.items()]
602+
600603
def camel(self, d):
601604
r = {}
602605

@@ -765,6 +768,20 @@ def get_identity(self, r):
765768
return {self.id: r["values"]["arn"]}
766769

767770

771+
class KinesisStream(Translator):
772+
773+
tf_type = "kinesis_stream"
774+
cfn_type = "AWS::Kinesis::Stream"
775+
id = "Name"
776+
strip = ("shard_level_metrics", "encryption_type")
777+
rename = {"retention_period": "RetentionPeriodHours"}
778+
779+
def get_properties(self, tfr):
780+
cfr = super().get_properties(tfr)
781+
cfr["Tags"] = self.get_tags(cfr.get("Tags", {}))
782+
return cfr
783+
784+
768785
class Lambda(Translator):
769786

770787
tf_type = "lambda_function"
@@ -796,9 +813,7 @@ def get_properties(self, tfr):
796813
"variables"
797814
]
798815
cfr["Code"] = {"ZipFile": tfr["values"]["filename"]}
799-
cfr["Tags"] = [
800-
{"Key": k, "Value": v} for k, v in tfr["values"].get("Tags", {}).items()
801-
]
816+
cfr["Tags"] = self.get_tags(tfr["values"].get("Tags", {}))
802817
if "VpcConfig" in cfr:
803818
cfr["VpcConfig"].pop("VpcId")
804819
return cfr

0 commit comments

Comments
 (0)