Sceptre File Resolver

raw JSON →
1.0.6 verified Mon Apr 27 auth: no python maintenance

Sceptre resolver to retrieve file content and inject it into CloudFormation templates. Version 1.0.6 is the latest stable release (last updated 2022). Low maintenance project.

pip install sceptre-file-resolver
error sceptre.exceptions.InvalidFileSceptreResolverException: Unable to resolve file
cause File path does not exist or is not readable.
fix
Check that the file path is correct and the file has read permissions. Use an absolute path or verify relative path from Sceptre working directory.
error ImportError: cannot import name 'FileContent' from 'sceptre_file_resolver'
cause PyPI package name differs from import path. The package is 'sceptre-file-resolver', import from 'sceptre_file_resolver'.
fix
Run: pip install sceptre-file-resolver, then import with: from sceptre_file_resolver import FileContent
gotcha The resolver does not validate file paths or handle permissions errors gracefully. Non-existent files cause runtime exceptions.
fix Ensure the file exists and is readable before calling the resolver. Use custom error handling in a wrapper if needed.
gotcha The resolver does not support Sceptre built-in environment variables. Use explicit file paths only.
fix Do not rely on environment variable resolution in the file path. Provide absolute or relative paths that are fully resolved at Sceptre runtime.

Instantiate the FileContent resolver and use it to read a file's content.

from sceptre_file_resolver import FileContent as FileResolver

# Example usage within Sceptre config
# In config.yaml:
#   parameters:
#     my_param: !file_content path/to/file.txt

# The resolver reads file content and returns it as a string.
file_path = "/path/to/file.txt"
resolver = FileResolver()
content = resolver.resolve(file_path=file_path)
print(content)