oci.instance
Oracle Cloud Infrastructure Instance Resource
- example:
Returns all Instance resources in the tenancy
policies:
- name: find-all-instance-resources
resource: oci.instance
Filters
metrics
Instance Metrics Filter
- example:
This filter returns the resources with the aggregated metrics data that match the criteria specified in the request. Compartment OCID required. For information on metric queries, see Building Metric Queries and Monitoring Query Language.
policies:
- name: instance-with-low-cpu-utilization
description: |
Return the instances with the low CPU utilization
resource: oci.instance
filters:
- type: metrics
query: 'CpuUtilization[30d].mean() < 6'
policies:
- name: instance-with-low-cpu-utilization
description: Return the instances with the low CPU utilization is less than 50%
resource: oci.instance
filters:
- type: metrics
query: 'CpuUtilization[10d]{region="us-ashburn-1"}.max() < 50'
properties:
query:
type: string
type:
enum:
- metrics
required:
- query
- type
Actions
reboot
Restarts a compute instance.
- Example:
policies:
- name: reboot-compute-instance
resource: oci.instance
actions:
- reboot
- name: force-reboot-compute-instance
resource: oci.instance
actions:
- type: reboot
force: true
If ‘force’ option is passed, then a compute instance will be rebooted immediately.
https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/restartinginstance.htm
properties:
force:
type: boolean
type:
enum:
- reboot
required:
- type
remove-tag
Remove Tag Action
- example:
Remove the specified tags from the resource. Defined tag needs to be referred as ‘namespace.tagName’ as below in the policy file.
policies:
- name: remove-tag
resource: oci.instance
actions:
- type: remove-tag
defined_tags: ['cloud_custodian.environment']
freeform_tags: ['organization', 'team']
properties:
block_until_completion:
type: boolean
defined_tags:
items:
type: string
type: array
fail_on_error:
type: boolean
freeform_tags:
items:
type: string
type: array
type:
enum:
- remove-tag
required:
- type
start
Starts a stopped compute instance.
- Example:
policies:
- name: start-compute-instance
resource: oci.instance
actions:
- start
https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/restartinginstance.htm
properties:
block_until_completion:
type: boolean
fail_on_error:
type: boolean
type:
enum:
- start
required:
- type
stop
Stops a running compute instance.
- Example:
policies:
- name: stop-compute-instance
resource: oci.instance
actions:
- stop
- name: force-stop-compute-instance
resource: oci.instance
actions:
- type: stop
force: true
If ‘force’ option is passed, then a compute instance will be stopped immediately.
https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/restartinginstance.htm
properties:
force:
type: boolean
type:
enum:
- stop
required:
- type
update
Update a compute instace
- example:
Updates certain fields on the specified instance. Fields that are not provided in the request will not be updated.
Changes to metadata fields will be reflected in the instance metadata service (this may take up to a minute).
The OCID of the instance remains the same.
policies:
- name: update-compute-instance
resource: oci.instance
actions:
- type: update
shape: VM.Standard.E3.Flex
https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/edit-instance.htm
properties:
defined_tags:
type: object
freeform_tags:
type: object
shape:
type: string
shape_config:
properties:
memory_in_gbs:
type: number
nvmes:
type: integer
ocpus:
type: number
type: object
type:
enum:
- update
required:
- type