aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

`aws cloudformation package` fails with awscli version 1.16.144

Open bikerp opened this issue 7 years ago • 16 comments

Hi,

after upgrading AWS CLI to version 1.16.144 I got the error: Unable to upload artifact template.yaml referenced by Location parameter of ... resource. It occurs on Windows 10 and Centos 7.5. Both using Python 2.7

bikerp avatar Apr 24 '19 08:04 bikerp

confirmed, same for me with python 3.6 join() argument must be str or bytes, not 'OrderedDict'

see also: AWS Forum

daTobiGit avatar Apr 24 '19 14:04 daTobiGit

Same here, I had to revert back to older version of the cli: pip install awscli==1.16.141

neilconlan avatar Apr 24 '19 15:04 neilconlan

@bikerp - Thank you for reporting the behavior. I am not able to reproduce the issue with CLI version 1.16.144. Please provide us the --debug log.

swetashre avatar Apr 24 '19 21:04 swetashre

here is my debug log from codebuild: 2019/04/24 13:18:13 Running command sam package --debug --template-file "${SAM_TEMPLATE}" --s3-bucket "${ARTIFACT_BUCKET}" --s3-prefix "${NOW}" --output-template-file "./${PACKAGED_FILE}" 2019-04-24 13:18:13 Using SAM Template at /codebuild/output/src574895711/src/sam-app/template.json 2019-04-24 13:18:13 package command is called join() argument must be str or bytes, not 'OrderedDict'

2019-04-24 13:18:14 Exception: Command 'aws', 'cloudformation', 'package', '--s3-prefix', 'xyz', '--output-template-file', './packaged.yaml', '--s3-bucket', 'someBucket', '--template-file', '/codebuild/output/src574895711/src/sam-app/template.json' returned non-zero exit status 255. 2019/04/24 13:18:15 Command did not exit successfully sam package --debug --template-file "${SAM_TEMPLATE}" --s3-bucket "${ARTIFACT_BUCKET}" --s3-prefix "${NOW}" --output-template-file "./${PACKAGED_FILE}" exit status 255 2019/04/24 13:18:15 Phase complete: BUILD State: FAILED

daTobiGit avatar Apr 25 '19 07:04 daTobiGit

@swetashre Here is the debug log

2019-04-24 17:00:48,122 - MainThread - awscli.customizations.cloudformation.artifact_exporter - DEBUG - Unable to export
Traceback (most recent call last):
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 254, in export
    self.do_export(resource_id, resource_dict, parent_dir)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 449, in do_export
    Template(template_path, parent_dir, self.uploader).export()
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 604, in export
    self.template_dict = self.export_global_artifacts(self.template_dict)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 563, in export_global_artifacts
    self.export_global_artifacts(val)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 563, in export_global_artifacts
    self.export_global_artifacts(val)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 563, in export_global_artifacts
    self.export_global_artifacts(val)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 563, in export_global_artifacts
    self.export_global_artifacts(val)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 561, in export_global_artifacts
    template_dict[key] = GLOBAL_EXPORT_DICT[key](val, self.uploader, self.template_dir)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 506, in include_transform_export_handler
    abs_include_location = os.path.join(parent_dir, include_location)
  File "/usr/lib64/python2.7/posixpath.py", line 75, in join
    if b.startswith('/'):
AttributeError: 'dict' object has no attribute 'startswith'
2019-04-24 17:00:48,123 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/clidriver.py", line 207, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/clidriver.py", line 348, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/commands.py", line 187, in __call__
    return self._run_main(parsed_args, parsed_globals)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/package.py", line 151, in _run_main
    exported_str = self._export(template_path, use_json)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/package.py", line 167, in _export
    exported_template = template.export()
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 617, in export
    exporter.export(resource_id, resource_dict, self.template_dir)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 262, in export
    ex=ex)
ExportFailedError: Unable to upload artifact src/workingHours/template.yaml referenced by Location parameter of WorkingHours resource.
'dict' object has no attribute 'startswith'
2019-04-24 17:00:48,124 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

Unable to upload artifact src/workingHours/template.yaml referenced by Location parameter of WorkingHours resource.
'dict' object has no attribute 'startswith'

bikerp avatar Apr 26 '19 07:04 bikerp

Cross-referencing #4087 and looping in @sanathkr.

justnance avatar May 07 '19 05:05 justnance

@bikerp - Thank you for your reply. Can you please provide me the full debug log so that we can know more about the issue.

swetashre avatar May 10 '19 22:05 swetashre

This is indeed an issue for me. When I downgrade i don't have an issue. I am performing the command in codebuild.

judahb avatar May 11 '19 00:05 judahb

@swetashre Here is the complete debug log:

2019-05-04 02:32:05,963 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.16.144 Python/2.7.5 Linux/3.10.0-957.10.1.el7.x86_64 botocore/1.12.134
2019-05-04 02:32:05,963 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['cloudformation', 'package', '--template-file', 'template.yaml', '--output-template-file', 'packaged.yaml', '--s3-bucket', 'pze-bucket', '--debug']
2019-05-04 02:32:05,964 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_scalar_parsers at 0x7f9d09cfdb90>
2019-05-04 02:32:05,965 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x7f9d0a5128c0>
2019-05-04 02:32:05,965 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x7f9d0a4e5e60>
2019-05-04 02:32:05,968 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x7f9d0a09e488>
2019-05-04 02:32:05,970 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /home/pavel/.local/lib/python2.7/site-packages/botocore/data/cloudformation/2010-05-15/service-2.json
2019-05-04 02:32:06,008 - MainThread - botocore.hooks - DEBUG - Event service-data-loaded.cloudformation: calling handler <function register_retries_for_service at 0x7f9d0b29c320>
2019-05-04 02:32:06,010 - MainThread - botocore.handlers - DEBUG - Registering retry handlers for service: cloudformation
2019-05-04 02:32:06,014 - MainThread - botocore.hooks - DEBUG - Event building-command-table.cloudformation: calling handler <function inject_commands at 0x7f9d0a1a6aa0>
2019-05-04 02:32:06,014 - MainThread - botocore.hooks - DEBUG - Event building-command-table.cloudformation: calling handler <function add_waiters at 0x7f9d09d0b1b8>
2019-05-04 02:32:06,027 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /home/pavel/.local/lib/python2.7/site-packages/botocore/data/cloudformation/2010-05-15/waiters-2.json
2019-05-04 02:32:06,030 - MainThread - botocore.hooks - DEBUG - Event building-command-table.package: calling handler <function add_waiters at 0x7f9d09d0b1b8>
2019-05-04 02:32:06,032 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.package.template-file: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f9d09bc0ed0>
2019-05-04 02:32:06,032 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.custom.package: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f9d09d12710>
2019-05-04 02:32:06,033 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.package.s3-bucket: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f9d09bc0ed0>
2019-05-04 02:32:06,034 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.custom.package: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f9d09d12710>
2019-05-04 02:32:06,034 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.package.kms-key-id: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f9d09bc0ed0>
2019-05-04 02:32:06,034 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.package.s3-prefix: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f9d09bc0ed0>
2019-05-04 02:32:06,035 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.package.output-template-file: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f9d09bc0ed0>
2019-05-04 02:32:06,035 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.custom.package: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f9d09d12710>
2019-05-04 02:32:06,036 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.package.use-json: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f9d09bc0ed0>
2019-05-04 02:32:06,036 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.custom.package: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f9d09d12710>
2019-05-04 02:32:06,036 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.package.force-upload: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f9d09bc0ed0>
2019-05-04 02:32:06,037 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.custom.package: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f9d09d12710>
2019-05-04 02:32:06,037 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.package.metadata: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f9d09bc0ed0>
2019-05-04 02:32:06,038 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2019-05-04 02:32:06,038 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2019-05-04 02:32:06,038 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2019-05-04 02:32:06,039 - MainThread - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials
2019-05-04 02:32:06,040 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /home/pavel/.local/lib/python2.7/site-packages/botocore/data/endpoints.json
2019-05-04 02:32:06,146 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f9d0b296aa0>
2019-05-04 02:32:06,147 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /home/pavel/.local/lib/python2.7/site-packages/botocore/data/s3/2006-03-01/service-2.json
2019-05-04 02:32:06,208 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.s3: calling handler <function add_generate_presigned_post at 0x7f9d0b2c2230>
2019-05-04 02:32:06,208 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.s3: calling handler <function add_generate_presigned_url at 0x7f9d0b2c2050>
2019-05-04 02:32:06,208 - MainThread - botocore.args - DEBUG - The s3 config key is not a dictionary type, ignoring its value of: None
2019-05-04 02:32:06,212 - MainThread - botocore.endpoint - DEBUG - Setting s3 timeout as (60, 60)
2019-05-04 02:32:06,214 - MainThread - botocore.client - DEBUG - Registering retry handlers for service: s3
2019-05-04 02:32:06,215 - MainThread - botocore.client - DEBUG - Defaulting to S3 virtual host style addressing with path style addressing fallback.
2019-05-04 02:32:06,345 - MainThread - awscli.customizations.cloudformation.artifact_exporter - DEBUG - Unable to export
Traceback (most recent call last):
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 254, in export
    self.do_export(resource_id, resource_dict, parent_dir)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 449, in do_export
    Template(template_path, parent_dir, self.uploader).export()
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 604, in export
    self.template_dict = self.export_global_artifacts(self.template_dict)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 563, in export_global_artifacts
    self.export_global_artifacts(val)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 563, in export_global_artifacts
    self.export_global_artifacts(val)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 563, in export_global_artifacts
    self.export_global_artifacts(val)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 563, in export_global_artifacts
    self.export_global_artifacts(val)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 561, in export_global_artifacts
    template_dict[key] = GLOBAL_EXPORT_DICT[key](val, self.uploader, self.template_dir)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 506, in include_transform_export_handler
    abs_include_location = os.path.join(parent_dir, include_location)
  File "/usr/lib64/python2.7/posixpath.py", line 75, in join
    if b.startswith('/'):
AttributeError: 'dict' object has no attribute 'startswith'
2019-05-04 02:32:06,346 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/clidriver.py", line 207, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/clidriver.py", line 348, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/commands.py", line 187, in __call__
    return self._run_main(parsed_args, parsed_globals)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/package.py", line 151, in _run_main
    exported_str = self._export(template_path, use_json)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/package.py", line 167, in _export
    exported_template = template.export()
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 617, in export
    exporter.export(resource_id, resource_dict, self.template_dir)
  File "/home/pavel/.local/lib/python2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 262, in export
    ex=ex)
ExportFailedError: Unable to upload artifact src/workingHours/template.yaml referenced by Location parameter of WorkingHours resource.
'dict' object has no attribute 'startswith'
2019-05-04 02:32:06,347 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

Unable to upload artifact src/workingHours/template.yaml referenced by Location parameter of WorkingHours resource.
'dict' object has no attribute 'startswith'

bikerp avatar May 13 '19 12:05 bikerp

Same issue here, downgrade to 1.16.141 and worked.

xu-lei-richard avatar May 21 '19 03:05 xu-lei-richard

Can confirm that this is happening to me as well.

orende avatar May 24 '19 12:05 orende

Same issue on aws-cli/1.16.160 Python/3.7.3 Darwin/18.6.0 botocore/1.12.150.

After reinstalling multiple versions of aws-clis and retrying to see at which version the bug occurs, it turns out the bug only happens on version awscli==1.16.144 and up to the current latest (1.16.169 right now).

Therefore downgrading to 143 is enough: pip3 install awscli==1.16.143

The bug also has another "flavour": join() argument must be str or bytes, not 'dict'. This bug occurred to me when using CloudFormation's intrinsic function Fn::Transform in conjecture with a !Ref (shorthand) or Ref (full form) :

'Fn::Transform':
    Name: 'AWS::Include'
        Parameters:
        Location: !Ref MyS3UrlParameter

The join() argument must be str or bytes, not 'dict' occurs when using the shorthand form !Ref The join() argument must be str or bytes, not 'OrderedDict' occurs when using the full form Ref

usr-ein avatar Jun 03 '19 09:06 usr-ein

Also happening to my team now.

zomgbre avatar Jun 04 '19 18:06 zomgbre

I'm using 1.16.170 and have the same issue

ShahoG avatar Jun 10 '19 04:06 ShahoG

Happening to us too with 1.16.170. It seems this has been broken for over a month - no official word?

sgates avatar Jun 13 '19 13:06 sgates

Fix was merged yesterday.. https://github.com/aws/aws-cli/issues/4087

sanathkr avatar Jun 13 '19 15:06 sanathkr