Cloudformation CLI package macro invalid template file path error

94 Views Asked by At

I am attempting to use Cloudformation Explode macro for adding multiple routes to a route table destination. Using the macro is demonstrated here: https://github.com/awslabs/aws-cloudformation-templates/tree/master/aws/services/CloudFormation/MacrosExamples/Explode

Transform: AWS::Serverless-2016-10-31

Resources:
  MacroFunction:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: python3.7
      PackageType: Zip
      CodeUri: s3://<my bucket name>/macros/lambda/
      Handler: explode.handler

  Macro:
    Type: AWS::CloudFormation::Macro
    Properties:
      Name: Explode
      FunctionName: 
        Fn::GetAtt: MacroFunction.Arn
$ aws cloudformation package --template-file s3://<my bucket name>/macros/macro.yaml --s3-bucket <my bucket arn> --output-template-file packaged.yaml                              
Invalid template path s3://********************/macros/macro.yaml

$ aws cloudformation package --template-file https://<mybucketname.s3.amazonaws.com/macros/macro.yaml --s3-bucket <my bucket arn> --output-template-file packaged.yaml          
Invalid template path https://*************.s3.amazonaws.com/macros/macro.yaml

I have the tried both the URI and URL inputs for the template file path parameter but have been unable to get the command to take the --template-file parameter data that I pass into it. I have the artifacts located in an S3 bucket. Meaning their exists an object folder in my cloudformation templates bucket called macros/ which contains the template macro.yaml in it in addition to the /lambda folder which further contains explode.py. My macro.yaml references the S3 URI for lambda in the CodeUri property.

Not sure what else to try. I am using the cloudshell for this operation as I am limited to doing it from the management console and not my local machine so I do not have the template nor the lambda code stored in a local path directory. Is this the problem? Thank you in advance.

1

There are 1 best solutions below

0
Seph On

Not sure if this helps but you can upload files to cloudshell's directory under /home/cloudshell-user. On the top right corner of cloudshell, there is the Actions button which allows you to upload your template files. If you have folder, I will upload the folder as a zip before running unzip <zip file>. Alternatively, you should be able to sync your files from a S3 bucket to the cloudshell directory as well. Can check out : https://docs.aws.amazon.com/cloudshell/latest/userguide/multiple-files-upload-download.html