Skip to content

SAM CLI fails with virtual-hosted style S3 URLs #2499

@steenda

Description

@steenda

Description:

SAM CLI doesn't recognize virtual-hosted style S3 URLs. AWS Cloudformation can handle both URL types.

Steps to reproduce:

Both URLs are fine, but the NewS3Url Resource is being rejected by SAM.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2017-10-31

Resources:
  OutdatedS3Url:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: https://s3.eu-central-1.amazonaws.com/cloudformation-templates-eu-central-1/S3_Website_With_CloudFront_Distribution.template

  NewS3Url:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: https://cloudformation-templates-eu-central-1.s3.eu-central-1.amazonaws.com/S3_Website_With_CloudFront_Distribution.template

Observed result:

steenda:~$ sam deploy --template-file test.yml  --stack-name test --debug
2020-12-22 15:27:15,530 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-22 15:27:15,813 | Unable to export
Traceback (most recent call last):
  File "/home/steenda/.local/pipx/venvs/aws-sam-cli/lib/python3.8/site-packages/samcli/lib/package/packageable_resources.py", line 115, in export
    self.do_export(resource_id, resource_dict, parent_dir)
  File "/home/steenda/.local/pipx/venvs/aws-sam-cli/lib/python3.8/site-packages/samcli/lib/package/artifact_exporter.py", line 80, in do_export
    raise exceptions.InvalidTemplateUrlParameterError(
samcli.commands.package.exceptions.InvalidTemplateUrlParameterError: TemplateURL parameter of NewS3Url resource is invalid. It must be a S3 URL or path to CloudFormation template file. Actual: /home/steenda/https:/cloudformation-templates-eu-central-1.s3.eu-central-1.amazonaws.com/S3_Website_With_CloudFront_Distribution.template
2020-12-22 15:27:15,813 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam deploy', 'duration': 282, 'exitReason': 'ExportFailedError', 'exitCode': 1, 'requestId': '0c6f2f0f-3b5b-42b8-9a30-23bbae5a0eca', 'installationId': 'dd2dcedc-ef5e-46b5-add4-b7049b3f34d0', 'sessionId': '7cabcb58-d269-41ac-80b0-1aa4a3e6e95b', 'executionEnvironment': 'CLI', 'pyversion': '3.8.5', 'samcliVersion': '1.15.0'}}]}
2020-12-22 15:27:16,635 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: Unable to upload artifact https://cloudformation-templates-eu-central-1.s3.eu-central-1.amazonaws.com/S3_Website_With_CloudFront_Distribution.template referenced by TemplateURL parameter of NewS3Url resource.
TemplateURL parameter of NewS3Url resource is invalid. It must be a S3 URL or path to CloudFormation template file. Actual: /home/steenda/https:/cloudformation-templates-eu-central-1.s3.eu-central-1.amazonaws.com/S3_Website_With_CloudFront_Distribution.template

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions