aws / aws/aws-sam-cli

Bug: SAM CLI init --location fails when using CloudFront signed URLs

Open
#4,193 2 comments 0 reactions 0 assignees View on GitHub
stage/pm-review type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:

sam init --location "CloudFront signed URL here" fails with message "Error: The template location specified is not valid:..."

### Steps to reproduce:

sam init --name "serverless-workshop" --location "https://static.us-east-1.prod.workshops.aws/8b7894f9-1c6c-4cb5-900a-a876378e79f3/static/serverless-workshop.zip?Policy=eyJTdGF0ZW1lbnQiOlt7...............2MjczNTcwMn19fV19&Key-Pair-Id=K36Q....7QD&Signature=JlDsUTg....U601jtB1F4WVHdgRRgST72UpZNr5A__"

### Observed result:

Error: The template location specified is not valid: https://static.us-east-1.prod.workshops.aws/8b7894f9-1c6c-4cb5-900a-a876378e79f3/static/serverless-workshop.zip?Policy=eyJTdGF.......TcwMn19fV19&Key-Pair-Id=K36Q....7QD&Signature=JlDsUT....5iPhutGU601jtB1F4WVHdgRRgST72UpZNr5A__

### Expected result:

Expect to get template zip file and use it as an initial structure.
wget is able to get referred file just fine:
wget "https://static.us-east-1.prod.workshops.aws/8b7894f9-1c6c-4cb5-900a-a876378e79f3/static/serverless-workshop.zip?Policy=eyJTdGF0ZW1l................................BB1F4WVHdgRRgST72UpZNr5A__"

The destination name is too long (641), reducing to 236
--2022-09-02 08:02:48-- https://static.us-east-1.prod.workshops.aws/8b7894f9-1c6c-4cb5-900a-a876378e79f3/static/serverless-workshop.zip?Policy=eyJTdG....Mn19fV19&Key-Pair-Id=K36Q....QD&Signature=JlDsUT....VHdgRRgST72UpZNr5A__
Resolving static.us-east-1.prod.workshops.aws (static.us-east-1.prod.workshops.aws)... ...
Connecting to static.us-east-1.prod.workshops.aws (static.us-east-1.prod.workshops.aws)|....|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6911 (6.7K) [application/zip]
Saving to: ‘serverless-workshop.zip?Policy=eyJTd....ltZ’

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

1. OS: MacOS 12.5.1
2. `sam --version`: SAM CLI, version 1.55.0
3. AWS region: us-east-1

`Add --debug flag to command you are running`
Debug output (sanitized):
sam init --debug --name "serverless-workshop" --location "https://static.us-east-1.prod.workshops.aws/68d00a0b-2a7c-4d81-813a-0857fcda6e34/static/serverless-workshop.zip?Policy=eyJTdGF0ZW...19fV19&Key-Pair-Id=K3...QD&Signature=SRO...xwYClANHOzQ__"

2022-09-02 10:11:52,512 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-09-02 10:11:52,512 | Using config file: samconfig.toml, config environment: default
2022-09-02 10:11:52,512 | Expand command line arguments to:
2022-09-02 10:11:52,512 | --name=serverless-workshop --location=https://static.us-east-1.prod.workshops.aws/68d00a0b-2a7c-4d81-813a-0857fcda6e34/static/serverless-workshop.zip?Policy=eyJTdGF0...zQ4M319fV19&Key-Pair-Id=K36Q...7QD&Signature=SROJkP...ClANHOzQ__ --package_type=Zip --output_dir=.
2022-09-02 10:11:52,512 | Parameters dict created with input given
2022-09-02 10:11:52,512 | {'template': 'https://static.us-east-1.prod.workshops.aws/68d00a0b-2a7c-4d81-813a-0857fcda6e34/static/serverless-workshop.zip?Policy=eyJTdGF0ZW1lbn...Q4M319fV19&Key-Pair-Id=K36...7QD&Signature=SROJ...YClANHOzQ__', 'output_dir': '.', 'no_input': False, 'extra_context': {'project_name': 'serverless-workshop', 'architectures': {'value': ['x86_64']}}}
2022-09-02 10:11:52,512 | Baking a new template with cookiecutter with all parameters
2022-09-02 10:11:52,512 | Template is not provided in context, skip adding project type metric
2022-09-02 10:11:52,512 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'fb618529-9b02-4de9-8b57-8c5f8ed3edde', 'installationId': '81da5cc0-a155-4908-b68d-8ee9abe09653', 'sessionId': '474d5007-2e4a-4064-bf9a-c41d5810d2c4', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.13', 'samcliVersion': '1.55.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam init', 'duration': 0, 'exitReason': 'InvalidLocationError', 'exitCode': 1}}]}
2022-09-02 10:11:52,759 | Telemetry response: 200
Error: The template location specified is not valid: https://static.us-east-1.prod.workshops.aws/68d00a0b-2a7c-4d81-813a-0857fcda6e34/static/serverless-workshop.zip?Policy=eyJTdGF0ZW1l...Q4M319fV19&Key-Pair-Id=K36...7QD&Signature=SROJkPKXr...8OuMUEdnAZ4AxwYClANHOzQ__

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.