Closed adrianotanaka closed 6 years ago
You are combining two methods of assigning the IP reservation, you don't need to use the opc_compute_ip_address_association
resource if you are assigning the opc_compute_ip_address_reservation
to the interface directly in the networking_info
config.
The difference is: when assigning the ip reservation in the nat
attribute of the networking_info
the Public IP is associated to the instance automatically on instance creation. If the nat
config is ommited, the opc_compute_ip_address_association
resource can be used to associate the public IP after the instance has been created.
A couple of other recommendations:
${opc_compute_ip_address_reservationreserva_ip.name}
in the nat
assignment rather than reconstructing the name - this way terraform infers the dependency relationship and will ensure the ip reservation is created before creating the instance. Same would apply for ip_network
name and the vnic_sets
if they are defined in the same config.vnic
name its best to use a name that includes the instance name, vnic names are global within the tenancy. resource "opc_compute_instance" "vm" {
name = "${var.nome_maquina}-${var.cliente}"
hostname = "${var.nome_maquina}"
label = "${var.nome_maquina}${var.cliente}"
shape = "oc3"
storage {
index = 1
volume = "${opc_compute_storage_volume.boot-volume.name}"
}
boot_order = [ 1 ]
networking_info {
index = 1
ip_network = "APP"
is_default_gateway = true
vnic_sets = ["VNICSET_SSH"]
vnic= "${var.nome_maquina}-${var.cliente}_eth1"
shared_network = false
nat = ["opc_compute_ip_address_reservation.reserva_ip.name"]
}
ssh_keys = ["${opc_compute_ssh_key.chave.name}"]
}
Take a look at the example Compute Instance with Public IP Address Reservation on an IP Network Interface for a full example of using IP Networks IP Address Reservations.
Thanks Stephen, with your help I finished the environment.
This is the final version of .tf file:
##Source
resource "opc_compute_storage_volume" "boot-volume" {
size = "20"
name = "boot-${var.nome_maquina}-${var.cliente}"
bootable = true
image_list = "/oracle/public/OL_7.2_UEKR4_x86_64"
image_list_entry = 1
}
resource "opc_compute_ip_address_reservation" "reserva_ip" {
name = "IPPUB-${var.nome_maquina}-${var.cliente}"
ip_address_pool = "public-ippool"
}
resource "opc_compute_instance" "vm" {
name = "${var.nome_maquina}-${var.cliente}"
hostname = "${var.nome_maquina}"
label = "${var.nome_maquina}${var.cliente}"
shape = "oc3"
#Discos
storage {
index = 1
volume = "${opc_compute_storage_volume.boot-volume.name}"
}
boot_order = [ 1 ]
#Rede
networking_info {
index = 1
ip_network = "APP"
is_default_gateway = "TRUE"
vnic_sets = ["VNICSET_SSH"]
vnic= "${var.nome_maquina}-${var.cliente}_eth1"
shared_network = "FALSE"
nat = ["${opc_compute_ip_address_reservation.reserva_ip.name}"]
}
ssh_keys = ["${opc_compute_ssh_key.chave.name}"]
}
output "public_ip_address" {
value = "${opc_compute_ip_address_reservation.reserva_ip.ip_address}"
}
Hi for all,
I'm with a problem creating an ip reservation and assign this to an instance.
Terraform Version
Terraform v0.11.7
Affected Resource(s)
Please list the resources as a list, for example: opc_compute_ip_address_association
Terraform Configuration Files
Debug Output
https://gist.github.com/adrianotanaka/141282605c6b6992f39748e8f30b5864
Expected Behavior
Create an IP Reservation on IP Network, Assign created IP reservation with Instance.
Actual Behavior
Steps to Reproduce
terraform apply
with provided .tf file