-
Notifications
You must be signed in to change notification settings - Fork 691
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
oci_core_security_list not adhering to plan #2258
Labels
Comments
i completely re made my terraform setup and i'm still being hit by this issue variables.tf variable "compute" {
type = object({
ad = optional(number, 3)
vcn_label = optional(string, "oci_vcn")
vcn_dns_label = optional(string, "OCIVCN")
vcn_ip_range = optional(string, "10.0.0.0/16")
ipv6_enabled = optional(bool, true)
dhcp_dns = optional(list(string), ["1.1.1.1", "1.0.0.1"])
dhcp_label = optional(string, "oci_dhcp")
subnet_label = optional(string, "oci_subnet")
subnet_dns_label = optional(string, "OCISubnet")
subnet_ip_range = optional(string, "10.10.10.0/24")
gw_label = optional(string, "oci_gateway")
route_label = optional(string, "oci_route_tabel")
security_label = optional(string, "oci_security")
egress_rules = list(object({
protocol = optional(string, "all")
destination = optional(string, "0.0.0.0/0")
udp_options = optional(object({
min = optional(number)
max = optional(number)
}))
tcp_options = object({
min = optional(number)
max = optional(number)
})
}))
ingress_rules = list(object({
protocol = optional(string, "6")
source = optional(string, "0.0.0.0")
tcp_options = optional(object({
min = optional(number, 22)
max = optional(number, 22)
}))
udp_options = optional(object({
min = optional(number)
max = optional(number)
}))
}))
instance_label = optional(string, "oci_instance")
instance_shape = optional(string, "VM.Standard.E2.1.Micro")
instance_ocpus = optional(number, 1)
instance_shape_config_memory_in_gbs = optional(number, 1)
nic_label = optional(string, "oci_instance_nic")
hostname = optional(string, "oci_hostname")
gen_keypair = optional(bool, true)
public_key = optional(string)
private_key = optional(string)
host_vars = optional(any)
})
}
locals {
public_key = var.compute.gen_keypair ? tls_private_key.staging_key[0].public_key_openssh : var.compute.public_key
private_key = var.compute.gen_keypair ? tls_private_key.staging_key[0].private_key_openssh : var.compute.private_key
}
locals {
ipv4_address = oci_core_instance.oci_instance.public_ip
host_vars = merge(var.compute.host_vars, { ansible_host = local.ipv4_address })
host = {
"${var.compute.hostname}" = local.host_vars
}
}
data "oci_identity_availability_domain" "ad" {
compartment_id = var.oci_settings.compartment_ocid
ad_number = var.compute.ad
}
data "oci_core_images" "images" {
compartment_id = var.oci_settings.compartment_ocid
operating_system = "Oracle Linux"
operating_system_version = 9
shape = var.compute.instance_shape
}
variable "oci_settings" {
type = object({
region = string
tenancy_ocid = string
user_ocid = string
fingerprint = string
oci_private_key = string
compartment_ocid = string
})
} main.tf resource "oci_core_virtual_network" "oci_vcn" {
cidr_block = var.compute.vcn_ip_range
compartment_id = var.oci_settings.compartment_ocid
display_name = var.compute.vcn_label
dns_label = var.compute.vcn_dns_label
is_ipv6enabled = var.compute.ipv6_enabled
}
resource "oci_core_dhcp_options" "oci_dhcp_options" {
compartment_id = var.oci_settings.compartment_ocid
options {
type = "DomainNameServer"
server_type = "CustomDnsServer"
custom_dns_servers = var.compute.dhcp_dns
}
display_name = var.compute.dhcp_label
vcn_id = oci_core_virtual_network.oci_vcn.id
}
resource "oci_core_subnet" "oci_subnet" {
cidr_block = var.compute.subnet_ip_range
display_name = var.compute.subnet_label
dns_label = var.compute.subnet_dns_label
security_list_ids = [oci_core_security_list.oci_security_list.id]
compartment_id = var.oci_settings.compartment_ocid
vcn_id = oci_core_virtual_network.oci_vcn.id
route_table_id = oci_core_route_table.oci_route_table.id
dhcp_options_id = oci_core_dhcp_options.oci_dhcp_options.id
ipv6cidr_block = var.compute.ipv6_enabled ? "${substr(oci_core_virtual_network.oci_vcn.ipv6cidr_blocks[0], 0, length(oci_core_virtual_network.oci_vcn.ipv6cidr_blocks[0]) - 2)}${64}" : null
}
resource "oci_core_internet_gateway" "oci_internet_gateway" {
compartment_id = var.oci_settings.compartment_ocid
display_name = var.compute.gw_label
vcn_id = oci_core_virtual_network.oci_vcn.id
}
resource "oci_core_route_table" "oci_route_table" {
compartment_id = var.oci_settings.compartment_ocid
vcn_id = oci_core_virtual_network.oci_vcn.id
display_name = var.compute.route_label
route_rules {
destination = "0.0.0.0/0"
destination_type = "CIDR_BLOCK"
network_entity_id = oci_core_internet_gateway.oci_internet_gateway.id
}
}
resource "oci_core_security_list" "oci_security_list" { ## null values making headaches
compartment_id = var.oci_settings.compartment_ocid
vcn_id = oci_core_virtual_network.oci_vcn.id
display_name = var.compute.security_label
dynamic "egress_security_rules" {
for_each = var.compute.egress_rules
content {
protocol = egress_security_rules.value.protocol
destination = egress_security_rules.value.destination
udp_options {
max = egress_security_rules.value.udp_options.max
min = egress_security_rules.value.udp_options.min
}
tcp_options {
max = egress_security_rules.value.tcp_options.max
min = egress_security_rules.value.tcp_options.min
}
}
}
dynamic "ingress_security_rules" {
for_each = var.compute.ingress_rules
content {
protocol = ingress_security_rules.value.protocol
source = ingress_security_rules.value.source
udp_options {
max = ingress_security_rules.value.udp_options.max
min = ingress_security_rules.value.udp_options.min
}
tcp_options {
max = ingress_security_rules.value.tcp_options.max
min = ingress_security_rules.value.tcp_options.min
}
}
}
}
resource "oci_core_instance" "oci_instance" {
availability_domain = data.oci_identity_availability_domain.ad.name
compartment_id = var.oci_settings.compartment_ocid
display_name = var.compute.instance_label
shape = var.compute.instance_shape
shape_config {
ocpus = var.compute.instance_ocpus
memory_in_gbs = var.compute.instance_shape_config_memory_in_gbs
}
create_vnic_details {
subnet_id = oci_core_subnet.oci_subnet.id
display_name = var.compute.nic_label
assign_public_ip = true
hostname_label = var.compute.hostname
assign_ipv6ip = var.compute.ipv6_enabled
}
source_details {
source_type = "image"
source_id = lookup(data.oci_core_images.images.images[0], "id") ### again unsure how to make a varible
}
metadata = {
ssh_authorized_keys = local.public_key
}
}
resource "terraform_data" "provision" {
input = oci_core_instance.oci_instance.public_ip
connection {
type = "ssh"
host = oci_core_instance.oci_instance.public_ip
user = "opc"
private_key = local.private_key ## dont like this
}
provisioner "remote-exec" {
inline = [ # add swap as 1 g memory nd 1 g swap isnt enough for dnf to work
"sudo swapoff -a",
"sudo dd if=/dev/zero of=/.swapfile bs=512M count=8", #512M * 8 = 4GB
"sudo mkswap /.swapfile",
"sudo swapon /.swapfile"
]
}
}
resource "tls_private_key" "staging_key" {
count = var.compute.gen_keypair ? 1 : 0
algorithm = "ED25519"
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Community Note
Terraform Version and Provider Version
Affected Resource(s)
oci_core_security_list
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
security list created without error as the plan specified
Actual Behavior
above error saying known values are null
Steps to Reproduce
terraform apply
Important Factoids
tofu plan shows
however the apply sats the known values eg protocol are null
References
The text was updated successfully, but these errors were encountered: