-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
This issue occurs when running sam deploy.
There is a very similar issue that was fixed approx a year ago when running sam build:
#1839
I did place a comment on that closed issue
Description:
sam deploy transforms TemplateURL from S3 https link to local file path. It prepends the path from which the sam deploy command is run to the https link. Then, of course, it says the resulting TemplateURL is invalid.
The example provided is a basic CFN template to show the output but have seen this on full SAM templates with SAM resources as well.
Steps to reproduce:
AWSTemplateFormatVersion: '2010-09-09'
Transform: myTransform
Description: A test CFN template
Resources:
ExampleNestedStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://mybucket.s3.amazonaws.com/20210326_222039_m2/templates/Template/exampletemplate.y\
aml
- note that mybucket is not actual name of the bucket
sam deploy --role-arn my-admin-role --capabilities CAPABILITY_IAM --template-file Template/sample-template.yaml --stack-name my-sample-stack
Observed result:
Error: Unable to upload artifact https://mybucket.s3.amazonaws.com/20210326_222039_m2/templates/Template/exampletemplate.yaml referenced by TemplateURL parameter of ExampleNestedStack resource.
TemplateURL parameter of ExampleNestedStack resource is invalid. It must be a S3 URL or path to CloudFormation template file.
Actual: /home/ec2-user/project/myproj/Template/https:/mybucket.s3.amazonaws.com/20210326_222039_m2/templates/Template/exampletemplate.yaml
Expected result:
successful interpretation and deploy processing of TemplateURL as the provided https path, with no prepending:
https:/mybucket.s3.amazonaws.com/20210326_222039_m2/templates/Template/exampletemplate.yaml
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Amazon Linux 2 on t3.small instance
sam --version: 1.21.1- AWS region: us-west-2
Add --debug flag to command you are running
sam deploy --debug --role-arn my-admin-role --capabilities CAPABILITY_IAM --template-file Template/sample-template.yaml --stack-name my-sample-stack
2021-03-30 19:36:00,888 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.am\
azonaws.com/metrics
2021-03-30 19:36:00,889 | Using config file: samconfig.toml, config environment: default
2021-03-30 19:36:00,889 | Expand command line arguments to:
2021-03-30 19:36:00,890 | --template_file=/home/ec2-user/project/myproj/Template/sample-template.yaml --role_arn=my-admin-role --capabilities=('CAPABILITY_IAM',) --stack_name=my-sample-stack --fail_on_empty_changeset
2021-03-30 19:36:01,402 | Unable to export
Traceback (most recent call last):
File "samcli/lib/package/packageable_resources.py", line 119, in export
File "samcli/lib/package/artifact_exporter.py", line 77, in do_export
samcli.commands.package.exceptions.InvalidTemplateUrlParameterError: TemplateURL parameter of ExampleNestedStack resource is invalid. It must be a S3 URL or path to CloudFormation template file. Actual: /home/ec2-user/project/myproj/Template/https:mybucket.s3.amazonaws.com/20210326_222039_m2/templates/Template/exampletemplate.yaml