AWS invalid literal for int() with base 8: ‘493’

Working on an AWS Elastic Beanstalk deployment, I’m using a .config file in my project’s .ebextensions folder to create and upload a file (see the Development Duide). The deployment fails with this message:

Error occurred during build: invalid literal for int() with base 8: ‘493’

I pulled a more complete error trace from /var/log/cfn-init.log:

[ERROR] Unhandled exception during build: invalid literal for int() with base 8: '493'
Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 122, in <module>
    worklog.build(detail.metadata, configSets)
  File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 117, in build
    Contractor(metadata).build(configSets, self)
  File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 502, in build
    self.run_config(config, worklog)
  File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 511, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.6/site-packages/cfnbootstrap/construction.py", line 238, in build
    changes['files'] = FileTool().apply(self._config.files, self._auth_config)
  File "/usr/lib/python2.6/site-packages/cfnbootstrap/file_tool.py", line 102, in apply
    file_is_link = "mode" in attribs and stat.S_ISLNK(int(attribs["mode"], 8))
ValueError: invalid literal for int() with base 8: '493'

The clue I needed was in the second-to-last line:  it didn’t like the “mode” I specified for the file, apparently complaining that 493 is not a base-8 value (which is true:  base 8 has digits 0 through 7). Here’s my .config file:

files:
  "/etc/my-file" :
    mode: 000755
    owner: root
    group: root
    source: https://s3-us-west-2.amazonaws.com/mybucket/my-file

Resources:
  AWSEBAutoScalingGroup:
    Metadata:
      AWS::CloudFormation::Authentication:
        S3Access:
          type: S3
          roleName: aws-elasticbeanstalk-ec2-role
          buckets: mybucket

For some reason, it converted 000755 to 493 decimal (base 10), then it tried to interpret it as base 8.

Use Quotation Marks for Mode

The fix? Enclose the mode in quotation marks (which is in fact the way it is shown in the Development Guide examples):

files:
  "/etc/my-file" :
    mode: "000755"
    ...

With that change, the deployment worked and the file was successfully transferred from S3 to my EC2 instance.

P.S. Credit for the “Resources” section that allows downloading from secured S3 goes to the May 7, 2014 post by Joshua@AWS to this thread.

6 thoughts on “AWS invalid literal for int() with base 8: ‘493’

  1. Akshay Singhvi

    Thank you, you saved a ton of time!

  2. Brice

    Wow !! Thank you so very much !!
    You prevented me from banging my head against my desk…

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.