Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudformation package generates S3BodyLocation by default #2320

Closed
dtimberlake opened this issue Dec 13, 2016 · 8 comments
Closed

cloudformation package generates S3BodyLocation by default #2320

dtimberlake opened this issue Dec 13, 2016 · 8 comments
Labels
cloudformation package-deploy customization Issues related to CLI customizations (located in /awscli/customizations) feature-request A feature should be added or improved.

Comments

@dtimberlake
Copy link
Contributor

Introduction

aws cloudformation package currently creates S3BodyLocation for AWS::ApiGateway::RestApi even when no swagger file is specified in the S3BodyLocation property. The default action is to zip the entire working directory and upload it to S3.

Since this this parameter is not required (you can specify an inline Body or just use other resources to specify your api), I believe this should only run when you explicitly specify a swagger file.

Reproduce

1. Create initial template

# template.yml
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  RestApi:
    Type: AWS::ApiGateway::RestApi
    Properties:
        Name: !Ref AWS::StackName

2. Package code (this will zip your entire current directory and upload)

aws cloudformation package \
  --template-file template.yml \
  --s3-bucket <bucket> \
  --output-template-file package-template.yml

This generate package-template.yml

Resources:
  RestApi:
    Properties:
      BodyS3Location:
        Bucket: <bucket>
        Key: <key>
      Name:
        Ref: AWS::StackName
    Type: AWS::ApiGateway::RestApi

Workaround

Remove BodyS3Location once the template has been created and remove the uploaded artifact from S3. Can't do anything about the cost associated with the initial upload.

@kyleknap
Copy link
Contributor

Seems reasonable to me. @sanathkr what are your thoughts?

@kyleknap kyleknap added feature-request A feature should be added or improved. cloudformation package-deploy labels Dec 16, 2016
@sanathkr
Copy link
Contributor

Yeah, this makes sense. Thanks for making this change.

@jamesls
Copy link
Member

jamesls commented Jan 7, 2017

Fixed via #2322. Thanks again for the pull request.

@dksheffield
Copy link

So i see this issue as closed but it is still happening to me using cloudformation package. Am i missing something? Is the fix not rolled out yet?

@dtimberlake
Copy link
Contributor Author

What version of the API are you using? Also, can you show me the AWS::ApiGateway::RestApi resource portion of your config?

I tried it with the example above and it worked fine for me (I know, not what you're looking to hear).

@dksheffield
Copy link

API Version - aws-cli/1.11.44 Python/2.7.12 Linux/4.4.0-64-generic botocore/1.5.7

not sure how to embed yaml code so here is the gist - https://gist.github.com/dksheffield/8e4654a0143d386b68e7d8a991544cfc

@dtimberlake
Copy link
Contributor Author

This issue was in reference to AWS::ApiGateway::RestApi not AWS::Serverless::Api. Can you share the template that is output when you package that file?

@dksheffield
Copy link

Using standard cft - when I package this - https://gist.github.com/dksheffield/80f332d1151c2fcb59307c44b739e680

It outputs this - https://gist.github.com/dksheffield/6e08182f695d8276afdf9d8a57bd868e

Which appears to be correct. It's when I package the AWS::Serverless::Api that it adds the line DefinitionUri: s3://candhtrailers.com-builds/contact-us-ms-builds/00aa6ea076936e6213225a697d33dee1 and that line messes up my deploy command.

I'll post this over on the Serverless API repo and see what they say. Thanks!

@kdaily kdaily added the customization Issues related to CLI customizations (located in /awscli/customizations) label Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloudformation package-deploy customization Issues related to CLI customizations (located in /awscli/customizations) feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

6 participants