-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCreateBucketUsingDualStackEndpoint_ObjectStorage.ps1
More file actions
70 lines (55 loc) · 3.48 KB
/
CreateBucketUsingDualStackEndpoint_ObjectStorage.ps1
File metadata and controls
70 lines (55 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<#
This example demonstrates listing Buckets in the Object Storage Service using IPv6 endpoints.
This example requires:
1) Module OCI.PSModules.Objectstorage. Install the module from Powershell Gallery.
2) Setting the $env:CompartmentId environment variable to a valid Compartment OCID.
3) Setting the $env:DisplayName environment variable.
#>
$UserErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = "Stop"
if ([string]::IsNullOrEmpty($env:CompartmentId) -or [string]::IsNullOrEmpty($env:DisplayName)) {
Throw 'Configure $env:CompartmentId and $env:DisplayName in the PS Session'
}
try {
# Import the module
Import-Module OCI.PSModules.Objectstorage
# Read CompartmentId and DisplayName environment variables
$CompartmentId = $env:CompartmentId
$BucketName = $env:DisplayName
#Create bucket details
$BucketDetails = New-Object Oci.ObjectstorageService.Models.CreateBucketDetails
$BucketDetails.CompartmentId = $CompartmentId
$BucketDetails.Name = $BucketName
###
### This portion of the example will create a bucket using dual-stack endpoints, assuming that the service supports it.
###
# Get the namespace of the account
Write-Host "Get-OCIObjectStorageNamespace -CompartmentId $CompartmentId -EnableDualStackEndpoints"
$NamespaceName = Get-OCIObjectStorageNamespace -CompartmentId $CompartmentId -EnableDualStackEndpoints
# Print the result
$NamespaceName
# Create a new Object Storage bucket
Write-Host "New-OCIObjectStorageBucket -NamespaceName $NamespaceName -CreateBucketDetails $BucketDetails -EnableDualStackEndpoints -Debug"
$Bucket = New-OCIObjectStorageBucket -NamespaceName $NamespaceName -CreateBucketDetails $BucketDetails -EnableDualStackEndpoints -Debug
Write-Host "Get-OCIObjectStorageBucket -NamespaceName $NamespaceName -BucketName $BucketName -EnableDualStackEndpoints -Debug"
Get-OCIObjectStorageBucket -NamespaceName $NamespaceName -BucketName $BucketName -EnableDualStackEndpoints -Debug | Out-Host
###
### This portion of the example will create a bucket without dual-stack endpoints, assuming that the service supports it and has enabled it by default.
### This part of the example is for demonstration purposes only and will not work unless Object Storage enables dual stack endpoints by default.
###
# # Get the namespace of the account
# Write-Host "Get-OCIObjectStorageNamespace -CompartmentId $CompartmentId -DisableDualStackEndpoints"
# $NamespaceName = Get-OCIObjectStorageNamespace -CompartmentId $CompartmentId -DisableDualStackEndpoints
# # Print the result
# $NamespaceName
# # Create a new Object Storage bucket
# Write-Host "New-OCIObjectStorageBucket -NamespaceName $NamespaceName -CreateBucketDetails $BucketDetails -DisableDualStackEndpoints -Debug"
# $Bucket = New-OCIObjectStorageBucket -NamespaceName $NamespaceName -CreateBucketDetails $BucketDetails -DisableDualStackEndpoints -Debug
# Write-Host "Get-OCIObjectStorageBucket -NamespaceName $NamespaceName -BucketName $BucketName -DisableDualStackEndpoints -Debug"
# Get-OCIObjectStorageBucket -NamespaceName $NamespaceName -BucketName $BucketName -DisableDualStackEndpoints -Debug | Out-Host
}
finally {
Write-Host "Remove-OCIObjectStorageBucket -NamespaceName $NamespaceName -BucketName $BucketName -FullResponse"
Remove-OCIObjectStorageBucket -NamespaceName $NamespaceName -BucketName $BucketName -FullResponse
$ErrorActionPreference = $UserErrorActionPreference
}