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

nx-serve only works with dev environments #77

Open
vespertilian opened this issue Mar 30, 2021 · 4 comments
Open

nx-serve only works with dev environments #77

vespertilian opened this issue Mar 30, 2021 · 4 comments

Comments

@vespertilian
Copy link

Hey,

So I have an account-based AWS setup (separate accounts for each env). I changed the stack suffix from dev to prod as they are all effectively prod.

However, I can not serve locally when using layers as we seem to use a mimic env var which does not set the layer suffix, layers are also deployed as my-layer-name-[dev/prod].

I was looking at trying to add this however I cannot seem to even build the master branch. There was no package.lock file checked in so maybe an update has broken the build?

Screen Shot 2021-03-30 at 10 09 10 pm

suffixes.

Can you build the project after an npm install?

Also, I am thinking maybe mimicEnv useDeployedSuffix ? Or does it mimic other aspects of the build?

@studds
Copy link
Owner

studds commented Mar 30, 2021

There was no package.lock file checked in so maybe an update has broken the build?

The repo uses yarn now, not npm. So it's got a yarn.lock and you install deps using yarn.

That type of error often clears up after removing node_modules and installing again.

I've never tested mimicEnv across accounts so I'm not sure if there's any gotchas there. But essentially all it's doing is finding a stack and grabbing the environment variables from lambdas in that stack, and importing them locally. That's not relevant to layers, because the layer arn is not an environment variable.

The layer arn is derived from a stack output. The relevant parts of the example config:

"serve": {
  "builder": "@nx-aws/sam:execute",
  "options": {
    "buildTarget": "api:build",
    "packageTarget": "api:package",
    "importStackOutputs": {
      "TestLayer": {
        "targetName": "layer:deploy",
        "outputName": "TestLayer"
      },
      "LibAsLayer": {
        "targetName": "lib-as-layer:deploy",
        "outputName": "LibAsLayer"
      }
    },
    "mimicEnv": "dev"
  }
},

@vespertilian
Copy link
Author

vespertilian commented Apr 3, 2021

@studds

The repo uses yarn now, not npm. So it's got a yarn.lock and you install deps using yarn.

Yes... silly me. I just use NPM in my projects, didn't even think about it. You list it in the readme and everything. Sorry.

That's not relevant to layers, because the layer arn is not an environment variable.

The layer arn is important for the layers as when you load SAM locally it pulls the remote layer from the AWS server. As the whole stack gets the -dev / -prod suffix, and I don't have a dev env (just prod) it cannot pull anything. I have a PR for this.

I wrote some specs ... I will try to help out with some more in the future.

@studds
Copy link
Owner

studds commented Apr 24, 2021

@vespertilian thanks so much for the pr, I've been slammed recently and haven't had a chance to look. Do you have some time this week to review together?

@vespertilian
Copy link
Author

@studds

Yeah, I think I can do even better but let's talk about it Wednesday or Thursday some time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants