outscale / terraform-provider-outscale

Mozilla Public License 2.0
28 stars 30 forks source link

"outscale_security_group_rule" resource: issue with "security_group_name_to_link" parameter #52

Open outscale-toa opened 2 years ago

outscale-toa commented 2 years ago

Terraform Version

Terraform v1.1.3
on linux_amd64
+ provider registry.terraform.io/outscale-dev/outscale v0.5.1

Terraform Configuration Files

resource "outscale_net" "outscale_net" {
   ip_range = "10.0.0.0/16"    tags {
        key   = "Name"
        value = "outscale_net_resource2"
    }
}
resource "outscale_security_group" "outscale_security_group4" {
    description         = "test group4"
    security_group_name = "sg4-terraform-test"
    net_id              = outscale_net.outscale_net.net_id
    tags {
        key   = "Name"
        value = "outscale_sg4"
    }
}
resource "outscale_security_group" "outscale_security_group5" {
    description         = "test group5"
    security_group_name = "sg5-terraform-test"
    net_id              = outscale_net.outscale_net.net_id
    tags {
        key   = "Name"
        value = "outscale_sg5"
    }
resource "outscale_security_group_rule" "outscale_security_group_rule-4" {
    flow              = "Inbound"
    security_group_id = outscale_security_group.outscale_security_group4.id
    from_port_range   = "8080"
    to_port_range     = "8080"
    ip_protocol       = "tcp"
    security_group_name_to_link = outscale_security_group.outscale_security_group5.id
}

Debug Output

╷
│ Error: "ip_protocol": conflicts with security_group_name_to_link
│ 
│   with outscale_security_group_rule.outscale_security_group_rule-4,
│   on CheckSgRules.tf line 49, in resource "outscale_security_group_rule" "outscale_security_group_rule-4":
│   49: resource "outscale_security_group_rule" "outscale_security_group_rule-4" {
│ 
╵
╷
│ Error: "security_group_name_to_link": conflicts with ip_protocol
│ 
│   with outscale_security_group_rule.outscale_security_group_rule-4,
│   on CheckSgRules.tf line 49, in resource "outscale_security_group_rule" "outscale_security_group_rule-4":
│   49: resource "outscale_security_group_rule" "outscale_security_group_rule-4" {
│ 

Crash Output

N/A

Expected Behavior

The security group rule is created correctly.

Actual Behavior

The security group rule failed.

Steps to Reproduce

  1. terraform init
  2. terraform apply

    Additional Context

References

outscale-rce commented 3 months ago

Ok, so security_group_name_to_link is not working at all. If you remove ip_protocol, you can apply the configuration, but nothing happens. Furthermore, once security_group_name_to_link is used, it becomes impossible to destroy, resulting in an error message like:

Error: Error revoking security group sg-2e00c45d rules: 400 Bad Request

However, using the following syntax, it will work as expected:

resource "outscale_security_group_rule" "outscale_security_group_rule-5" {
    flow              = "Inbound"
    security_group_id = outscale_security_group.outscale_security_group5.id
    rules {
        from_port_range = "9090"
        to_port_range   = "9090"
        ip_protocol     = "tcp"
        security_groups_members {
            account_id          = "123456789"
            security_group_name = outscale_security_group.outscale_security_group4.security_group_name
        }
    }
}