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

VPC subnets created in incorrect resource group #1398

Closed
timroster opened this issue May 1, 2020 · 4 comments
Closed

VPC subnets created in incorrect resource group #1398

timroster opened this issue May 1, 2020 · 4 comments

Comments

@timroster
Copy link

timroster commented May 1, 2020

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.12.24

Affected Resource(s)

Please list the resources as a list, for example:

  • ibm_is_subnet

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

Terraform Configuration Files

variable "resource_group" {}
provider "ibm" {
  generation         = 2
  region             = "us-south"
}
data ibm_resource_group "group" {
  name = var.resource_group
}
resource "ibm_is_vpc" "iac_test_vpc" {
  name = "terraform-test-vpc"
  resource_group = data.ibm_resource_group.group.id
}
resource "ibm_is_subnet" "iac_test_subnet" {
  name            = "terraform-test-subnet"
  vpc             = ibm_is_vpc.iac_test_vpc.id
  zone            = "us-south-1"
  ipv4_cidr_block = "10.240.0.0/24"
  resource_group = data.ibm_resource_group.group.id
}

Debug Output

https://gist.github.com/timroster/bdf4b90186955a1e9d6297a1c7b50e62

Panic Output

N/A

Expected Behavior

The VPC subnet should have been added to the resource group specified in the plan displayed before confirmation:

Terraform will perform the following actions:

  # ibm_is_subnet.iac_test_subnet will be created
  + resource "ibm_is_subnet" "iac_test_subnet" {
      + available_ipv4_address_count = (known after apply)
      + id                           = (known after apply)
      + ip_version                   = "ipv4"
      + ipv4_cidr_block              = "10.240.0.0/24"
      + ipv6_cidr_block              = (known after apply)
      + name                         = "terraform-test-subnet"
      + network_acl                  = (known after apply)
2020/05/01 14:40:58 [DEBUG] command: asking for input: "Do you want to perform these actions?"
      + resource_controller_url      = (known after apply)
      + resource_crn                 = (known after apply)
      + resource_group               = "5831b69fab464da7a96f7b989dfdf32a"
      + resource_group_name          = (known after apply)
      + resource_name                = (known after apply)
      + resource_status              = (known after apply)
      + status                       = (known after apply)
      + total_ipv4_address_count     = (known after apply)
      + vpc                          = (known after apply)
      + zone                         = "us-south-1"
    }

Actual Behavior

The VPC subnet was created in the Default resource group for the account:

terraform show
...
# data.ibm_resource_group.group:
data "ibm_resource_group" "group" {
    id   = "5831b69fab464da7a96f7b989dfdf32a"
    name = "IKS-RG1"
}

# ibm_is_subnet.iac_test_subnet:
resource "ibm_is_subnet" "iac_test_subnet" {
    id                       = "0717-626efc8c-32a6-4d5e-8c10-c3a631297d75"
    ip_version               = "ipv4"
    ipv4_cidr_block          = "10.240.0.0/24"
    name                     = "terraform-test-subnet"
    network_acl              = "r006-a3ba7a99-381f-45d2-8fe6-c025fe67b775"
    resource_controller_url  = "https://cloud.ibm.com/vpc-ext/network/subnets"
    resource_crn             = "crn:v1:bluemix:public:is:us-south-1:a/bda3b5ea09b5c9cb909067cd839e95c2::subnet:0717-626efc8c-32a6-4d5e-8c10-c3a631297d75"
    resource_group           = "3aa4f26156c44d868306df4073877910"
    resource_group_name      = "Default"
    resource_name            = "terraform-test-subnet"
    resource_status          = "available"
    status                   = "available"
    total_ipv4_address_count = 256
    vpc                      = "r006-3c0f4242-c94d-4b18-a2a2-7f1726d32db3"
    zone                     = "us-south-1"
}
...

Steps to Reproduce

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

  1. terraform apply
    (use a resource group in the account other than default or Default depending on the name of the default resource group for the account)

Important Factoids

First appears in 1.5.0, works correctly in 1.4.0, 1.3.0

References

N/A

@hkantare
Copy link
Collaborator

hkantare commented May 4, 2020

@timroster
Copy link
Author

Successfully tested example failing use case against version 1.5.1. 👍

@y0zg
Copy link

y0zg commented Jun 11, 2020

@timroster
Copy link
Author

timroster commented Jun 11, 2020

@y0zg Yes, this issue affected the version 1.5.0 provider on VPC generation 2. But it's fixed now.

Note it was not specific to IKS on Gen 2. However code with the provider creating a vpc, subnet, and cluster in a non-default resource group would have been affected by this.

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

3 participants