Add resource filtering

Fix to previous PR, this allows the env variables to get replaced correctly