-
Notifications
You must be signed in to change notification settings - Fork 32
Description
I currently have a workflow where I allow my developers to manually added environment variables via the Vercel website. Then later I add that environment variable to terraform for tracking and future changes. Because the env variable was manually created, I get an error of:
│ Could not create project environment variable, unexpected error: ENV_ALREADY_EXISTS -
Another Environment Variable with the same Name and Environment exists in your project.
Remove it or choose a different Name or Environment.
It would be nice if there was a parameter to tell the provider and API to overwrite or delete and recreate the current variable with what is in the terraform config.
I know that I can use terraform import, but importing environment variables is annoying because the environment variable id is needed and there is no easy way to see the ID in the website, only via the web browser development tools or API.
To recreate:
Create the vercel project.
resource "vercel_project" "test" {
name = "test-foobar"
git_repository = {
type = "github"
repo = "agitelzon/test"
}
}
Manually create the environment variable FOO
with any value via the web console.
Then add the following code and run it.
resource "vercel_project_environment_variable" "foo" {
project_id = vercel_project.test.id
key = "FOO"
value = "foobar"
target = ["development", "preview", "production"]
}