Skip to content

Local invoke AWS CF function resolution for env variable : Fn::ImportValue#8157

Merged
medikoo merged 6 commits into
serverless:masterfrom
fredericbarthelet:import-value-env-resolution
Sep 1, 2020
Merged

Local invoke AWS CF function resolution for env variable : Fn::ImportValue#8157
medikoo merged 6 commits into
serverless:masterfrom
fredericbarthelet:import-value-env-resolution

Conversation

@fredericbarthelet

Copy link
Copy Markdown
Contributor

This PR uses work already done in #7147
It is focus only on Fn::ImportValue resolution as the service resolveCfImportValue already exists within Serverless framework and is currently in use by getStackInfo service for httpApi external id import resolution.
Additional PRs will be issued to implement as well GetAtt and Ref function resolution.

Addresses: #7087 #8147

Comment thread lib/plugins/aws/invokeLocal/index.js Outdated
@codecov-commenter

codecov-commenter commented Aug 31, 2020

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.23%. Comparing base (87fd3c1) to head (49796ba).

Files with missing lines Patch % Lines
lib/plugins/aws/info/getStackInfo.js 50.00% 1 Missing ⚠️
lib/plugins/aws/invokeLocal/index.js 93.75% 1 Missing ⚠️
lib/plugins/aws/utils/resolveCfImportValue.js 50.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8157      +/-   ##
==========================================
+ Coverage   88.21%   88.23%   +0.02%     
==========================================
  Files         248      248              
  Lines        9416     9421       +5     
==========================================
+ Hits         8306     8313       +7     
+ Misses       1110     1108       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@medikoo medikoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @fredericbarthelet! It looks promising. Please see my comment

Comment thread lib/plugins/aws/utils/resolveCfFunctionValue.js Outdated
Comment thread lib/plugins/aws/invokeLocal/index.js Outdated
Comment thread lib/plugins/aws/invokeLocal/index.js Outdated
@fredericbarthelet
fredericbarthelet force-pushed the import-value-env-resolution branch from 6359980 to 01b1c9d Compare September 1, 2020 09:08
@fredericbarthelet

Copy link
Copy Markdown
Contributor Author

@medikoo I updated my PR with your comments :)

@medikoo medikoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @fredericbarthelet that looks great. I've left just one minor remark

Comment thread lib/plugins/aws/info/getStackInfo.js Outdated
Comment thread lib/plugins/aws/info/getStackInfo.js Outdated
@fredericbarthelet
fredericbarthelet force-pushed the import-value-env-resolution branch 3 times, most recently from f00e6e6 to 2d0317d Compare September 1, 2020 11:18

@medikoo medikoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fredericbarthelet looks great, still I've just noticed one last minor (DX related) thing.

Comment thread lib/plugins/aws/utils/resolveCfImportValue.js Outdated

@medikoo medikoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @fredericbarthelet !

@maghirardelli

Copy link
Copy Markdown

How would these changes be used within a serverless.yaml file? I am currently using it as this and still getting my env variable set as [object Object]:

custom:
  backendTools:
    environmentOverrides: 
      lambdas:
        lambdaName:
          environment:
            LOCAL_ARN:
              'Fn::ImportValue': '${AuthenticationLayerHandlerRoleArn}'

@medikoo

medikoo commented Oct 5, 2022

Copy link
Copy Markdown
Contributor

@maghirardelli are you using plugin to port those env variables to lambda. Also do you see [object Object] in actual lambda, or maybe local invocation?

@maghirardelli

Copy link
Copy Markdown

@medikoo I am not using a plugin to port those env variable to lambda. I am running sls offline so local invocation.

@medikoo

medikoo commented Oct 5, 2022

Copy link
Copy Markdown
Contributor

@maghirardelli In case of local invocation cloudformation intristic functions are not supported.

@maghirardelli

Copy link
Copy Markdown

@medikoo Oh, I thought that was what this PR was adding support for. What does this PR do then?

@medikoo

medikoo commented Oct 5, 2022

Copy link
Copy Markdown
Contributor

@maghirardelli indeed, I totally forgot we've got partial support, and resolve Fn::ImportValue and Ref if possible.

Still environment variables for functions are configured either at provider.environment or functions[].environment, while you refer to configuration in custom block (hence by question about plugins)

@maghirardelli

Copy link
Copy Markdown

@medikoo Ah, that makes sense. Thanks for the info and the speedy responses!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants