A few things here:
1) Your gist of that file, and what you indicate in your email are different, specifically the `if env in ["dev", "stg]` part
2) As a result of #1 the YAML renders incorrectly, causing that error
Here is the result of the template when `env: dev` is set:
---
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- "s3:List*"
Resource: "arn:aws:s3:::bucket"
- Effect: Allow
Action:
- "s3:Get*"
- "s3:Put*"
Resource:
- "arn:aws:s3:::bucket/dev"
- "arn:aws:s3:::bucket/dev/*"
As such, your template needs to be adjusted with something like this, where the `{% if %}` and `{% endif %}` blocks aren't adding to the indentation, by being completely left justified:
---
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- "s3:List*"
Resource: "arn:aws:s3:::bucket"
- Effect: Allow
Action:
- "s3:Get*"