serverless-appsync-plugin icon indicating copy to clipboard operation
serverless-appsync-plugin copied to clipboard

Write aws-exports.js / awsconfiguration.json after creating the AppSync API

Open debae opened this issue 3 years ago • 3 comments

We have an angular application that is getting deployed to S3 and I'm adding the AppSync config in the same serverless.yml. Our application which is running on S3 is using amplify and thus requires an aws-exports.js file.

Right now the appsync plugin only outputs the url / apikey / ... to the console.

So in order to get this to work we need to perform sls deploy, downloading the file from the AppSync console and doing another deploy to get the correct aws-exports.js file in there.

I searched already for an existing solution and stumbled upon https://www.serverless.com/plugins/aws-amplify-serverless-plugin but that one is archived.

debae avatar Apr 08 '21 21:04 debae

Thank you @debae for your feedback.

I did something similar in the past, unfortunately, I cannot put my hand on it. I remember using that plugin you mentioned in the past but it is indeed archived. If I remember well, I used https://www.npmjs.com/package/serverless-plugin-scripts to achieve the same thing. It requires some custom scripting though.

If you manage to do it, please share it with us here.

I guess we could also consider integrating some functionality to this plugin too.

bboure avatar Apr 09 '21 05:04 bboure

After rethinking this I decided not to go with the aws-exports.js file on S3 because that would mean that the api key for the AppSync api is publicly available. I do think there is a usecase for it when you don't put everything public.

debae avatar Apr 13 '21 19:04 debae

@debae Usually, it's OK if the API key is public for this kind of use case. Not sure if you are building a web or mobile app, but in any case, the API key is extractable (although it's harder no Mobile). You just need to make sure that the API key has no special privilege other than public access (eg: no admin endpoints). If you need privileged access, you need IAM, OIDC or Cognito.

bboure avatar Apr 14 '21 11:04 bboure