Skip to content

aattwwss/oci-instance-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 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.

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 1 minute
go run . -t=1
./oci-instance-go  -t=1

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 1 minute
./oci-instance-go  -t=1 

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