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

(feat) CloudFormation AWS::ApiGateway::Methods and AWS::ApiGateway::Resources support #1247

Merged
merged 78 commits into from
Aug 12, 2019

Conversation

viksrivat
Copy link
Contributor

Issue #, if available:

Description of changes:
Extends of #1239 to support AWS::ApiGateway::Resources
Checklist:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

viksrivat and others added 30 commits June 17, 2019 16:26
The Api object now contains a list of routes and the attributes associated with it. The rest of the code is also managed in terms of routes/endpoints.
This will allow for easy extensability if the Apis will grouped into different sections
…ures

Restructure the information Api has the way it passed through
…ksrivat/aws-sam-cli into feature/cloud_formation_stage_support
@viksrivat viksrivat changed the base branch from develop to start-api/cfn July 29, 2019 18:05
@jfuss jfuss changed the base branch from start-api/cfn to develop August 9, 2019 03:15
Copy link
Contributor

@jfuss jfuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Looks like flake8 isn't happy. Can you address that as well, so we can make sure make pr passes and touched/new files have good tests coverage?

samcli/commands/local/lib/cfn_api_provider.py Outdated Show resolved Hide resolved

Parameters
----------
logical_id : str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: keep the order they are defined in the function.

samcli/commands/local/lib/cfn_api_provider.py Outdated Show resolved Hide resolved

resource_path = ""
if isinstance(resource_id, string_types):
resource = resources.get(resource_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would help in being more explicit about what resource this is. It took me awhile to understand what was going on here. Maybe a comment above the if isinstance would be helpful to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if instance can be removed once we merge in the intrinsic pr since the Refs will resolve to a string.

if resource:
resource_path = self.resolve_resource_path(resources, resource, "")
else:
resource_path = resource_id # In this case, the path was resolved to a string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment right? This line gets executed if resource is falsey, not that the path was resolved to a string. This assigns the resource_path to be the resource_id, but should be the root path then right? Sorry having a hard time following this path right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment to reflect it. This comment is referring to the case that is a ref of a raw resolved string such as { "Fn::GetAtt": ["MyRestApi", "RootResourceId"] }

samcli/commands/local/lib/cfn_api_provider.py Outdated Show resolved Hide resolved
samcli/commands/local/lib/route_collector.py Outdated Show resolved Hide resolved
@@ -0,0 +1,127 @@
AWSTemplateFormatVersion: '2010-09-09'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume once the intrinsics PR gets merged and integrated, you will add some testdata and integ tests for resource and methods that are defined with intrinsics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ye. A lot of the code resource and methods is based on intrinsic references. When that is merged, all the tests will be updated to use intrinsics.

HttpMethod: "GET"
Integration:
Uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${WhatFunction.Arn}/invocations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the Uri is defined just by a string instead of an Intrinsic Fn::Sub?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't really matter because all properties will be resolved using intrinsics

@jfuss
Copy link
Contributor

jfuss commented Aug 10, 2019

@viksrivat Looks like tests.integration.local.start_api.test_start_api.TestStartApiWithMethodsAndResources testMethod=test_binary_request is failing on all python versions. Can you please address the failing test?

@jfuss jfuss merged commit 7790659 into aws:develop Aug 12, 2019
viksrivat added a commit to viksrivat/aws-sam-cli that referenced this pull request Aug 14, 2019
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

Successfully merging this pull request may close these issues.

2 participants