Skip to content

Commit

Permalink
changes for objectv2 & mpu
Browse files Browse the repository at this point in the history
changes for objectv2 & mpu

updated documentation
  • Loading branch information
Your Name committed Nov 24, 2021
1 parent 47a04dc commit 893b184
Show file tree
Hide file tree
Showing 12 changed files with 1,069 additions and 75 deletions.
72 changes: 65 additions & 7 deletions examples/ibm-cos-bucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,62 @@ resource "ibm_cos_bucket" "archive_expire_rule_cos" {
prefix = "logs/"
}
}
resource "ibm_cos_bucket" "expirebucket" {
bucket_name = "a-bucket-expiredat"
resource_instance_id = ibm_resource_instance.cos_instance.id
region_location = "us-south"
storage_class = "standard"
force_delete = true
object_versioning {
enable = true
}
expire_rule {
rule_id = "a-bucket-expire-rule"
enable = true
date = "2021-11-18"
prefix = "logs/"
}
noncurrent_version_expiration {
rule_id = "my-rule-id-bucket-ncversion"
enable = true
prefix = ""
noncurrent_days = 1
}
}
resource "ibm_cos_bucket" "cos_bucket" {
bucket_name = "a-bucket-expireddelemarkertest"
resource_instance_id = ibm_resource_instance.cos_instance.id
region_location = "us-south"
storage_class = "standard"
object_versioning {
enable = true
}
expire_rule {
rule_id = "my-rule-id-bucket-expired"
enable = true
expired_object_delete_marker = true
}
noncurrent_version_expiration {
rule_id = "my-rule-id-bucket-ncversion"
enable = true
prefix = ""
noncurrent_days = 1
}
}
resource "ibm_cos_bucket" "cos_bucket" {
bucket_name = "a-bucket-multipartupload"
resource_instance_id = ibm_resource_instance.cos_instance.id
region_location = "us-south"
storage_class = "standard"
abort_incomplete_multipart_upload_days {
rule_id = var.abort_mpu_ruleid
enable = true
prefix = ""
days_after_initiation = 1
}
}
resource "ibm_cos_bucket" "retention_cos" {
bucket_name = "a-bucket-retention"
Expand Down Expand Up @@ -171,16 +227,18 @@ data "ibm_cos_bucket" "standard-ams03" {
| usage_metrics_enabled | Specify true or false to set usage metrics (i.e. bytes_used). | `bool` | no
| request_metrics_enabled | Specify true or false to set cos request metrics (i.e. get,put,post request). | `bool` | no
| metrics_monitoring_crn | Required the first time metrics_monitoring is configured. The instance of IBM Cloud Monitoring that will receive the bucket metrics. | `string` | yes
| archive_ruleid | Unique identifier for the rule. | `string` | no
| regional_loc | The location for a regional bucket. Supported values are au-syd, eu-de, eu-gb, jp-tok,,us-east,us-south. | `string` | no
| archive_days | Specifies the number of days when the specific archive rule action takes effect. | `int` | yes
| archive_types | Specifies the archive type to which you want the object to transition. Supported values are Glacier or Accelerated. | `string` | yes
| expire_ruleid | Unique identifier for the rule. | `string` | no
| expire_days | Specifies the number of days when the specific expire rule action takes effect. | `int` | yes
| expire_prefix | Specifies a prefix filter to apply to only a subset of objects with names that match the prefix. | `string` | no
| type | Specifies the archive type to which you want the object to transition. Supported values are Glacier or Accelerated. | `string` |yes
| rule_id | Unique identifier for the rule. | `string` | no
| days | Specifies the number of days when the specific expire rule action takes effect. | `int` | no
| date | After the specifies date , the current version of objects in your bucket expires.. | `string` | no
| expired_object_delete_marker | Expired object delete markers can be automatically cleaned up to improve performance in bucket. This cannot be used alongside version expiration. | `bool` | no
| prefix | Specifies a prefix filter to apply to only a subset of objects with names that match the prefix. | `string` | no
| noncurrent_days | Configuration parameter in your policy that says how long to retain a non-current version before deleting it. | `int` | no
| days_after_initiation | Specifies the number of days that govern the automatic cancellation of part upload. Clean up incomplete multi-part uploads after a period of time. | `int` | no
| default | Specifies a default retention period to apply in all objects in the bucket. | `int` | yes
| maximum | Specifies maximum duration of time an object can be kept unmodified in the bucket. | `int` | yes
| minimum | Specifies minimum duration of time an object must be kept unmodified in the bucket. | `int` | yes
| permanent | Specifies a permanent retention status either enable or disable for a bucket. | `bool` | no
| enable | Specifies Versioning status either enable or Suspended for the objects in the bucket. | `bool` | no
| hard_quota | sets a maximum amount of storage (in bytes) available for a bucket. | `int` | no
| hard_quota | sets a maximum amount of storage (in bytes) available for a bucket. | `int` | no
29 changes: 20 additions & 9 deletions examples/ibm-cos-bucket/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ resource "ibm_resource_instance" "activity_tracker" {
resource_group_id = data.ibm_resource_group.cos_group.id
service = "logdnaat"
plan = "lite"
location = "us-south"
location = var.regional_loc
}
resource "ibm_resource_instance" "metrics_monitor" {
name = "metrics_monitor"
resource_group_id = data.ibm_resource_group.cos_group.id
service = "sysdig-monitor"
plan = "graduated-tier"
location = "us-south"
location = var.regional_loc
parameters = {
default_receiver = true
}
Expand Down Expand Up @@ -79,6 +79,24 @@ resource "ibm_cos_bucket" "cos_bucket" {
object_versioning {
enable = true
}
abort_incomplete_multipart_upload_days {
rule_id = var.abort_mpu_ruleid
enable = true
prefix = var.abort_mpu_prefix
days_after_initiation = var.abort_mpu_days_init
}
expire_rule {
rule_id = var.expire_ruleid
enable = true
date = var.expire_date
prefix = var.expire_prefix
}
noncurrent_version_expiration {
rule_id = var.nc_exp_ruleid
enable = true
prefix = var.nc_exp_prefix
noncurrent_days = var.nc_exp_days
}
}

resource "ibm_cos_bucket_object" "plaintext" {
Expand All @@ -87,10 +105,3 @@ resource "ibm_cos_bucket_object" "plaintext" {
content = "Hello World"
key = "plaintext.txt"
}

resource "ibm_cos_bucket_object" "base64" {
bucket_crn = ibm_cos_bucket.cos_bucket.crn
bucket_location = ibm_cos_bucket.cos_bucket.region_location
content_base64 = "RW5jb2RlZCBpbiBiYXNlNjQ="
key = "base64.txt"
}
28 changes: 28 additions & 0 deletions examples/ibm-cos-bucket/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,38 @@ variable "expire_days" {
default = 1
}

variable "expire_date" {
default = ""
}

variable "expire_prefix" {
default = ""
}

variable "nc_exp_ruleid" {
default = "test-obj-ver-exp-3"
}

variable "nc_exp_days" {
default = 1
}

variable "nc_exp_prefix" {
default = ""
}

variable "abort_mpu_ruleid" {
default = "test-abort_mpu-5"
}

variable "abort_mpu_days_init" {
default = 1
}

variable "abort_mpu_prefix" {
default = ""
}

variable "default_retention" {
default = "0"
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/IBM/event-notifications-go-admin-sdk v0.0.2
github.com/IBM/eventstreams-go-sdk v1.2.0
github.com/IBM/go-sdk-core/v5 v5.7.2
github.com/IBM/ibm-cos-sdk-go v1.7.0
github.com/IBM/ibm-cos-sdk-go v1.8.0
github.com/IBM/ibm-cos-sdk-go-config v1.2.0
github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1
github.com/IBM/keyprotect-go-client v0.7.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ github.com/IBM/go-sdk-core/v5 v5.7.2/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc
github.com/IBM/ibm-cos-sdk-go v1.3.1/go.mod h1:YLBAYobEA8bD27P7xpMwSQeNQu6W3DNBtBComXrRzRY=
github.com/IBM/ibm-cos-sdk-go v1.7.0 h1:3DZULY/D5WzjlIm+Iaj6h0surEjQs65EZk1YAe8+rj0=
github.com/IBM/ibm-cos-sdk-go v1.7.0/go.mod h1:Oi8AC5WNDhmUJgbo1GL2FtBdo0nRgbzE/1HmCL1SERU=
github.com/IBM/ibm-cos-sdk-go v1.8.0 h1:6d3BY+jo71JvQoyUwdtv4pemEfbnK/XSKQCKOEuWmks=
github.com/IBM/ibm-cos-sdk-go v1.8.0/go.mod h1:Oi8AC5WNDhmUJgbo1GL2FtBdo0nRgbzE/1HmCL1SERU=
github.com/IBM/ibm-cos-sdk-go-config v1.2.0 h1:1E93234yZgVS0ntm7eUwVb3h0AAayPGcxEhhizEN1LE=
github.com/IBM/ibm-cos-sdk-go-config v1.2.0/go.mod h1:Wetfgv6m1xyuzpZLQTTLIBsWstxjYa15h+Utj7x53Dk=
github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1 h1:T5UwRKKd+BoaPZ7UIlpJrzXzVTUEs8HcxwQ3pCIbORs=
Expand Down
77 changes: 76 additions & 1 deletion ibm/data_source_ibm_cos_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,34 @@ func dataSourceIBMCosBucket() *schema.Resource {
},
},
},
"abort_incomplete_multipart_upload_days": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"rule_id": {
Type: schema.TypeString,
Computed: true,
Description: "Unique identifier for the rule. Rules allow you to set a specific time frame after which objects are deleted. Set Rule ID for cos bucket",
},
"enable": {
Type: schema.TypeBool,
Computed: true,
Description: "Enable or disable rule for a bucket",
},
"prefix": {
Type: schema.TypeString,
Computed: true,
Description: "The rule applies to any objects with keys that match this prefix",
},
"days_after_initiation": {
Type: schema.TypeInt,
Computed: true,
Description: "Specifies the number of days when the specific rule action takes effect.",
},
},
},
},
"archive_rule": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -178,6 +206,11 @@ func dataSourceIBMCosBucket() *schema.Resource {
Computed: true,
Description: "Enable or disable an archive rule for a bucket",
},
"date": {
Type: schema.TypeString,
Computed: true,
Description: "Specifies the date when the specific rule action takes effect.",
},
"days": {
Type: schema.TypeInt,
Computed: true,
Expand All @@ -188,6 +221,11 @@ func dataSourceIBMCosBucket() *schema.Resource {
Computed: true,
Description: "The rule applies to any objects with keys that match this prefix",
},
"expired_object_delete_marker": {
Type: schema.TypeBool,
Computed: true,
Description: "Expired object delete markers can be automatically cleaned up to improve performance in bucket. This cannot be used alongside version expiration.",
},
},
},
},
Expand Down Expand Up @@ -234,6 +272,35 @@ func dataSourceIBMCosBucket() *schema.Resource {
},
},
},
"noncurrent_version_expiration": {
Type: schema.TypeList,
Computed: true,
Description: "Enable configuration expire_rule to COS Bucket after a defined period of time",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"rule_id": {
Type: schema.TypeString,
Computed: true,
Description: "Unique identifier for the rule.Expire rules allow you to set a specific time frame after which objects are deleted. Set Rule ID for cos bucket",
},
"enable": {
Type: schema.TypeBool,
Computed: true,
Description: "Enable or disable an expire rule for a bucket",
},
"prefix": {
Type: schema.TypeString,
Computed: true,
Description: "The rule applies to any objects with keys that match this prefix",
},
"noncurrent_days": {
Type: schema.TypeInt,
Computed: true,
Description: "Specifies the number of days when the specific rule action takes effect.",
},
},
},
},
"hard_quota": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -381,7 +448,7 @@ func dataSourceIBMCosBucketRead(d *schema.ResourceData, meta interface{}) error

}

// Read the lifecycle configuration (archive)
// Read the lifecycle configuration

gInput := &s3.GetBucketLifecycleConfigurationInput{
Bucket: aws.String(bucketName),
Expand All @@ -397,12 +464,20 @@ func dataSourceIBMCosBucketRead(d *schema.ResourceData, meta interface{}) error
if len(lifecycleptr.Rules) > 0 {
archiveRules := archiveRuleGet(lifecycleptr.Rules)
expireRules := expireRuleGet(lifecycleptr.Rules)
nc_expRules := nc_exp_RuleGet(lifecycleptr.Rules)
abort_mpuRules := abort_mpu_RuleGet(lifecycleptr.Rules)
if len(archiveRules) > 0 {
d.Set("archive_rule", archiveRules)
}
if len(expireRules) > 0 {
d.Set("expire_rule", expireRules)
}
if len(nc_expRules) > 0 {
d.Set("noncurrent_version_expiration", nc_expRules)
}
if len(abort_mpuRules) > 0 {
d.Set("abort_incomplete_multipart_upload_days", abort_mpuRules)
}
}
}

Expand Down
Loading

0 comments on commit 893b184

Please sign in to comment.