Terraform module to launch Ampere A1 Shapes on Oracle Cloud Infrastructure (OCI) Free-Tier
The goal of this code is to supply the minimal ammount of information to quickly have working Ampere A1 instances on OCI "Always Free". To keep things simple, The root compartment will be used (compartment id and tenancy id are the same) when launching the instance.
Addtional tasks performed by this code:
- Dynamically creating sshkeys to use when logging into the instance.
- Dynamically getting region, availability zone and image id..
- Creating necessary core networking configurations for the tenancy
- Rendering metadata to pass into the Ampere A1 instance.
- Launch 1 to 4 Ampere A1 instances with metadata and ssh keys.
- Output IP information to connect to the instance.
To get started clone this repository from GitHub locally.
The easiest way to configure is to use a terraform.tfvars in the project directory.
Please note that Compartment OCID are the same as Tenancy OCID for Root Compartment.
The following is an example of what terraform.tfvars should look like:
tenancy_ocid = "ocid1.tenancy.oc1..aaaaaaaabcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq"
user_ocid = "ocid1.user.oc1..aaaaaaaabcdefghijklmnopqrstuvwxyz0987654321zyxwvustqrponmlkj"
fingerprint = "a1:01:b2:02:c3:03:e4:04:10:11:12:13:14:15:16:17"
private_key_path = "/home/bwayne/.oci/oracleidentitycloudservice_bwayne-08-09-14-59.pem"
This can also be used as a terraform module. The following is example code for module usage supplying a custom cloud-init template:
variable "tenancy_ocid" {}
variable "user_ocid" {}
variable "fingerprint" {}
variable "private_key_path" {}
locals {
cloud_init_template_path = "${path.cwd}/cloud-init.yaml.tpl"
}
module "oci-ampere-a1" {
source = "github.com/amperecomputing/terraform-oci-ampere-a1"
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
# Optional
# oci_vcn_cidr_block = "10.2.0.0/16"
# oci_vcn_cidr_subnet = "10.2.1.0/24"
oci_os_image = "oraclelinux84"
instance_prefix = "ampere-a1-oraclelinux-84"
oci_vm_count = "1"
ampere_a1_vm_memory = "24"
ampere_a1_cpu_core_count = "4"
cloud_init_template_file = local.cloud_init_template_path
}
output "oci_ampere_a1_private_ips" {
value = module.oci-ampere-a1.ampere_a1_private_ips
}
output "oci_ampere_a1_public_ips" {
value = module.oci-ampere-a1.ampere_a1_public_ips
}
terraform init && terraform plan && terraform apply -auto-approve
- Apache Tomcat on Ampere A1: https://github.com/oracle-devrel/terraform-oci-arch-tomcat-autonomous
- WordPress on Ampere A1: https://github.com/oracle-quickstart/oci-arch-wordpress-mds/tree/master/matomo
- https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformproviderconfiguration.htm
- Where to Get the Tenancy's OCID and User's OCID
- API Key Authentication
- Instance Principal Authorization
- Security Token Authentication
- How to Generate an API Signing Key
- Bootstrapping a VM image in Oracle Cloud Infrastructure using Cloud-Init
- Oracle makes building applications on Ampere A1 Compute instances easy
- scross01/oci-linux-instance-cloud-init.tf
- scross01/autonomous_linux_7.7.tf
- Oracle Cloud Always Free
- OCI Terraform Level 200
- OCI Deploy Button
- Working with OCI Marketplace Stacks