Coder Social home page Coder Social logo

`create` variable about terraform-aws-next-js HOT 8 CLOSED

millihq avatar millihq commented on July 19, 2024
`create` variable

from terraform-aws-next-js.

Comments (8)

ofhouse avatar ofhouse commented on July 19, 2024 1

Is this still needed?
With the release of v0.8.0 it is now possible to use count on the module like this:

module "next-tf" {
  source = "dealmore/next-js/aws"

  count = terraform.workspace == "prod" ? 1 : 0
}

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Do you have a specific resource in mind?
My philosophy here is to support optional resources when they are not necessary or can be replaced with self-written constructs.

The next optional resource to add will be the main CloudFront distribution, which is targeted in #55.
IMHO I currently don't see other resources where this would make sense, but I am open for suggestions πŸ™‚

from terraform-aws-next-js.

b6pzeusbc54tvhw5jgpyw8pwz2x6gs avatar b6pzeusbc54tvhw5jgpyw8pwz2x6gs commented on July 19, 2024

@ofhouse In many use cases, one Terraform code covers multiple environments. For example, in the code below, I would like to decide to create the next-tf module according to the environment.

module "next-tf" {
  source = "dealmore/next-js/aws"
  create = terraform.workspace == "prod"
  // or
  // create = var.env == "prod"

  next_tf_dir     = var.next_tf_dir
  deployment_name = var.deployment_name
}

This pattern can be used in many modules, including the following two modules used by this module:

from terraform-aws-next-js.

b6pzeusbc54tvhw5jgpyw8pwz2x6gs avatar b6pzeusbc54tvhw5jgpyw8pwz2x6gs commented on July 19, 2024

My philosophy here is to support optional resources when they are not necessary or can be replaced with self-written constructs.

This can also be achieved by just using var.create && var.create_xxx. Example:

resouce "aws_cloudfront_distribution" "this" {
  count = var.create && var.create_cloudfront_distribution ? 1 : 0
}

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Ah, thanks for clarification.
I think the create variables there were originally added for versions of Terraform below 0.13 since it was not possible to use count or for_each on modules.

Terraform 0.13 (which is already the minimal required version for this module) and up support count on modules which I would prefer here since it is an official Terraform feature and no workaround like a create variable would be.

However, using count on this module currently does not work because we use an internal AWS provider to ensure that some resources are created in us-east-1 region. #50
The plan is to drop this internal provider in the next version which should lift the limitation on using count.

from terraform-aws-next-js.

b6pzeusbc54tvhw5jgpyw8pwz2x6gs avatar b6pzeusbc54tvhw5jgpyw8pwz2x6gs commented on July 19, 2024

You're right. Using count in module, blocks the use of provider inside the module, I think the create variable is still useful in many cases.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Would like to reevaluate this after #50 is implemented.
Introducing a create variable would require a lot of changes and it must also be ensured that the submodules support it.

For this reason I would appreciate it when this could be handled in userland with a simple count on the module itself.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 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.