create
¶
Description¶
Creates a new load balancer in the specified compartment. For general information about load balancers, see Overview of the Load Balancing Service.
For the purposes of access control, you must provide the OCID of the compartment where you want the load balancer to reside. Notice that the load balancer doesn’t have to be in the same compartment as the VCN or backend set. If you’re not sure which compartment to use, put the load balancer in the same compartment as the VCN. For information about access control and compartments, see Overview of the IAM Service.
You must specify a display name for the load balancer. It does not have to be unique, and you can change it.
For information about Availability Domains, see Regions and Availability Domains. To get a list of Availability Domains, use the ListAvailabilityDomains operation in the Identity and Access Management Service API.
All Oracle Cloud Infrastructure resources, including load balancers, get an Oracle-assigned, unique ID called an Oracle Cloud Identifier (OCID). When you create a resource, you can find its OCID in the response. You can also retrieve a resource’s OCID by using a List API operation on that resource type, or by viewing the resource in the Console. Fore more information, see Resource Identifiers.
After you send your request, the new object’s state will temporarily be PROVISIONING. Before using the object, first make sure its state has changed to RUNNING.
When you create a load balancer, the system assigns an IP address. To get the IP address, use the GetLoadBalancer operation.
Required Parameters¶
-
--compartment-id
,
-c
[text]
¶
The OCID of the compartment in which to create the load balancer.
-
--display-name
[text]
¶
A user-friendly name. It does not have to be unique, and it is changeable. Avoid entering confidential information.
Example:
example_load_balancer
-
--shape-name
[text]
¶
A template that determines the total pre-provisioned bandwidth (ingress plus egress). To get a list of available shapes, use the ListShapes operation.
Example:
flexible` NOTE: After May 2023, Fixed shapes - 10Mbps, 100Mbps, 400Mbps, 8000Mbps would be deprecated and only shape allowed would be `Flexible
-
--subnet-ids
[complex type]
¶
An array of subnet OCIDs. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
Optional Parameters¶
-
--backend-sets
[complex type]
¶
This option is a JSON dictionary of type dict(str, BackendSetDetails). For documentation on BackendSetDetails please see our API reference: https://docs.cloud.oracle.com/api/#/en/loadbalancer/20170115/datatypes/BackendSetDetails. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--certificates
[complex type]
¶
This option is a JSON dictionary of type dict(str, CertificateDetails). For documentation on CertificateDetails please see our API reference: https://docs.cloud.oracle.com/api/#/en/loadbalancer/20170115/datatypes/CertificateDetails. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags.
Example:
{"Operations": {"CostCenter": "42"}}
This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags.
Example:
{"Department": "Finance"}
This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--from-json
[text]
¶
Provide input to this command as a JSON document from a file using the file://path-to/file syntax.
The --generate-full-command-json-input
option can be used to generate a sample json file to be used with this command option. The key names are pre-populated and match the command option names (converted to camelCase format, e.g. compartment-id –> compartmentId), while the values of the keys need to be populated by the user before using the sample file as an input to this command. For any command option that accepts multiple values, the value of the key can be a JSON array.
Options can still be provided on the command line. If an option exists in both the JSON document and the command line then the command line specified value will be used.
For examples on usage of this option, please see our “using CLI with advanced JSON options” link: https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/cliusing.htm#AdvancedJSONOptions
-
--hostnames
[complex type]
¶
This option is a JSON dictionary of type dict(str, HostnameDetails). For documentation on HostnameDetails please see our API reference: https://docs.cloud.oracle.com/api/#/en/loadbalancer/20170115/datatypes/HostnameDetails. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--ip-mode
[text]
¶
Whether the load balancer has an IPv4 or IPv6 IP address.
If “IPV4”, the service assigns an IPv4 address and the load balancer supports IPv4 traffic.
If “IPV6”, the service assigns an IPv6 address and the load balancer supports IPv6 traffic.
Example:
"ipMode":"IPV6"
Accepted values are:
IPV4, IPV6
-
--is-delete-protection-enabled
[boolean]
¶
Whether or not the load balancer has delete protection enabled.
If “true”, the loadbalancer will be protected against deletion if configured to accept traffic.
If “false”, the loadbalancer will not be protected against deletion.
Delete protection will not be enabled unless a value of “true” is provided. Example: true
-
--is-private
[boolean]
¶
Whether the load balancer has a VCN-local (private) IP address.
If “true”, the service assigns a private IP address to the load balancer.
If “false”, the service assigns a public IP address to the load balancer.
A public load balancer is accessible from the internet, depending on your VCN’s security list rules. For more information about public and private load balancers, see How Load Balancing Works.
Example:
true
-
--is-request-id-enabled
[boolean]
¶
Whether or not the load balancer has the Request Id feature enabled for HTTP listeners.
If “true”, the load balancer will attach a unique request id header to every request passed through from the load balancer to load balancer backends. This same request id header also will be added to the response the lb received from the backend handling the request before the load balancer returns the response to the requestor. The name of the unique request id header is set the by value of requestIdHeader.
If “false”, the loadbalancer not add this unique request id header to either the request passed through to the load balancer backends nor to the reponse returned to the user.
New load balancers have the Request Id feature disabled unless isRequestIdEnabled is set to true.
Example:
true
-
--listeners
[complex type]
¶
This option is a JSON dictionary of type dict(str, ListenerDetails). For documentation on ListenerDetails please see our API reference: https://docs.cloud.oracle.com/api/#/en/loadbalancer/20170115/datatypes/ListenerDetails. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--max-wait-seconds
[integer]
¶
The maximum time to wait for the work request to reach the state defined by --wait-for-state
. Defaults to 1200 seconds.
-
--nsg-ids
[complex type]
¶
The array of NSG OCIDs to be used by this Load Balancer. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--path-route-sets
[complex type]
¶
This option is a JSON dictionary of type dict(str, PathRouteSetDetails). For documentation on PathRouteSetDetails please see our API reference: https://docs.cloud.oracle.com/api/#/en/loadbalancer/20170115/datatypes/PathRouteSetDetails. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--request-id-header
[text]
¶
If isRequestIdEnabled is true then this field contains the name of the header field that contains the unique request id that is attached to every request from the load balancer to the load balancer backends and to every response from the load balancer.
If a request to the load balancer already contains a header with same name as specified in requestIdHeader then the load balancer will not change the value of that field.
If isRequestIdEnabled is false then this field is ignored.
If this field is not set or is set to “” then this field defaults to X-Request-Id
Notes: * Unless the header name is “” it must start with “X-” prefix. * Setting the header name to “” will set it to the default: X-Request-Id.
-
--reserved-ips
[complex type]
¶
An array of reserved Ips.
This option is a JSON list with items of type ReservedIP. For documentation on ReservedIP please see our API reference: https://docs.cloud.oracle.com/api/#/en/loadbalancer/20170115/datatypes/ReservedIP. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--rule-sets
[complex type]
¶
This option is a JSON dictionary of type dict(str, RuleSetDetails). For documentation on RuleSetDetails please see our API reference: https://docs.cloud.oracle.com/api/#/en/loadbalancer/20170115/datatypes/RuleSetDetails. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--shape-details
[complex type]
¶
The configuration details to create load balancer using Flexible shape. This is required only if shapeName is Flexible. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--ssl-cipher-suites
[complex type]
¶
This option is a JSON dictionary of type dict(str, SSLCipherSuiteDetails). For documentation on SSLCipherSuiteDetails please see our API reference: https://docs.cloud.oracle.com/api/#/en/loadbalancer/20170115/datatypes/SSLCipherSuiteDetails. This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
-
--wait-for-state
[text]
¶
This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state
SUCCEEDED --wait-for-state
FAILED would return on whichever lifecycle state is reached first. If timeout is reached, a return code of 2 is returned. For any other error, a return code of 1 is returned.
Accepted values are:
ACCEPTED, FAILED, IN_PROGRESS, SUCCEEDED
-
--wait-interval-seconds
[integer]
¶
Check every --wait-interval-seconds
to see whether the work request has reached the state defined by --wait-for-state
. Defaults to 30 seconds.
Extended Defined tags for ZPR for this resource. Each key is predefined and scoped to a namespace.
Example:
{"Oracle-ZPR": {"MaxEgressCount": {"value":"42","mode":"audit", "usagetype" : "zpr"}}}
This is a complex type whose value must be valid JSON. The value can be provided as a string on the command line or passed in as a file using the file://path/to/file syntax.
The --generate-param-json-input
option can be used to generate an example of the JSON which must be provided. We recommend storing this example
in a file, modifying it as needed and then passing it back in via the file:// syntax.
Examples
When creating a load balancer, there are two main options:
Providing all information when calling the
create
commandProviding minimal information to the
create
command then then using individual commands to “assemble” the load balancer post-creation
Working samples for both approaches can be found here.
Providing all information at create time¶
Under this option, you would call the create
command and specify the --certificates
, --backend-sets
, --listener
and --path-route-sets
options in order to also create these items when creating the load balancer. Since those options are complex types, it is recommended that you place their input in JSON files and then specify these files as input to the command using the file:// syntax. For example:
oci lb load-balancer create --backend-sets file://path/to/backend/set/file.json
You can discover the format of the input you need to provide by using the --generate-param-json-input
option. For example:
oci lb load-balancer create --generate-param-json-input certificates
oci lb load-balancer create --generate-param-json-input backend-sets
oci lb load-balancer create --generate-param-json-input listeners
oci lb load-balancer create --generate-param-json-input path-route-sets
As an alternative to providing those individal options, you can specify all the input to the command in a single file using the --from-json
option. For example:
oci lb load-balancer create --from-json file://path/to/file/of/input.json
You can discover the format of the input you need to provide by using the --generate-full-command-json-input
option. For example:
oci lb load-balancer create --generate-full-command-json-input
Providing minimal information and then assembling via other commands¶
Under this option, you would only supply the mandatory arguments to the create
command (and not any of the input marked as COMPLEX TYPE
) and then use other operations to add certificates, backend sets, listeners and path route sets. This approach is more applicable if you do not wish to prepare JSON input files.
The key commands you’ll need to be aware of are:
This command
You would tie these together in sequence by:
# Create load balancer with minimal attributes
oci lb load-balancer create
# Create a certificate bundle associated with the load balancer (call command multiple times if needed)
oci lb certificate create
# Create a backend set associated with the load balancer (call command multiple times if needed)
# You may need the details of the certificate you previously created
oci lb backend-set create
# Add multiple backends to the backend set
oci lb backend create
oci lb backend create
# Create a path route set for a particular listener of the load balancer to route traffic to appropriate back-end set
oci lb path-route-set create
# Add a listener to the load balancer (call command multiple times if needed)
# This will take a --protocol option, whose valid values you can discover by oci lb protocol lists
# You may also need the details of the certificate you previously created
oci lb listener create
Global Parameters¶
Use oci --help
for help on global parameters.
--auth-purpose
, --auth
, --cert-bundle
, --cli-auto-prompt
, --cli-rc-file
, --config-file
, --connection-timeout
, --debug
, --defaults-file
, --endpoint
, --generate-full-command-json-input
, --generate-param-json-input
, --help
, --latest-version
, --max-retries
, --no-retry
, --opc-client-request-id
, --opc-request-id
, --output
, --profile
, --proxy
, --query
, --raw-output
, --read-timeout
, --realm-specific-endpoint
, --region
, --release-info
, --request-id
, --version
, -?
, -d
, -h
, -i
, -v
Example using required parameter¶
Copy and paste the following example into a JSON file, replacing the example parameters with your own.
oci lb load-balancer create --generate-param-json-input subnet-ids > subnet-ids.json
Copy the following CLI commands into a file named example.sh. Run the command by typing “bash example.sh” and replacing the example parameters with your own.
Please note this sample will only work in the POSIX-compliant bash-like shell. You need to set up the OCI configuration and appropriate security policies before trying the examples.
export compartment_id=<substitute-value-of-compartment_id> # https://docs.cloud.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/lb/load-balancer/create.html#cmdoption-compartment-id
export display_name=<substitute-value-of-display_name> # https://docs.cloud.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/lb/load-balancer/create.html#cmdoption-display-name
export shape_name=<substitute-value-of-shape_name> # https://docs.cloud.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/lb/load-balancer/create.html#cmdoption-shape-name
oci lb load-balancer create --compartment-id $compartment_id --display-name $display_name --shape-name $shape_name --subnet-ids file://subnet-ids.json