Last active
April 23, 2023 19:55
-
-
Save scross01/5a66207fdc731dd99869a91461e9e2b8 to your computer and use it in GitHub Desktop.
Oracle Cloud Infrastructure instance with Terraform cloud-init user_data
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
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