Terraform Workspaces vs Separate Directories: Which is Better for Dev/Prod?
Terraform Workspaces vs Separate Directories: Discover the best approach for managing Dev, Staging, and Production with strong environment isolation.
Terraform Workspaces vs Separate Directories: Discover the best approach for managing Dev, Staging, and Production with strong environment isolation.
What Happens If You Manually Delete a Resource in the Cloud Console? Manually deleting a cloud resource outside of Terraform — such as via the AWS Console, Azure Portal, or GCP Console — creates a situation called configuration drift. Understanding how Terraform handles this is critical for maintaining infrastructure integrity. What is Configuration Drift? Drift…
When Should You Explicitly Use depends_on in Terraform? Terraform automatically builds a dependency graph by analyzing resource references in your code. In most cases, you never need to declare dependencies manually. But there are specific scenarios where depends_on is necessary. How Implicit Dependencies Work When one resource references another, Terraform infers the dependency automatically: resource…
How to Recover from a Corrupted Terraform State File The Terraform state file (terraform.tfstate) is the single source of truth for your managed infrastructure. A corrupted or lost state file is one of the most critical incidents you can face. Here is how to handle it. Prevention First: Enable Remote Backend with Versioning The best…
Terraform count vs for_each: Which is Better for Dynamic Resources? When creating multiple instances of a resource in Terraform, you have two options: count and for_each. Knowing when to use each one is a key concept for writing reliable, maintainable infrastructure code. Using count count creates resources using a numeric index starting at 0. It…
List Comprehension Tasks in Python List comprehension is one of Python’s most powerful and elegant features. It lets you create new lists from existing ones in a single, readable line of code. Basic Syntax # [expression for item in iterable if condition] squares = [x**2 for x in range(10)] print(squares) # [0, 1, 4, 9,…
Count Character Frequency in Python Counting how many times each character appears in a string is a fundamental problem with many real-world applications, from text analysis to compression algorithms. Best Solution: Using Counter from collections import Counter def char_frequency(s): return Counter(s) result = char_frequency(“hello world”) print(result) # Output: Counter({‘l’: 3, ‘o’: 2, ‘h’: 1, ‘e’:…
Check for Anagrams in Python Two strings are anagrams if they contain the same characters in the same frequency, just in a different order. For example, “listen” and “silent” are anagrams. Solution 1: Sort and Compare def is_anagram(s1, s2): return sorted(s1.lower()) == sorted(s2.lower()) print(is_anagram(“listen”, “silent”)) # True print(is_anagram(“hello”, “world”)) # False Solution 2: Using Counter…
Remove Duplicates from a List in Python Cleaning a list of duplicate values is a frequent data processing task. Python offers several clean approaches depending on whether order matters. Fastest Method: Convert to Set (Order Not Preserved) my_list = [1, 2, 2, 3, 4, 4, 5] unique_list = list(set(my_list)) print(unique_list) # Output: [1, 2, 3,…
Two Sum Problem in Python Given a list of numbers and a target value, find the indices of two numbers that add up to the target. This is one of the most popular LeetCode-style interview questions. Brute Force — O(n²) def two_sum_brute(nums, target): for i in range(len(nums)): for j in range(i + 1, len(nums)): if…