import json with open('projects/aws-accounts/ecr-repos.default', 'r') as f: resources = [] for line in f.readlines(): resource = { "type": "aws:ecr/repositoryPolicy:RepositoryPolicy", "name": f"us-west-2-{line.strip()}-policy", "id": line.strip(), } resources.append(resource) with open('test.json', 'w') as f2: json.dump({"resources": resources}, f2, indent=2)