Sceptre: Strings starting with 0 are identified as Octal in Sceptre User data

Created on 10 Sep 2019  路  4Comments  路  Source: Sceptre/sceptre

Hi,

It seems that Sceptre somehow interprets variables starting with 0 as octal and converts them to decimal. This is a an Issue because we have user names that start with 0. Here is the example
Sceptre Config file:

sceptre_user_data:
  env:
    user: {{ var.user }}

sceptre --var "user=03303560" launch TEST/s3
When I execute this the value in the deployed cloudformation template becomes 886640.

Is it possible to do something about this?
Thanks!

help wanted ready for development

Most helpful comment

Hi, this is probably due to how YAML works.

(more info: https://stackoverflow.com/questions/54820256/how-to-read-load-yaml-parameters-with-leading-zeros-as-a-string)

I'd suggest to treat these numbers as strings 'user="03303560"' unless you really need it to be an integer starting with zero.

All 4 comments

Hi, this is probably due to how YAML works.

(more info: https://stackoverflow.com/questions/54820256/how-to-read-load-yaml-parameters-with-leading-zeros-as-a-string)

I'd suggest to treat these numbers as strings 'user="03303560"' unless you really need it to be an integer starting with zero.

Thanks @1oglop1 , that make sense. I need to figure out because actually I use sceptre --var "user=${USER}" launch TEST/s3 and then I pass User as env variable in gitlab-ci:

variables:
USER: 03303560

Therefore, I need to substitute $USER for 03303560

Blind shot, but try out this:

sceptre_user_data:
  env:
    user: !!str {{ var.user }}

https://yaml.org/type/str.html

here is what's going to happen (what I expect to happen):

  1. supplied sceptre --var "user=03303560" will be rendered correctly from jinja
  2. !!str 03303560 will make sure that whatever the value is, it's represented as string.

After using !!str 03303560 the string was still converted to 886640

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tahoward picture tahoward  路  4Comments

brian-provenzano picture brian-provenzano  路  6Comments

fabiodouek picture fabiodouek  路  5Comments

et304383 picture et304383  路  6Comments

n2taylor picture n2taylor  路  7Comments