Skip to content

aattwwss/oci-instance-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oci-instance-go

A golang port of https://github.com/hitrov/oci-arm-host-capacity

This script will attempt to automatically create an instance in oracle cloud infrastructure according to the config in the .env file.

Confiuration

Follow the same configuration guide in here and populate the .env file accordingly.

  1. Go to https://cloud.oracle.com/identity/domains/my-profile/api-keys
  2. Click on Add API Key
  3. Download the private key
  4. Click on Add
  5. Either fill the .env file with the content of the config file, or use the config file directly as described below

OCI API Key Configuration

I have also added support for the default configuration provider from the official GO sdk. If you have the config file and private key in their default location of $HOME/.oci/config, then you do not need to populate the following 4 fields:

  • OCI_REGION
  • OCI_USER_ID
  • OCI_TENANCY_ID
  • OCI_KEY_FINGERPRINT

Running the script

Included retry with delay

You can set the script to run forever with the specified delay in minute using the -t flag.

# run one time and end
go run .
./oci-instance-go 

#retry every 15 minutes
go run . -t=15
./oci-instance-go  -t=15

With prebuilt binaries

In the release page, download the binary for your OS and platform. Then run the binary and the .env file in the same folder.

# run one time and end
./oci-instance-go

#retry every 15 minutes
./oci-instance-go  -t=1 5

Without compiling

git clone https://github.com/aattwwss/oci-instance-go.git
cd oci-instance-go
cp /path/to/.env .
go run .

With compiling

As GO allows you to compile the program into an executable, we run the executable with the .env file anywhere within the same platform.

git clone https://github.com/aattwwss/oci-instance-go.git
cd oci-instance-go
cp /path/to/.env .
go build .
./oci-instance-go