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

Terraform plan shows billing contacts removed #47

Closed
phumberdroz opened this issue Mar 6, 2019 · 7 comments
Closed

Terraform plan shows billing contacts removed #47

phumberdroz opened this issue Mar 6, 2019 · 7 comments
Assignees

Comments

@phumberdroz
Copy link

Hey,

I just started using the terraform aiven provider. I deployed a new project with it now in the next terraform plan run it wants to remove the billing details.

variable "aiven_api_token" {}
variable "aiven_card_id" {}

# Initialize provider. No other config options than api_token
provider "aiven" {
  api_token = "${var.aiven_api_token}"
}

resource "aiven_project" "project" {
  project           = "${terraform.workspace}"
  copy_from_project = "karl-3727"
}

Terraform Plan:

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ aiven_project.project
      billing_address:             "**********************************" => ""
      billing_emails.#:            "1" => "0"
      billing_emails.1238831172:   "**********************************" => ""
      card_id:                     "**********************************" => ""
      country_code:                "DE" => ""
      technical_emails.#:          "1" => "0"
      technical_emails.1238831172: "**********************************" => ""


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

------------------------------------------------------------------------

This plan was saved to: planfile

To perform exactly these actions, run the following command to apply:
    terraform apply "planfile"
@phumberdroz
Copy link
Author

as a work around I changed my Project Resource to look like this:

resource "aiven_project" "project" {
  project           = "${terraform.workspace}"
  copy_from_project = "karl-3727"

  lifecycle {
    ignore_changes = [
      # Ignore Because it conflicts with copy_from_project see: https://github.com/aiven/terraform-provider-aiven/issues/47
      "billing_address",
      "billing_emails.#",
      "billing_emails.1238831172",
      "card_id",
      "country_code",
      "technical_emails.#",
      "technical_emails.1238831172",
    ]
  }
}

@seboudry
Copy link

Came into the same issue with an already created project.
Billing information is managed by finance team and we don't want to handle it with Terrafrom.

@phumberdroz I borrow your idea and simplify billing_emails list:

resource "aiven_project" "awesome" {
  project          = "${var.aiven_project_name}"
  technical_emails = [
    "production@awesome.io",
  ]

  lifecycle {
    # ignoring billing information
    ignore_changes = [
      "billing_address",
      "billing_emails",
      "card_id",
      "country_code",
    ]
  }
}

@seboudry
Copy link

But maybe another solution is to have a aiven_projet data source instead to only reference an existing resource. Like google_project one https://www.terraform.io/docs/providers/google/d/google_project.html

After a few time using this provider I also notice that Terraform's output variable type aren't used. All computed values are resource attributes. Am I wrong ?

@mteiste mteiste self-assigned this Jun 27, 2019
@mteiste
Copy link

mteiste commented Aug 16, 2019

latest release (1.0.14) implements the suggested solution (datasources)

@mteiste mteiste closed this as completed Aug 16, 2019
@jeff-knurek
Copy link

latest release (1.0.14) implements the suggested solution (datasources)

can you elaborate?
I imported the aiven_projet resource and had to apply the lifecycle { ignore_changes } workaround in version v1.2.3

@mteiste
Copy link

mteiste commented Apr 6, 2020

You define and import the project as data "aiven_project" instead of resource "aiven_project".

@eb-trigo
Copy link

eb-trigo commented Jun 2, 2021

Hey, @mteiste If I use the lifecycle feature it allows me to add another email address but if I want to delete some email from the list it ignores this change.

Can you please let me know what should I change in my aiven Terraform's resources?

resource "aiven_billing_group" "billing_group" {
    name = var.name
    vat_id = var.vat_id
    billing_currency = "USD"
    billing_emails = var.billing_emails
}

resource "aiven_project" "project" {
    project = var.project
    technical_emails  = var.technical_emails
    billing_group = aiven_billing_group.billing_group.id
    lifecycle {
      ignore_changes = [billing_emails]
    }
}

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

5 participants