DontShaveTheYak / cf2tf

Convert Cloudformation templates to Terraform.
GNU General Public License v3.0
493 stars 80 forks source link

fix "Condition" key being treated like a intrinsic function #237

Closed shadycuz closed 11 months ago

shadycuz commented 11 months ago

Closes #234

A Cloudformation template has several Keys named "Condition" that are treated in special ways. The first being the "Condition" section that contains conditions to be evaluated. The second is the "Condition" key in a resource that is used to determine if the resource should be created or not. The third is the "Condition" intrinsic function that points to a condition in the "Condition" section.

The third is tricky because all the other intrinsic functions being with "Fn::" but the "Condition" intrinsic function is the only one that does not. That means we have to look for the "Condition" key by inspecting every key in the template. This is a problem because the "Condition" key is a valid key for a resource. Like in an IAM Policy. We are attempting to fix this by looking at the value of the "Condition" key. A "Condition" intrinsic function will be a string and a "Condition" element of an IAM Policy will be a dictionary.

codecov[bot] commented 11 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (62aee46) 76.12% compared to head (59b499e) 89.66%. Report is 2 commits behind head on develop.

Files Patch % Lines
src/cf2tf/convert.py 83.33% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #237 +/- ## ============================================ + Coverage 76.12% 89.66% +13.53% ============================================ Files 16 16 Lines 1110 1122 +12 Branches 176 182 +6 ============================================ + Hits 845 1006 +161 + Misses 229 82 -147 + Partials 36 34 -2 ``` | [Flag](https://app.codecov.io/gh/DontShaveTheYak/cf2tf/pull/237/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DontShaveTheYak) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/DontShaveTheYak/cf2tf/pull/237/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DontShaveTheYak) | `89.66% <87.50%> (+13.53%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DontShaveTheYak#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.