Coder Social home page Coder Social logo

Comments (10)

ofhouse avatar ofhouse commented on June 21, 2024

Did you run npx tf-next build in the root of your Next.js project before running terraform apply?

Looks like the build output from the tf-next command (which is stored in .next-tf directory) is not present.

from terraform-aws-next-js.

ahmed-rezk-dev avatar ahmed-rezk-dev commented on June 21, 2024

This a screenshot of my foulders https://i.imgur.com/tlefhK8.png

it only happened if I used

 backend "remote" {
    organization = "*****"

    workspaces {
      name = "*****"
    }
  }

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on June 21, 2024

Looks like you are using Terraform Cloud for the deployment?
My guess is that the .next-tf folder is not uploaded correctly to Terraform Cloud and is therefore not present when running terraform apply.

Looking at your files it seems that your .terraformignore file is in the wrong place.
It's not very well documented but it should be located in the project root (/.terraformignore, where your .prettierrc.js is located) rather than in the terraform subfolder /terraform/.terraformignore.

Content of the .terraformignore file should also include the .tf-next directory as described in the Readme.

from terraform-aws-next-js.

ahmed-rezk-dev avatar ahmed-rezk-dev commented on June 21, 2024

Yes, I'm using Terraform Cloud for the deployment. I'm trying to make it work with AWS and GitHub actions with Terraform. Terraform Cloud is one of the requirement. If you think of another way to do it without the Terraform Cloud. Please let me know.

I tried to add the .terraformignore in the main directory including the .tf-next. But still giving me the same error.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on June 21, 2024

Interesting we also use Terraform Cloud for an project and it works fine for us.

Do you use the VCS integration or do you execute terraform apply on the GitHub Actions instance first which triggers a remote apply in Terraform Cloud?

from terraform-aws-next-js.

ahmed-rezk-dev avatar ahmed-rezk-dev commented on June 21, 2024

I'm actually trying to make work locally first. Then move to setup with Github actions but I will execute terraform apply on the GitHub Actions.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on June 21, 2024

Okay, yes this sounds like a similar approach we are using for our own infrastructure which works fine.

Keep in mind that terraform plan or terraform apply do not trigger a build of Next.js by its own.
For a complete deployment you always have to execute npx tf-next build (which creates a Next.js build and pipes it to the .next-tf directory) and then terraform plan or terraform apply (which picks up some files from the previously generated .next-tf folder) in this exact order.

Looking at your workflow here I do not see any execution of npx tf-next build which may is the cause of the error.

from terraform-aws-next-js.

ahmed-rezk-dev avatar ahmed-rezk-dev commented on June 21, 2024

I did before then I removed it again. I got the same error locally. That's why I'm trying to get it to work before pushing it again.

You are welcome to try my repo to see the error by yourself.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on June 21, 2024

Checked it out locally and the apply was successful in Terraform Cloud for me.
Here are my steps for reproduction:

Setup

  • Terraform Version: 0.14.3
  • Terraform Working Directory (In Terraform Cloud Settings): /terraform
    Screenshot 2021-04-11 at 15 15 52

Reproduction steps

1. Git checkout

git clone [email protected]:ahmed-rezk-dev/nile-dahsboard.git
git checkout develop

2. Create .terraformignore file in repo-root with the following content:

# .terraformignore
*
!terraform/
!**/.next-tf/**

3. Install dependencies & run tf-next build

yarn
yarn tf-next

4. Run terraform apply on Terraform Cloud

cd terraform
terraform init
terraform login

terraform apply

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on June 21, 2024

I'm going to close this issue because it has been inactive for 30 days ⏳. This helps to find and focus on the active issues.

from terraform-aws-next-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.