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'

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

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']

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

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

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