Skip to content

Instantly share code, notes, and snippets.

@scross01
Last active April 23, 2023 19:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scross01/5a66207fdc731dd99869a91461e9e2b8 to your computer and use it in GitHub Desktop.
Save scross01/5a66207fdc731dd99869a91461e9e2b8 to your computer and use it in GitHub Desktop.
Oracle Cloud Infrastructure instance with Terraform cloud-init user_data
data "template_file" "cloud-config" {
template = <<YAML
#cloud-config
runcmd:
- echo 'This instance was provisioned by Terraform.' >> /etc/motd
YAML
}
resource "oci_core_instance" "example" {
count = 1
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)}"
user_data = "${base64encode(data.template_file.cloud-config.rendered)}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment