1. Introduction

A Maven plugin for the Oracle Cloud Infrastructure Java SDK.

Currently supported OCI Java SDK version is 2.46.0.

For the time being, this plugin provides the minimum capabilities to setup instances. In the future this plugin may provide access to all services exposed by the OCI Java SDK.
This plugin is not endorsed by Oracle nor does the company provide any support for it.

2. Usage

As this is a typical Maven plugin, simply declare the plugin in the <plugins> section of your POM file: Plugin declaration in pom.xml

<plugins>
    <plugin>
        <groupId>org.kordamp.maven</groupId>
        <artifactId>oci-maven-plugin</artifactId>
        <version>0.8.0</version>
    </plugin>
</plugins>

2.1. Requirements

Java 8 and Maven 3.6 are the minimum requirements to use this plugin.

2.1.1. Example

Provisioning an Instance with brand new Vcn, Subnets, InternetGateway, and InstanceConsoleConnection, making sure that OpenJDK is installed and port 8080 is open

mvn oci:setup-instance \
  -Doci.compartment.id=ocid1.compartment.oc1... \
  -Doci.verbose=true \
  -Doci.instance.name=myInstance \
  -Doci.image=Oracle-Linux-7.6-2019.04.18-0 \
  -Doci.shape=VM.Standard2.1 \
  -Doci.public.key.file=/home/myuser/.oci/oci-key.pub \
  -Doci.user.data.file=/home/myuser/oci/cloud-init.sh
cloud-init.sh
#!/bin/bash

# install Java
yum install -y yum java-1.8.0-openjdk

# amend firewall rules to allow port 8080
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload

2.2. Configuration

You can configure mojos using the standard ~/.oci/config file. The format of the configuration file is specified at this page, it looks something similar to

[DEFAULT]
user=ocid1.user.oc1...
fingerprint=f9:14:d0:...
key_file=~/.oci/oci_api_key.pem
tenancy=ocid1.tenancy.oc1...
region=eu-frankfurt-1
pass_phrase=<secret>

2.3. Mojos

All mojos share the following properties

Property Type System Environment Default Required

profile

String

oci.profile

OCI_PROFILE

DEFAULT

region

String

oci.region

OCI_REGION

showSecrets

boolean

false

skip

boolean

false

displayStreamLogs

boolean

oci.display.stream.logs

OCI_DISPLAY_STREAM_LOGS

false

Where each column defines

Property

The name of the mojo property.

Type

The type of the property.

System

The system property to set this property’s value. Use -D as prefix, i.e, -Doci.profile=mine

Environment

The environment key to set this property’s value. Set as key/value in command shell, i.e, export OCI_PROFILE=mine.

Default

Default value for this property (if any).

Required

Whether this property is required or not.

Property values are resolved in the following order

Environment > System Property > Property

Task paths may be used as prefix for Environment and System properties such that, for a task named step01 on a subproject named project1 you get the following Environment and System keys for the profile property

STEP01_OCI_PROFILE
step01.oci.profile
OCI_PROFILE
oci.profile

2.3.1. OCI Create

createBucket

Creates a Bucket.

createCompartment

Creates a Compartment.

createInstanceConsoleConnection

Creates an InstanceConsoleConnection.

createInstance

Creates an Instance.

createInternetGateway

Creates a InternetGateway.

createSubnet

Creates a Subnet.

createVcn

Creates a Vcn.

Table 1. createBucket
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 2. createCompartment
Property Type System Environment Default Required

compartmentDescription

String

oci.compartment.description

OCI_COMPARTMENT_DESCRIPTION

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

compartmentName

String

oci.compartment.name

OCI_COMPARTMENT_NAME

verbose

boolean

oci.verbose

OCI_VERBOSE

false

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 3. createInstanceConsoleConnection
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

instanceId

String

oci.instance.id

OCI_INSTANCE_ID

publicKeyFile

File

oci.public.key.file

OCI_PUBLIC_KEY_FILE

verbose

boolean

oci.verbose

OCI_VERBOSE

false

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 4. createInstance
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

image

String

oci.image

OCI_IMAGE

instanceName

String

oci.instance.name

OCI_INSTANCE_NAME

publicKeyFile

File

oci.public.key.file

OCI_PUBLIC_KEY_FILE

shape

String

oci.shape

OCI_SHAPE

subnetId

String

oci.subnet.id

OCI_SUBNET_ID

dnsLabel

String

oci.dns.label

OCI_DNS_LABEL

userDataFile

File

oci.user.data.file

OCI_USER_DATA_FILE

verbose

boolean

oci.verbose

OCI_VERBOSE

false

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 5. createInternetGateway
Property Type System Environment Default Required

internetGatewayName

String

oci.internet.gateway.name

OCI_INTERNET_GATEWAY_NAME

verbose

boolean

oci.verbose

OCI_VERBOSE

false

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 6. createSubnet
Property Type System Environment Default Required

availabilityDomain

String

oci.availability.domain

OCI_AVAILABILITY_DOMAIN

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

dnsLabel

String

oci.dns.label

OCI_DNS_LABEL

subnetName

String

oci.subnet.name

OCI_SUBNET_NAME

vcnId

String

oci.vcn.id

OCI_VCN_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 7. createVcn
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

dnsLabel

String

oci.dns.label

OCI_DNS_LABEL

vcnName

String

oci.vcn.name

OCI_VCN_NAME

verbose

boolean

oci.verbose

OCI_VERBOSE

false

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

2.3.2. OCI Delete

deleteBucket

Deletes a Bucket.

deleteCompartment

Deletes a Compartment.

deleteInstanceConsoleConnection

Deletes an InstanceConsoleConnection.

deleteInternetGateway

Deletes a InternetGateway.

deleteObject

Deletes an Object.

deleteSubnet

Deletes a Subnet.

deleteVcn

Deletes a Vcn.

Table 8. deleteBucket
Property Type System Environment Default Required

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 9. deleteCompartment
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 10. deleteInstanceConsoleConnection
Property Type System Environment Default Required

instanceConsoleConnectionId

String

oci.instance.console.connection.id

OCI_INSTANCE_CONSOLE_CONNECTION_ID

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 11. deleteInternetGateway
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

internetGatewayId

String

oci.internet.gateway.id

OCI_INTERNET_GATEWAY_ID

*

internetGatewayName

String

oci.internet.gateway.name

OCI_INTERNET_GATEWAY_NAME

*

vcnId

String

oci.vcn.id

OCI_VCN_ID

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Either internetGatewayId or internetGatewayName must be specified.
Table 12. deleteObject
Property Type System Environment Default Required

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

objectName

String

oci.object.name

OCI_OBJECT_NAME

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 13. deleteSubnet
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

subnetId

String

oci.subnet.id

OCI_SUBNET_ID

*

subnetName

String

oci.subnet.name

OCI_SUBNET_NAME

*

vcnId

String

oci.vcn.id

OCI_VCN_ID

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Either subneId or subnetName must be specified.
Table 14. deleteVcn
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

vcnId

String

oci.vcn.id

OCI_VCN_ID

*

vcnName

String

oci.vcn.name

OCI_VCNNAME

*

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Either vcnId or vcnName must be specified.

2.3.3. OCI Get

getBucket

Displays information for an specific Bucket.

getCompartment

Displays information for an specific Compartment.

getInstanceConsoleConnection

Displays information for an specific InstanceConsoleConnection.

getInstancePublicIp

Displays public Ip addresses for a particular Instance.

getInstance

Displays information for an specific Instance.

getInternetGateway

Displays information for an specific InternetGateway.

getNamespace

Displays information for an specific Namespace.

getObject

Displays information for an specific Object.

getRouteTable

Displays information for an specific RouteTable.

getSecurityList

Displays information for an specific SecurityList.

getSubnet

Displays information for an specific Subnet.

getVcn

Displays information for an specific Vcn.

Table 15. getBucket
Property Type Option System Environment Default

Required

bucketName

String

bucket-name

oci.bucket.name

OCI_BUCKET_NAME

namespaceName

String

namespace-name

oci.namespace.name

Table 16. getCompartment
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

Table 17. getInstanceConsoleConnection
Property Type System Environment Default Required

instanceConsoleConnectionId

String

oci.instance.console.connection.id

OCI_INSTANCE_CONSOLE_CONNECTION_ID

Table 18. getInstancePublicIp
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

instanceId

String

oci.instance.id

OCI_INSTANCE_ID

Table 19. getInstance
Property Type System Environment Default Required

instanceId

String

oci.instance.id

OCI_INSTANCE_ID

Table 20. getInternetGateway
Property Type System Environment Default Required

internetGatewayId

String

oci.internet.gateway.id

OCI_INTERNET_GATEWAY_ID

Table 21. getNamespace
Property Type Option System Environment Default

Required

compartmentId

String

compartment-id

oci.compartment.id

OCI_COMPARTMENT_ID

Table 22. getObject
Property Type Option System Environment Default

Required

bucketName

String

bucket-name

oci.bucket.name

OCI_BUCKET_NAME

objectName

String

object-name

oci.object.name

OCI_OBJECT_NAME

namespaceName

String

namespace-name

Table 23. getRouteTable
Property Type System Environment Default Required

routeTableId

String

oci.route.table.id

OCI_ROUTE_TABLE_ID

Table 24. getSecurityList
Property Type System Environment Default Required

securityListId

String

oci.security.list.id

OCI_SECURITY_LIST_ID

Table 25. getSubnet
Property Type System Environment Default Required

subnetId

String

oci.subnet.id

OCI_SUBNET_ID

Table 26. getVcn
Property Type System Environment Default Required

vcnId

String

oci.vcn.id

OCI_VCN_ID

2.3.4. OCI Instance

addIngressSecurityRule

Adds IngressSecurityRules to a SecurityList.

instanceAction

Performs a given action on an Instance.

setupInstance

Setups an Instance with Vcn, InternetGateway, Subnets, InstanceConsoleConnection, and Volume.

terminateInstance

Terminates an Instance.

Table 27. addIngressSecurityRule
Property Type System Environment Default Required

sourcePort

int

destinationPort

int

portType

String

oci.port.type

OCI_PORT_TYPE

TCP

securityListId

String

oci.security.list.id

OCI_SECURITY_LIST_ID

Valid values for portType are: TCP, UDP.
Table 28. instanceAction
Property Type System Environment Default Required

action

String

oci.action

OCI_ACTION

STOP

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

instanceId

String

oci.instance.id

OCI_INSTANCE_ID

*

instanceName

String

oci.instance.name

OCI_INSTANCE_NAME

*

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Either instanceId or instanceName must be specified.
Valid values for action are: RESET, SOFTRESET, SOFTSTOP, START, STOP.
Table 29. setupInstance
Property Type System Environment Default Required

availabilityDomain

String

oci.availability.domain

OCI_AVAILABILITY_DOMAIN

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

image

String

oci.image

OCI_IMAGE

instanceName

String

oci.instance.name

OCI_INSTANCE_NAME

publicKeyFile

File

oci.public.key.file

OCI_PUBLIC_KEY_FILE

shape

String

oci.shape

OCI_SHAPE

subnetId

String

oci.subnet.id

OCI_SUBNET_ID

userDataFile

File

oci.user.data.file

OCI_USER_DATA_FILE

verbose

boolean

oci.verbose

OCI_VERBOSE

false

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Table 30. terminateInstance
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

instanceId

String

oci.instance.id

OCI_INSTANCE_ID

*

instanceName

String

oci.instance.name

OCI_INSTANCE_NAME

*

regex

boolean

oci.regex

OCI_REGEX

false

waitForCompletion

boolean

oci.wait.for.completion

OCI_WAIT_FOR_COMPLETION

false

Either instanceId or instanceName must be specified. If regex is true then instanceName is treated as a regular expression.

2.3.5. OCI List

listAvailabilityDomains

Lists AvailabilityDomains available on a Compartment.

listBuckets

Lists available Buckets.

listCompartments

Lists available Compartments.

listImages

Lists Images available on a Compartment.

listInstanceConsoleConnections

Lists available InstanceConsoleConnection on an Instance.

listInstances

Lists available Instances.

listInternetGateways

Lists InternetGateways available on a Vcn.

listObjects

Lists available Objects in a Bucket.

listRegions

Lists available Regions.

listRouteTables

Lists RouteTables available on a Vcn.

listSecurityLists

Lists SecurityLists available on a Vcn.

listShapes

Lists Shapes available on a Compartment.

listSubnets

Lists Subnets available on a Vcn.

listUsers

Lists available Users.

listVcns

Lists Vcns available on a Compartment.

Table 31. listAvailabilityDomains
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 32. listBuckets
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

limit

Integer

oci.limit

OCI_LIMIT

1000

page

String

oci.page

OCI_PAGE

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 33. listCompartments
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 34. listImages
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 35. listInstanceConsoleConnections
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

instanceId

String

oci.instance.id

OCI_INSTANCE_ID

Table 36. listInstances
Property Type System Environment Default Required

availabilityDomain

String

oci.availability.domain

OCI_AVAILABILITY_DOMAIN

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 37. listInternetGateways
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

vcnId

String

oci.vcn.id

OCI_VCN_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 38. listObjects
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

limit

Integer

oci.limit

OCI_LIMIT

1000

delimiter

String

oci.delimiter

OCI_DELIMITER

prefix

String

oci.prefix

OCI_PREFIX

start

String

oci.start

OCI_START

end

String

oci.end

OCI_END

fields

String

oci.fields

OCI_FIELDS

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 39. listRegions
Property Type System Environment Default Required

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 40. listRouteTables
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

vcnId

String

oci.vcn.id

OCI_VCN_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 41. listSecurityLists
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

vcnId

String

oci.vcn.id

OCI_VCN_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 42. listShapes
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

Table 43. listSubnets
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

vcnId

String

oci.vcn.id

OCI_VCN_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 44. listUsers
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

Table 45. listVcns
Property Type System Environment Default Required

compartmentId

String

oci.compartment.id

OCI_COMPARTMENT_ID

verbose

boolean

oci.verbose

OCI_VERBOSE

false

2.3.6. OCI Object

clearBucket

Clears a Bucket.

copyObject

Copies an Object.

downloadObject

Downloads an Object to an specific location.

headBucket

Heads an specific Bucket.

headObject

Heads an specific Object.

putObject

Puts an Object on a Bucket.

Table 46. clearBucket
Property Type System Environment Default Required

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

async

boolean

oci.async

OCI_ASYNC

false

Table 47. copyObject
Property Type System Environment Default Required

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

objectName

String

oci.object.name

OCI_OBJECT_NAME

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

destinationRegion

String

oci.destination.region

OCI_DESTINATION_REGION

destinationBucketName

String

oci.destination.bucket.name

OCI_DESTINATION_BUCKET_NAME

destinationNamespaceName

String

oci.destination.namespace.name

OCI_DESTINATION_NAMESPACE_NAME

destinationObjectName

String

oci.destination.object.name

OCI_DESTINATION_OBJECT_NAME

Table 48. downloadObject
Property Type System Environment Default Required

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

objectName

String

oci.object.name

OCI_OBJECT_NAME

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

destinationDir

Directory

oci.destination.dir

OCI_DESTINATION_DIR

Table 49. headBucket
Property Type System Environment Default Required

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

objectName

String

oci.object.name

OCI_OBJECT_NAME

Table 50. headObject
Property Type System Environment Default Required

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

objectName

String

oci.object.name

OCI_OBJECT_NAME

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

Table 51. putObject
Property Type System Environment Default Required

bucketName

String

oci.bucket.name

OCI_BUCKET_NAME

objectName

String

oci.object.name

OCI_OBJECT_NAME

namespaceName

String

oci.namespace.name

OCI_NAMESPACE_NAME

file

File

oci.file

OCI_FILE

content-type

String

oci.content.type

OCI_CONTENT_TYPE

content-encoding

String

oci.content.encoding

OCI_CONTENT_ENCODING

content-language

String

oci.content.language

OCI_CONTENT_LANGUAGE

content-md5

String

oci.content.md5

OCI_CONTENT_MD5

2.3.7. OCI Query

searchResources

Lists information on resource types.

Table 52. searchResources
Property Type System Environment Default Required

resourceType

String

oci.resource.type

OCI_RESOURCE_TYPE