Last active
September 27, 2022 20:52
-
-
Save scross01/21e5e934c5aca5602be712fac5f9eacb to your computer and use it in GitHub Desktop.
Oracle Cloud Infrastructure Instance with Terraform remote-exec Provisioner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "oci_core_instance" "example" { | |
compartment_id = "${var.compartment_ocid}" | |
availability_domain = "${var.availability_domain}" | |
subnet_id = "${var.subnet_ocid}" | |
display_name = "example" | |
image = "${lookup(data.oci_core_images.image-list.images[0], "id")}" | |
shape = "VM.Standard1.1" | |
metadata = { | |
ssh_authorized_keys = "${file(var.ssh_public_key_file)}" | |
} | |
connection { | |
type = "ssh" | |
host = "${self.public_ip}" | |
user = "opc" | |
private_key = "${file(var.ssh_private_key_file)}" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"echo 'This instance was provisioned by Terraform.' | sudo tee /etc/motd", | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kaustubh77 I set my host this way: