Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cycode/cli/files_collector/iac/tf_content_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import time
import uuid
from typing import List

from cycode.cli import consts
Expand Down Expand Up @@ -43,7 +44,7 @@ def _generate_tf_content(resource_changes: List[ResourceChange]) -> str:


def _generate_resource_content(resource_change: ResourceChange) -> str:
resource_content = f'resource "{resource_change.resource_type}" "{resource_change.name}" {{\n'
resource_content = f'resource "{resource_change.resource_type}" "{resource_change.name}-{uuid.uuid4()}" {{\n'
if resource_change.values is not None:
for key, value in resource_change.values.items():
resource_content += f' {key} = {json.dumps(value)}\n'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re

from cycode.cli.files_collector.iac import tf_content_generator
from cycode.cli.utils.path_utils import get_file_content, get_immediate_subdirectories
Expand All @@ -13,4 +14,6 @@ def test_generate_tf_content_from_tfplan() -> None:
tfplan_content = get_file_content(os.path.join(_PATH_TO_EXAMPLES, example, 'tfplan.json'))
tf_expected_content = get_file_content(os.path.join(_PATH_TO_EXAMPLES, example, 'tf_content.txt'))
tf_content = tf_content_generator.generate_tf_content_from_tfplan(example, tfplan_content)
assert tf_content == tf_expected_content

cleaned_tf_content = re.sub(r'-[a-fA-F0-9\-]{36}', '', tf_content)
assert cleaned_tf_content == tf_expected_content