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

Dynamic URI in Swagger file #79

Closed
joshm91 opened this issue Feb 2, 2017 · 6 comments
Closed

Dynamic URI in Swagger file #79

joshm91 opened this issue Feb 2, 2017 · 6 comments

Comments

@joshm91
Copy link

joshm91 commented Feb 2, 2017

Hi,
Is there a way that I'm missing to have a more dynamic URI to the lambda function defined in a swagger file.

I've tried passing in region and arn/accountId variables in the same way that the function name is passed in in this example but it never works, even though I've confirmed that the variables contain the correct values.

The error I keep getting in the cloudformation console is

Errors found during import: Unable to put integration on 'GET' for resource at path '/preapproved-service/{service-name}': Invalid ARN specified in the request

Thanks for any advice

@sanathkr
Copy link
Contributor

sanathkr commented Feb 2, 2017

Unfortunately not. This is a API Gateway limitation and SAM does not have any control over it. You have to hard-code AccountId and Region in APIGateway until this limitation is fixed.

@mmuppidi
Copy link

Is this changed yet ? I have the same issue.

@joshm91
Copy link
Author

joshm91 commented Aug 31, 2017

I believe it's still the same. We've resorted to using inline swagger definitions being as our APIs are fairly simple.

@mkochco
Copy link

mkochco commented Mar 7, 2018

@sanathkr Following the api_swagger_cors example (minus cors) I'm still seeing 'Invalid Arn' when creating the stack. Do we still need to hard code the account and region when using a separate swagger.yml file?

@t-patt
Copy link
Contributor

t-patt commented Apr 25, 2018

+1, do we still have to in-line swagger?

@sparrowt
Copy link

sparrowt commented Nov 1, 2018

It seems swagger files referenced by DefinitionUri: still do not support substitution; neither !Sub or Fn::Sub: work, and AmazonApiGateway produces one of the following non-specific errors:

Errors found during import: Unable to put integration on 'GET' for resource at path '/foo': AWS ARN for integration must contain path or action (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: ...)
Errors found during import: Unable to put integration on 'GET' for resource at path '/foo': Invalid ARN specified in the request
Unable to parse API definition because of a malformed integration at path /foo. (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: ...)

depending on exactly how you try - all somewhat lacking in clarity / line number of error.

However there does appear to be a solution which doesn't involve inlining the swagger: this example template.yaml uses Fn::Transform & AWS::Include to bring in a swagger.yaml file from S3 like so:

        DefinitionBody:
          'Fn::Transform':
            Name: 'AWS::Include'
            # Replace <bucket> with your bucket name
            Parameters:
              Location: s3://<bucket>/swagger.yaml

and the accompanying example swagger.yaml contains substitutions which will be filled in with the relevant values.

EDIT: turns out @dinvlad posted about this here already #8 (comment) see also https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/create-reusable-transform-function-snippets-and-add-to-your-template-with-aws-include-transform.html

EDIT: see also aws/aws-cli#3454 which (I think) enables this to work for local files by auto-uploading them to s3 first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants