// This is an automatically generated code sample.
// To make this code sample work in your Oracle Cloud tenancy,
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
// boolean, number, and enum parameters with values not fitting your use case).
import * as containerinstances from "oci-containerinstances";
import common = require("oci-common");
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();
(async () => {
try {
// Create a service client
const client = new containerinstances.ContainerInstanceClient({ authenticationDetailsProvider: provider });
// Create a request and dependent object(s).
const createContainerInstanceDetails = {
displayName: "EXAMPLE-displayName-Value",
compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
availabilityDomain: "EXAMPLE-availabilityDomain-Value",
faultDomain: "EXAMPLE-faultDomain-Value",
shape: "EXAMPLE-shape-Value",
shapeConfig: {
ocpus: 3060.7778,
memoryInGBs: 3698.4568,
}
,
volumes: [{
volumeType: "EMPTYDIR", backingStore: containerinstances.models.ContainerEmptyDirVolume.BackingStore.EphemeralStorage,
name: "EXAMPLE-name-Value"
}
],
containers: [{
displayName: "EXAMPLE-displayName-Value",
imageUrl: "EXAMPLE-imageUrl-Value",
command: ["EXAMPLE--Value" ],
arguments: ["EXAMPLE--Value" ],
workingDirectory: "EXAMPLE-workingDirectory-Value",
environmentVariables: {
EXAMPLE_KEY_Yi213 :"EXAMPLE_VALUE_wu4d90Tp6DPXSUSEtOGq"
},
volumeMounts: [{
mountPath: "EXAMPLE-mountPath-Value",
volumeName: "EXAMPLE-volumeName-Value",
subPath: "EXAMPLE-subPath-Value",
isReadOnly: true,
partition: 89,
}
],
isResourcePrincipalDisabled: false,
resourceConfig: {
vcpusLimit: 384.64545,
memoryLimitInGBs: 2194.9727,
}
,
healthChecks: [{
healthCheckType: "HTTP", path: "EXAMPLE-path-Value",
port: 21851,
headers: [{
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
],
name: "EXAMPLE-name-Value",
initialDelayInSeconds: 217,
intervalInSeconds: 241,
failureThreshold: 19,
successThreshold: 928,
timeoutInSeconds: 744,
failureAction: containerinstances.models.ContainerHealthCheckFailureAction.None
}
],
securityContext: {
securityContextType: "LINUX", runAsUser: 31533,
runAsGroup: 30035,
isNonRootUserCheckEnabled: false,
isRootFileSystemReadonly: false,
capabilities: {
addCapabilities: [containerinstances.models.ContainerCapabilityType.CapAuditWrite ],
dropCapabilities: [containerinstances.models.ContainerCapabilityType.CapNetBindService ],
}
}
,
freeformTags: {
EXAMPLE_KEY_dMg1Z :"EXAMPLE_VALUE_l5dlLM8N08warUK7AlI2"
},
definedTags: {
EXAMPLE_KEY_dMJD7 :{
EXAMPLE_KEY_mGCs7 :"EXAMPLE--Value"
}
},
}
],
vnics: [{
displayName: "EXAMPLE-displayName-Value",
hostnameLabel: "EXAMPLE-hostnameLabel-Value",
isPublicIpAssigned: false,
skipSourceDestCheck: true,
nsgIds: ["EXAMPLE--Value" ],
privateIp: "EXAMPLE-privateIp-Value",
subnetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
freeformTags: {
EXAMPLE_KEY_xJBVg :"EXAMPLE_VALUE_b97k5iIPcPYVo584j7K1"
},
definedTags: {
EXAMPLE_KEY_j3sAv :{
EXAMPLE_KEY_EH1jV :"EXAMPLE--Value"
}
},
}
],
dnsConfig: {
nameservers: ["EXAMPLE--Value" ],
searches: ["EXAMPLE--Value" ],
options: ["EXAMPLE--Value" ],
}
,
gracefulShutdownTimeoutInSeconds: 62,
imagePullSecrets: [{
secretType: "VAULT", secretId: "ocid1.test.oc1..<unique_ID>EXAMPLE-secretId-Value",
registryEndpoint: "EXAMPLE-registryEndpoint-Value"
}
],
containerRestartPolicy: containerinstances.models.ContainerInstance.ContainerRestartPolicy.Never,
freeformTags: {
EXAMPLE_KEY_Qwb0s :"EXAMPLE_VALUE_Oh9BRxOzLs271Uznrui4"
},
definedTags: {
EXAMPLE_KEY_Zyzwd :{
EXAMPLE_KEY_XzLyq :"EXAMPLE--Value"
}
},
}
const createContainerInstanceRequest: containerinstances.requests.CreateContainerInstanceRequest = {
createContainerInstanceDetails: createContainerInstanceDetails,
opcRetryToken: "EXAMPLE-opcRetryToken-Value",
opcRequestId: "GWCZWDK5WBMLOUDMZT2C<unique_ID>",
};
// Send request to the Client.
const createContainerInstanceResponse = await client.createContainerInstance(createContainerInstanceRequest);
}
catch (error) {
console.log("createContainerInstance Failed with error " + error);
}
})();