cloudformation package generates S3BodyLocation by default
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.
Seems reasonable to me. @sanathkr what are your thoughts?
Yeah, this makes sense. Thanks for making this change.
Fixed via https://github.com/aws/aws-cli/pull/2322. Thanks again for the pull request.
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?
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).
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
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?
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!