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

Fully populate mock function environment variables #6551

Merged
merged 6 commits into from
Feb 12, 2021

Conversation

edwardfoyle
Copy link
Contributor

@edwardfoyle edwardfoyle commented Feb 4, 2021

Issue #, if available:
#4635, #4234, #6548, #6533, #3124, #1378, #691

Description of changes:
Populates environment variables when running amplify mock function by:
1. Not leaking any system environment variables into the mock lambda execution
2. Providing reasonable defaults for common lambda env vars specified here (https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime)
3. Loading aws access keys from the profile that the CLI is currently configured to use
3. Resolving parameters specified in team-provider-info.json
4. Resolving parameters specified in parameters.json
5. Resolving parameters from other resources in the project (eg. API names, table names)
6. Override GraphQL API endpoint env var to local mock endpoint when mock api is running
7. Load “mock only” env vars from a .env file in the function’s directory

1-6 should provide reasonable defaults for most customers and 7 provides a simple mechanism for customers to override / add environment variables only in the context of mock

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

@codecov
Copy link

codecov bot commented Feb 4, 2021

Codecov Report

Merging #6551 (f909b2b) into master (819a749) will decrease coverage by 0.01%.
The diff coverage is 42.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6551      +/-   ##
==========================================
- Coverage   56.93%   56.92%   -0.02%     
==========================================
  Files         484      484              
  Lines       21904    22014     +110     
  Branches     4373     4401      +28     
==========================================
+ Hits        12472    12531      +59     
- Misses       8551     8604      +53     
+ Partials      881      879       -2     
Impacted Files Coverage Δ
packages/amplify-cli-core/src/index.ts 95.00% <ø> (ø)
packages/amplify-cli/src/context-extensions.ts 31.29% <0.00%> (ø)
packages/amplify-cli/src/domain/amplify-toolkit.ts 2.94% <ø> (+0.02%) ⬆️
...lify-nodejs-function-runtime-provider/src/index.ts 0.00% <0.00%> (ø)
...function-runtime-provider/src/utils/invokeUtils.ts 100.00% <ø> (ø)
...nction-runtime-provider/src/utils/legacyPackage.ts 0.00% <0.00%> (ø)
...il-mock/src/CFNParser/resource-processors/index.ts 0.00% <0.00%> (ø)
...l-mock/src/CFNParser/resource-processors/lambda.ts 0.00% <0.00%> (ø)
...kages/amplify-util-mock/src/__e2e__/utils/index.ts 0.00% <0.00%> (ø)
...plify-util-mock/src/__e2e__/utils/lambda-helper.ts 0.00% <0.00%> (ø)
... and 21 more

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 2977c6a...f909b2b. Read the comment docs.

@lgtm-com
Copy link

lgtm-com bot commented Feb 4, 2021

This pull request introduces 1 alert and fixes 2 when merging 008e389 into 8647486 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

fixed alerts:

  • 2 for Unused variable, import, function or class

@edwardfoyle edwardfoyle changed the title Mock env vars Fully populate mock function environment variables Feb 5, 2021
@lgtm-com
Copy link

lgtm-com bot commented Feb 5, 2021

This pull request introduces 1 alert and fixes 2 when merging d8b399e into a16e8b8 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

fixed alerts:

  • 2 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Feb 6, 2021

This pull request introduces 1 alert and fixes 3 when merging baf49f4 into a16e8b8 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

fixed alerts:

  • 3 for Unused variable, import, function or class

@edwardfoyle edwardfoyle marked this pull request as ready for review February 8, 2021 19:31
@edwardfoyle edwardfoyle requested a review from a team as a code owner February 8, 2021 19:31
@edwardfoyle edwardfoyle requested review from jhockett and yuth February 8, 2021 19:31
@lgtm-com
Copy link

lgtm-com bot commented Feb 8, 2021

This pull request fixes 3 alerts when merging 3d9fe6c into a66bd14 - view on LGTM.com

fixed alerts:

  • 3 for Unused variable, import, function or class

Copy link
Contributor

@jhockett jhockett left a comment

Choose a reason for hiding this comment

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

LGTM

@lgtm-com
Copy link

lgtm-com bot commented Feb 10, 2021

This pull request fixes 3 alerts when merging 3fe813c into b866ccc - view on LGTM.com

fixed alerts:

  • 3 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Feb 12, 2021

This pull request fixes 3 alerts when merging 3e01644 into 31eb8eb - view on LGTM.com

fixed alerts:

  • 3 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Feb 12, 2021

This pull request fixes 3 alerts when merging f909b2b into 2977c6a - view on LGTM.com

fixed alerts:

  • 3 for Unused variable, import, function or class

@edwardfoyle edwardfoyle merged commit dceb13a into aws-amplify:master Feb 12, 2021
@github-actions
Copy link

This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants