0

After code changes in stocks_alert.js based on client requirements, the error persisted when I try to run "Serverless invoke local -f stocks_alert".

Here's the complete error:

Error:
   Could not resolve "appsyncUrl" environment variable: Unsupported environment variable format:        {'Fn::GetAtt': [ 'GraphQlApi', 'GraphQLUrl' ] }

and the error pinpoints to the configuration from serverless.yml & invokelocalvar.yml:

Actual invokelocalvar.yml:

PROD:
 userPoolId: !ImportValue IQOS-UserPoolId-${self:custom.stage}
 appsyncUrl: !GetAtt GraphQlApi.GraphQLUrl
 appsyncApiKey: !GetAtt GraphQlApiKeyDefault.ApiKey
 clientId: !ImportValue "IQOS-UserWebclient-${self:custom.stage}"

LOCAL_PRE:
 userPoolId: ap-southeast-1_UWp5U3ImF
 appsyncUrl: https://lgrsmv2pgvdexogm2enpphiwji.appsync-api.ap-southeast-    1.amazonaws.com/graphql
 appsyncApiKey: da2-5mu4rrerq5fofcseyfal3zfzm4
 clientId: 49jgb26kp598r7g244tlfnh5ie

LOCAL_PROD:
 userPoolId: ap-southeast-1_TLwFqBRKT
 appsyncUrl: https://dsjyeun425bl7knwvquyejngwu.appsync-api.ap-southeast-1.amazonaws.com/graphql
 appsyncApiKey: da2-mwji6z7y3nbovhzwzhnd3ahaeu
 clientId: 4obtjmi3sq4lfbvlo1l149359m

This is from serverless.yml:

Actual config from serverless (under environment)

 appsyncUrl: !GetAtt GraphQlApi.GraphQLUrl
 appsyncApiKey: !GetAtt GraphQlApiKeyDefault.ApiKey

How do I resolve this kind of issue?

I already tried to modify the value of config from appsyncUrl and appsyncapiKey to put !ImportValue but I realize that the purpose of this is if the two configuration is running on different cloudformation stack, and I've already tried commenting out the two configurations(appsyncUrl & AppsyncapiKey) from serverless.yml because I though there's duplication of configuration in serverless.yml and invokelocalvar.yml.

My expectation is that running serverless invoke local -f stocks_alert succeeds, it will trigger the stocks_alert and sending alert to all recipients the low stock inventory of each warehouses via email.

1 Answer 1

0

Without looking at your full setup, I guess the problem is that serverless invoke local does not support all of the AWS CloudFormation intrinsic functions.

One solution is to use serverless-export-env plugin, basically follow the instruction in the Custom Resource Resolution section to map the !GetAtt to something else that works in the local environment.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.