Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import concurrent.futures
import logging
import os
import sys
import time
from collections import deque
import click
from dictdiffer import diff
@bneutra
bneutra / terraform_check_examples.tf
Created July 28, 2023 20:45
terraform_check_examples.tf
# precondition vs check
# precondition:
# - raises
# - stop you at plan
# check:
# - warns
# - to be used with TFC "Continuous Validation"
# - i.e. alert when check warnings emerge
# Uses for precondition and check
import boto3
import sys
def has_ecs_create_permissions(policy_document):
"""
Check if the policy document contains permissions to create ECS resources.
"""
for statement in policy_document.get("Statement", []):
# move_blocks.py
# This script is used to generate move blocks
# as we move to the new module
# usage: python move_blocks.py <workspace_file> <variable_name> <module_name>
# The file name, the local variable map name and the module name that loops over
# workspaces, unfortunately vary
# typical example to create a moved.tf:
# account_name = account_name.replace("-","_")
# python move_blocks.py main.tf <account_name>_workspaces <account_name> >> moved.tf
import sys
import boto3
import sys
def has_ecs_create_permissions(policy_document):
"""
Check if the policy document contains permissions to create ECS resources.
"""
for statement in policy_document.get("Statement", []):
#!/usr/bin/env python3
import os
import sys
import json
from datetime import datetime, timedelta
import requests
import boto3
import boto3
from datetime import datetime
import sys
def get_acm_certificates(region):
"""
Query ACM certificates and report their domain name, in-use status, and certificate status.
"""
# Initialize ACM client
acm_client = boto3.client('acm', region_name=region)