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

Error while passing egress and ingress as list variable #313

Closed
rahulviswam17 opened this issue Oct 13, 2017 · 2 comments
Closed

Error while passing egress and ingress as list variable #313

rahulviswam17 opened this issue Oct 13, 2017 · 2 comments
Labels

Comments

@rahulviswam17
Copy link

rahulviswam17 commented Oct 13, 2017

Terraform Version

# Run this command to get the terraform version:

$ terraform -v
Terraform v0.10.7

OCI Provider Version

# Execute the plugin directly to get the version:

$ <path-to-plugin>/terraform-provider-oci
2017/10/13 01:12:08 [INFO] terraform-provider-oci 2.0.1
This binary is a plugin. These are not meant to be executed directly.
Please execute the program that consumes these plugins, which will
load any plugins automatically

Description:

Include a description with repro steps, expected result and actual result
I am in a need to pass egress and ingress rule for a security list which is stored in another variable.tf file to the resource in the create_network.tf file. I get the below error with this approach, but when substituting the value directly in the resource works fine.

Error

  • oci_core_security_list.CustmSecurityList: egress_security_rules.0: expected object, got invalid
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.0: expected object, got invalid
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.1: expected object, got invalid
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.2: expected object, got invalid
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.3: expected object, got invalid
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.4: expected object, got invalid
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.5: expected object, got invalid
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.6: expected object, got invalid
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.7: expected object, got invalid
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.8: expected object, got invalid

Terraform Plan

**create_network.tf**

#Template for different ADs

data "oci_identity_availability_domains" "ADs" {
compartment_id = "${var.compartment_ocid}"
}

#Resource for creating VCN

resource "oci_core_virtual_network" "CompleteVCN" {
count = "${var.enable_flag}"
cidr_block = "${var.VCN-CIDR}"
compartment_id = "${var.compartment_ocid}"
display_name = "TFCompleteVCN"
dns_label = "vnc1"
}

#Resource for creating IG

resource "oci_core_internet_gateway" "CompleteIG" {
count = "${var.enable_flag}"
compartment_id = "${var.compartment_ocid}"
display_name = "TFCompleteIG"
vcn_id = "${oci_core_virtual_network.CompleteVCN.id}"
}

#Resource for creating Routing table

resource "oci_core_route_table" "RouteForComplete" {
count = "${var.enable_flag}"
compartment_id = "${var.compartment_ocid}"
vcn_id = "${oci_core_virtual_network.CompleteVCN.id}"
display_name = "TFRouteTableForComplete"
route_rules {
cidr_block = "0.0.0.0/0"
network_entity_id = "${oci_core_internet_gateway.CompleteIG.id}"
}
}

#Rsource for creating custom security list

resource "oci_core_security_list" "CustmSecurityList" {
count = "${var.enable_flag}"
compartment_id = "${var.compartment_ocid}"
display_name = "Custom_SecurityList"
vcn_id = "${oci_core_virtual_network.CompleteVCN.id}"
egress_security_rules = "${var.egress_rule}"
ingress_security_rules = "${var.ingress_rule}"
}

variable.tf

variable "VCN-CIDR" {
default = "10.0.0.0/16"
}

variable "sl_egress" {
type = "list"
default = [{
destination = "0.0.0.0/0"
protocol = "all"
}]

}

variable "sl_ingress" {
type = "list"
default = [{
tcp_options {
"max" = 10250
"min" = 10250
}
protocol = "6"
source = "10.0.0.0/16"
},
{
tcp_options {
"max" = 6443
"min" = 6443
}
protocol = "6"
source = "10.0.0.0/16"
},
{
tcp_options {
"max" = 30999
"min" = 30000
}
protocol = "6"
source = "10.0.0.0/16"
},
{
tcp_options {
"max" = 2380
"min" = 2379
}
protocol = "6"
source = "10.0.0.0/16"
},
{
tcp_options {
"max" = 111
"min" = 111
}
protocol = "6"
source = "10.0.0.0/16"
}]
}

Alternative tried in Security List creation --> Unsuccessfull

resource "oci_core_security_list" "CustmSecurityList" {
compartment_id = "${var.compartment_ocid}"
display_name = "Custom_SecurityList"
vcn_id = "${oci_core_virtual_network.CompleteVCN.id}"
egress_security_rules = {
variables = "${var.sl_egress}"
}
ingress_security_rules = {
variables = "${var.sl_ingress}"
}

}

Error

6 error(s) occurred:

  • oci_core_security_list.CustmSecurityList: "egress_security_rules.0.destination": required field is not set
  • oci_core_security_list.CustmSecurityList: "egress_security_rules.0.protocol": required field is not set
  • oci_core_security_list.CustmSecurityList: "ingress_security_rules.0.protocol": required field is not set
  • oci_core_security_list.CustmSecurityList: "ingress_security_rules.0.source": required field is not set
  • oci_core_security_list.CustmSecurityList: egress_security_rules.0: invalid or unknown key: variables
  • oci_core_security_list.CustmSecurityList: ingress_security_rules.0: invalid or unknown key: variables
@codycushing
Copy link
Contributor

I don't believe Terraform supports this. Can you point to some docs or examples where this is has been achieved? Perhaps you can inquire as to the feasibility of this on the Terraform project.

@rahulviswam17
Copy link
Author

I came across this this issue in the Terraform project. Looks like its not supported, and marked for future enhancement.

hashicorp/terraform#7705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants