GithubHelp home page GithubHelp logo

chronark / terraform-provider-vercel Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 9.0 246 KB

A terraform provider for vercel's hosting platform

Home Page: ff789693-5a72-142e-e45d-326ead4ae7a4.vercel.app

License: Mozilla Public License 2.0

Makefile 0.83% Go 99.17%

terraform-provider-vercel's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

terraform-provider-vercel's Issues

No `darwin_arm64` release?

Hi, I'm trying to use this on my M1 MacBook Pro and I get this error

│ Error: Incompatible provider version
│
│ Provider registry.terraform.io/chronark/vercel v0.14.0 does not have a package available for your current platform, darwin_arm64.
│
│ Provider releases are separate from Terraform CLI releases, so not all providers are available for all platforms. Other versions of this provider may have different platforms
│ supported.

I looked at the .goreleaser.yaml file but I can't seem to find anything wrong with it that'd be ignoring darwin_arm64. Could you take a look too?

terraform apply constantly says vercel dns must be replaced

Terraform Version

v10.0.0

Affected Resource(s)

Please list the resources as a list, for example:

  • vercel_dns

Terraform Configuration Files

resource "vercel_project" "foodbudget" {
  name           = "foodbudget"
  framework      = "nextjs"
  root_directory = "packages/@foodbudget/frontend"
  git_repository {
    type = "github"
    repo = "jacktan165/foodbudget"
  }
}

resource "vercel_env" "env" {
  project_id = vercel_project.foodbudget.id
  type       = "plain"
  key        = "NEXT_PUBLIC_API_URL"
  value      = "https://api.foodbudget.tk"
  target     = ["production", "preview", "development"]
}

resource "vercel_domain" "prod" {
  name = "foodbudget.tk"
}

resource "vercel_alias" "prod" {
  project_id = vercel_project.foodbudget.id
  domain     = vercel_domain.prod.name
}

resource "vercel_alias" "prod_www" {
  project_id = vercel_project.foodbudget.id
  domain     = "www.foodbudget.tk"
  redirect   = vercel_alias.prod.domain
}

resource "vercel_dns" "prod_a_record" {
  domain = vercel_domain.prod.name
  type   = "A"
  name   = "www"
  value  = "76.76.21.21"
}

resource "vercel_dns" "api" {
  domain = vercel_domain.prod.name
  type   = "CNAME"
  name   = "api"
  value  = module.foodbudget_lb.lb.dns_name

  depends_on = [
    module.foodbudget_lb.lb
  ]
}

resource "vercel_dns" "prod_caa_record" {
  domain = vercel_domain.prod.name
  type   = "CAA"
  name   = ""
  value  = "0 issue \"amazon.com\""

  depends_on = [
    module.foodbudget_lb.lb
  ]
}

resource "vercel_dns" "cert" {
  domain = vercel_domain.prod.name
  type   = tolist(aws_acm_certificate.foodbudget.domain_validation_options)[0].resource_record_type
  name   = tolist(aws_acm_certificate.foodbudget.domain_validation_options)[0].resource_record_name
  value  = tolist(aws_acm_certificate.foodbudget.domain_validation_options)[0].resource_record_value
}
Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply":

  # vercel_project.foodbudget has been changed
  ~ resource "vercel_project" "foodbudget" {
      ~ alias                      = [
            "foodbudget.vercel.app",
          + "foodbudget.tk",
          + "www.foodbudget.tk",
        ]
        id                         = "prj_R7sZ79xRAmnOiRr8hGMwKExq7CjT"
        name                       = "foodbudget"
        # (8 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }
  # vercel_domain.prod has been changed
  ~ resource "vercel_domain" "prod" {
        id                   = "QmetFZiVBcpxQG2a9kpGDmP3zMQ8JGLQXfjeyhzu7heTG6"
        name                 = "foodbudget.tk"
      ~ ns_verified_at       = 1623930884154 -> 1623946518086
        # (12 unchanged attributes hidden)
    }
  # vercel_dns.api has been changed
  ~ resource "vercel_dns" "api" {
        id         = "rec_1454cfc4ad85258c41759531"
        name       = "api"
      ~ updated    = 1623946519861 -> 1623946529703
      ~ updated_at = 1623946519861 -> 1623946529703
        # (7 unchanged attributes hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # vercel_dns.api must be replaced
-/+ resource "vercel_dns" "api" {
      ~ created    = 1623946519861 -> (known after apply)
      ~ created_at = 1623946519861 -> (known after apply)
      ~ creator    = "nqUzOXR9ZLbkknmWT1vSwt8Z" -> (known after apply)
      ~ id         = "rec_1454cfc4ad85258c41759531" -> (known after apply)
        name       = "api"
      ~ updated    = 1623946529703 -> (known after apply)
      ~ updated_at = 1623946529703 -> (known after apply)
      ~ value      = "foodbudget-prod-lb-652827199.ap-southeast-2.elb.amazonaws.com." -> "foodbudget-prod-lb-652827199.ap-southeast-2.elb.amazonaws.com" # forces replacement
        # (3 unchanged attributes hidden)
    }

  # vercel_dns.cert must be replaced
-/+ resource "vercel_dns" "cert" {
      ~ created    = 1623946519795 -> (known after apply)
      ~ created_at = 1623946519795 -> (known after apply)
      ~ creator    = "nqUzOXR9ZLbkknmWT1vSwt8Z" -> (known after apply)
      ~ id         = "rec_d6526060a2f0a33d355ffa51" -> (known after apply)
      ~ name       = "_5c4a3f13d9996761f16a2d0fba623bca" -> "_5c4a3f13d9996761f16a2d0fba623bca.foodbudget.tk." # forces replacement
      ~ updated    = 1623946519795 -> (known after apply)
      ~ updated_at = 1623946519795 -> (known after apply)
        # (4 unchanged attributes hidden)
    }

Expected Behavior

When I run terraform apply after running it initially, it should not do anything.

Actual Behavior

It constantly says those resources must be replaced.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Improve support for vercel_env type "encrypted"

While not documented by this repo, you can successfully create a vercel_env with type encrypted.

However, these resources will always have changes applied to them. It would be great if support for type = "encrypted" was improved, as Vercel is planning to deprecate secrets https://vercel.com/docs/rest-api#endpoints/secrets

Terraform Version

Terraform v1.0.11
on linux_amd64

  • provider registry.terraform.io/chronark/vercel v0.14.2

Affected Resource(s)

  • vercel_env

Terraform Configuration Files

resource "vercel_project" "test" {
  name = "test"

  git_repository {
    type = "github"
    repo = "marklawlor/test"
  }

  framework     = "nextjs"
}


resource "vercel_env" "test" {
  project_id = vercel_project.test.id
  type       = "encrypted"
  key        = "test"
  value      = random_password.test.result
  target     = ["production"]
}

resource "random_password" "test" {
  length  = 16
  special = true
}

Expected Behavior

Should detect no changes when running terraform apply multiple times

Actual Behavior

  ~ resource "vercel_env" "test" {
        id         = "RiZ1UbFy3BbC6x3m"
      ~ key        = "" -> "test"
      ~ target     = [
          + "production",
        ]
      ~ type       = "" -> "encrypted"
      # Warning: this attribute value will no longer be marked as sensitive
      # after applying this change.
      ~ value      = (sensitive) -> (known after apply)
        # (3 unchanged attributes hidden)
    }

Missing support for `MX`-records

It seems like MX-records are not supported in the vercel_dns-resource. I'm open to doing a PR for this. 🤠

Terraform Version

Terraform v1.1.7
on darwin_amd64
+ provider registry.terraform.io/chronark/vercel v0.14.4

Affected Resource(s)

  • vercel_dns

Terraform Configuration Files

resource "vercel_dns" "mail_mx01" {
  name = ""
  type = "MX"
  domain = "mydomain.example"
  value = "10 mx01.mail.icloud.com." # initially expected this to work
}

Debug Output

Gist

Panic Output

No panic.

Expected Behavior

The record being created as specified.

Actual Behavior

The record was not created.

╷
│ Error: Unable to request resource: [POST] /v2/domains/mydomain.example/records with payload {}: Error during http request: map[error:map[code:bad_request message:Invalid request: missing required property `mxPriority`.]]
│
│   with vercel_dns.mail_mx01,
│   on dns.tf line 33, in resource "vercel_dns" "mail_mx01":
│   33: resource "vercel_dns" "mail_mx01" {
│

Steps to Reproduce

  1. Make MX record
  2. terraform apply

Important Factoids

Nope.

References

Nope.

`terraform import` of Vercel project not importing domain settings

Terraform Version

1.0.11

Affected Resource(s)

  • vercel_project

Terraform Configuration Files

I will need to sanitize the relevant configuration files, will attach shortly. 

Debug Output

Same as configuration files.

Expected Behavior

I used terraform import to import a vercel resource into my state, but the multiple domain blocks configured in that resource were not imported, so terraform wants to change the resource unnecessarily.

Actual Behavior

Terraform wants to change project domains to match

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform import vercel_project.foo myorg/foo
  2. [ Ensure that values in my terraform config match configured values in Vercel. ]
  3. terraform plan
# vercel_project.foo will be updated in-place
  ~ resource "vercel_project" "foo" {
        id             = "[REDACTED]"
        name           = "foo"
        # (9 unchanged attributes hidden)

      + domain {
          + git_branch = "main"
          + name       = "foo.bar"
        }
      + domain {
          + git_branch = "main"
          + name       = "www.foo.bar"
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Priority value / Email presets?

Hi!

I'm trying to configure Google Suite emails and was looking for the email preset option:
image
but from what I can see, it's not implemented yet (not sure if it's even possible to implement it)

Instead I'm now trying to manually add all of the DNS records but I ran into an issue - I can't set the priority field as it's missing -
image

Do you have any plans on adding support for either?

project domain branch not set when defined

Hi there again! 😇

For given example

resource "vercel_project" "web" {
  name    = "web"

  git_repository {
    type = "gitlab"
    repo = "foo/bar"
  }

  domain {
    name = foo.example.com
    git_branch = "stage"
  }
}

project domain's git branch is not set.

In resource_project.go in lines 234-238 the code is not passing git_branch value and also not sending gitBranch as part of the request to create a project domain.


Terraform version: 1.0.2
vercel provider version: 0.11.0


And once again, thank you for working on this handy project 😉

multiple domains in a project

Hi there!

Thank you for creating this, it's really a great terraform provider for a great platform!

Currently I'm able to set a single domain with a single git branch per project, but often in reality we need multiple domains.

resource "vercel_project" "web" {
  name    = "web"

  git_repository {
    type = "gitlab"
    repo = "foo/bar"
  }

  domain {
    name = "foo-dev.example.com"
    git_branch = "master"
  }
}

Vercel UI and API allow for multiple domains in a single project. Using the API we could set up one domain for development, one for staging etc. Something like this:

resource "vercel_project" "web" {
  name    = "web"

  git_repository {
    type = "gitlab"
    repo = "foo/bar"
  }

  domain {
    name = "foo-dev.example.com"
    git_branch = "master"
  }

  domain {
    name = "foo-stage.example.com"
    git_branch = "stage"
  }
}

Currently, I see that you are limiting the number of domain blocks to 1 which is why the example above is (expectedly) failing.


Temp workaround could be to create N number of projects where N is the number of domains and their appropriate deploy environments.

Resource Project: Blocks of type "domain" are not expected here.

Hi there, i'm having troubles when try to add domain block in project resource.

Terraform Version

Run terraform -v to show the version. We support terraform v0.13+

 terraform -v
Terraform v1.0.4
on darwin_amd64
+ provider registry.terraform.io/chronark/vercel v0.10.4
+ provider registry.terraform.io/hashicorp/google-beta v4.1.0

Affected Resource(s)

Please list the resources as a list, for example:

  • vercel_project

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

provider "vercel" {
  # Configuration options
  token = var.vercel_token
}

resource "vercel_domain" "main" {
  for_each = var.states

  name = each.value.domain
}

resource "vercel_project" "projects" {
  for_each = var.states
  name = "${each.value.state}-${var.project_name}"

  team_id = var.team_id
  framework = "nextjs"
  build_command = "yarn build"

  git_repository {
    type = "github"
    repo = var.github_repo
  }

  domain {
    name = vercel_domain.main.name
  }

  // domain {
  //   name = "www.${vercel_domain.main.name}"
  //   redirect = vercel_domain.main.name
  //   redirect_status_code = 308
  // }
}

Debug Output

Screenshot 2021-12-03 at 12 27 11

Panic Output

No panic

Expected Behavior

Should create project in Vercel, without this domain block in project resource everything works fine.

Actual Behavior

Unsupported block

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply or terraform plan

Important Factoids

References

Issue with Vercel Domain Creation

Hi there,

Thank you so much for making this module! I'll probably be making heavy use of it over the next couple months, and I really appreciate the work you put in. Unfortunately I couldn't get the new vercel domain stuff you just added to work quick right for me. Maybe I misconfigured something? Any help would be greatly appreciated.

Terraform Version

Terraform v0.15.3
on darwin_amd64
+ provider registry.terraform.io/chronark/vercel v0.10.0
+ provider registry.terraform.io/hashicorp/github v4.9.4
+ provider registry.terraform.io/integrations/github v4.9.4

Affected Resource(s)

Please list the resources as a list, for example:

  • vercel_domain

Terraform Configuration Files

resource "vercel_domain" "antarahaldar_com" {
  team_id = var.vercel_team_id
  name = "antarahaldar.com"
}

Debug Output

│ Error: Unable to fetch domain from vercel: Unable to request resource: [GET] /v4/domains/antarahaldar.com/?teamId=team_Mb1ivhnQAH2uo2nNrPBbDwk4 with payload {<nil>}: Error during http request: map[error:map[code:not_found message:The requested API endpoint was not found.]]
│
│   with vercel_domain.antarahaldar_com,
│   on antara.tf line 22, in resource "vercel_domain" "antarahaldar_com":
│   22: resource "vercel_domain" "antarahaldar_com" {

Expected Behavior

It should create the domain and not error

Actual Behavior

The domain is created as expected in vercel, but terraform thinks it failed and exists with this error.

### Terraform Version

Terraform Version

Terraform v1.1.3

Affected Resource(s)

  • vercel_project

Terraform Configuration Files

resource "vercel_project" "all_trace" {
    ...
    domain {
        name        = <HIDDEN>
        git_branch  = "example-branch"
    }
}

Expected Behavior

Update the domain's git-branch setting.

Actual Behavior

Not updated!

It appears the git_branch has no effect on the domain, every other field works expected except this.

Happy to help out! First git issue I have logged, apologies if I did something incorrectly.

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.