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: sam support to add resource policies to api properties #1045

Merged
merged 10 commits into from Aug 1, 2019

Conversation

praneetap
Copy link
Contributor

@praneetap praneetap commented Jul 26, 2019

Issue #, if available:
#514
Description of changes:
Added support for resource policies on api definition in SAM.
Description of how you validated changes:
Transformed this template locally and deployed it on CFN successfully. I could invoke the API successfully.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
  Api:
    Auth:
      ResourcePolicy:
        CustomStatements: [{
            "Effect": "Allow",
            "Principal": "*",
            "Action": "execute-api:Invoke",
            "Resource": "execute-api:*/*/*",
            "Condition": {
                "IpAddress": {
                    "aws:SourceIp": "1.2.3.4"
                }
            }
        }]
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      InlineCode: |
        exports.handler = async () => "Hello Worlds!"
      Handler: index.handler
      Runtime: nodejs8.10
      Events:
        Api:
          Type: Api
          Properties:
            Method: Put
            Path: /get

Checklist:

  • Write/update tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected
  • Add/update example to examples/2016-10-31

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

@codecov-io
Copy link

codecov-io commented Jul 26, 2019

Codecov Report

Merging #1045 into develop will decrease coverage by 0.11%.
The diff coverage is 77.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #1045      +/-   ##
==========================================
- Coverage    94.91%   94.8%   -0.12%     
==========================================
  Files           69      69              
  Lines         3248    3274      +26     
  Branches       631     639       +8     
==========================================
+ Hits          3083    3104      +21     
- Misses          87      89       +2     
- Partials        78      81       +3
Impacted Files Coverage Δ
samtranslator/plugins/globals/globals.py 99% <ø> (ø) ⬆️
samtranslator/model/api/api_generator.py 96.66% <100%> (+0.02%) ⬆️
samtranslator/swagger/swagger.py 95.68% <73.68%> (-1.28%) ⬇️
samtranslator/model/sam_resources.py 95.65% <0%> (+0.02%) ⬆️
samtranslator/model/apigateway.py 97.76% <0%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 71de14a...da2ada1. Read the comment docs.

@praneetap praneetap requested review from keetonian and jlhood and removed request for keetonian July 26, 2019 18:08
Copy link
Contributor

@keetonian keetonian 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, just one minor comment about a comment.

tests/translator/input/api_with_resource_policy.yaml Outdated Show resolved Hide resolved
keetonian
keetonian previously approved these changes Jul 30, 2019
@keetonian keetonian dismissed their stale review July 30, 2019 21:46

Changes needed

Copy link
Contributor

@jlhood jlhood left a comment

Choose a reason for hiding this comment

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

Awesome. Thanks for iterating on this!

@praneetap praneetap merged commit 5090228 into aws:develop Aug 1, 2019
@praneetap praneetap deleted the resource-policy branch August 1, 2019 22:58
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.

None yet

4 participants