#I'm certain some of the stuff I'm

1 messages · Page 1 of 1 (latest)

tough iris
#

I'm literally here looking for answers to my problems with my production build in Azure. So what is the issue with your prod build?

royal merlin
#

You can deploy nextjs to amplify pretty seamlessly

#

(If you aren’t using app dir)

#

If you are there’s a bit more config

proud meteor
#

Mostly connections, ports, headers, et cetera. The biggest issues we're dealing with right now are running a build and having it connect to our API to generate static pages (it needs a list of records for several pages to generate dynamic pages). We've been trying several ways to set up servers, either through an EC2 instance of frontend that connects to EC2 backend or connecting EC2 backend using Amplify frontend

#

@royal merlin my issue with Amplify isn't the deploy it is setting up EC2 to accept connections from Amplify

royal merlin
#

Oh

#

Well that’s not really a nextjs thing

#

You gotta make the ec2 publicly accessible

proud meteor
#

I'm aware, I just don't know how to find a solution. Pretty much trying to look everywhere at this point because I'm not a devops engineer

royal merlin
#

Because amplify can’t talk to private ec2 instance

proud meteor
#

If I could whitelist the Amplify instance that would be ideal, but there's no where to get an IP of the instance

royal merlin
#

You can’t

#

Amplify is serverless

#

The ips are always different

proud meteor
#

I don't think it's feasible to open our API to public without any authentication

royal merlin
#

So it’s not possible to whitelist it

#

It’s not, you gotta add auth 👍

#

That could be something as simple as a hardcoded key that gets sent as a header

#

And you confirm in the api that the key matches the predicted env variable

proud meteor
#

I see. I guess I will need to look into that.

royal merlin
#

Good luck.

proud meteor
#

So setting up a key as a header using next.config.js that is verified by the backend could be the way that is setup?

tough iris
#

thanks for that @royal merlin - I'll be trying aws soon

royal merlin
#

Idk about next.config

#

I mean when sending requests to your api

#

Include the key in the headers

proud meteor
#

Ah, in request headers okay, that makes sense.

royal merlin
#

Where the key comes in terms of env variables and how it gets injected into your app is up to you

proud meteor
#

Yeah, does Amplify have a way to use the secrets manager like EC2 instances do?

royal merlin
#

Anything on aws can access the secret manager

#

But it may not always be obvious how via their ui

#

You can add env variables to amplify via their ui but they don’t go into secrets manager

#

If you want to use secrets manager you gotta name the keys using a certain pattern so amplify knows how to pick it up. Google for it

#

Or you can access the secret manager programmatically inside of your next config

#

And load the secrets during build time

proud meteor
#

Yeah, so our .env file usually gets records during the server build in EC2 using linux commands to just echo the variables from the secrets m anager

royal merlin
#

Using the aws JavaScript api