-
Notifications
You must be signed in to change notification settings - Fork 72
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
fix: Lambda client env var name issue #2324
Conversation
🦋 Changeset detectedLatest commit: c14ab2c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: Kamil Sobol <[email protected]>
packages/backend-data/src/factory.ts
Outdated
modelIntrospectionSchemaKey, | ||
['AMPLIFY_DATA_DEFAULT_NAME']: `${namePrefix}${this.name}`, | ||
// @deprecated | ||
[`${this.name}_GRAPHQL_ENDPOINT`]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this not create a duplicate when namePrefix
is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was worried about the same thing. Up on line 311, name prefix is left blank if the name is defaulted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not expected, we should avoid adding it. Also wanted to ask what's special about GRAPHQL_ENDPOINT
that this behavior is not replicated for the other _MODEL_INTROSPECTION_SCHEMA_BUCKET_NAME
and _MODEL_INTROSPECTION_SCHEMA_KEY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GRAPHQL_ENDPOINT
predates the MIS fields and customers may be depending on it directly. Since the other two are newer, @sobolk advised that they can be modified without concern for breaking change.
Also GRAPHQL_ENDPOINT
is included in the prefixing, however, we are leaving an unprefixed version in place with a @Deprecation flag to enable removal with the next major version change.
packages/backend-function/src/runtime/get_amplify_clients_configuration.ts
Outdated
Show resolved
Hide resolved
@@ -307,14 +308,32 @@ class DataGenerator implements ConstructContainerEntryGenerator { | |||
|
|||
convertJsResolverDefinition(scope, amplifyApi, schemasJsFunctions); | |||
|
|||
const namePrefix = this.name === defaultName ? '' : defaultName; | |||
|
|||
const ssmEnvironmentScopeContext = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const ssmEnvironmentScopeContext = { | |
const ssmEnvironmentEntries = { |
perhaps. this is a nit, feel free to ignore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This naming came from the function that receives these entries/vars ssmEnvironmentEntriesGenerator.generateSsmEnvironmentEntries(scopeContext)
. I'm going to proceed with this naming and can revisit it in another change if we decide its clearer with different naming.
['AMPLIFY_DATA_DEFAULT_NAME']: `${namePrefix}${this.name}`, | ||
}; | ||
|
||
const backwardsCompatibleScopeContext = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update this plz if you take above nit.
Problem
When using the
getAmplifyDataClientConfig
function with a nameddataBackend
, the SSM variable names don't line up.Example:
with
Results in a typescript error caused by mismatched env var names.
Issue number, if available:
#2320
Changes
AmplifyData
as a prefix (which is included even if a user defined name is providedAMPLIFY_DATA_DEFAULT_NAME
SSM variablegetAmplifyDataClientConfig
now uses the default name variable to use the correct env variablestoScreamingSnakeCase
into the export surface of'@aws-amplify/platform-core'
as SSM variables are normalized by this method and this normalization needs to be applied to consume these variables ingetAmplifyDataClientConfig
Validation
defineData({name: '', ...})
Checklist
run-e2e
label set.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.