Skip to content

658 - enhancement - netapp-ontap_s3_bucket#669

Open
csahu9 wants to merge 9 commits into
integration/mainfrom
658-enhancement-netapp-ontap_s3_bucket
Open

658 - enhancement - netapp-ontap_s3_bucket#669
csahu9 wants to merge 9 commits into
integration/mainfrom
658-enhancement-netapp-ontap_s3_bucket

Conversation

@csahu9
Copy link
Copy Markdown
Contributor

@csahu9 csahu9 commented Apr 22, 2026

Issue #658

  • added new option cors_rules, requires ONTAP 9.16 or later.

ACC test result:

TF_ACC=1 go test `go list ./... | grep -e provider` -v -run=TestAccS3BucketResource
=== RUN   TestAccS3BucketResource
--- PASS: TestAccS3BucketResource (28.95s)
PASS
ok      github.com/netapp/terraform-provider-netapp-ontap/internal/provider/protocols   28.964s

@csahu9 csahu9 linked an issue Apr 22, 2026 that may be closed by this pull request
@csahu9 csahu9 linked an issue May 11, 2026 that may be closed by this pull request
"cors_rules": schema.SetNestedAttribute{
MarkdownDescription: "The list of object store bucket CORS rules. Requires ONTAP 9.16.1 or later.",
Optional: true,
Computed: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this is required on 9.16.1 from https://docs.netapp.com/us-en/ontap-restapi/swagger-ui/index.html#/Object-Store/s3_bucket_create. Can you share the document link here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the POST model in swagger,

image

setplanmodifier.UseStateForUnknown(),
},
Validators: []validator.Set{
setvalidator.SizeAtLeast(1),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's optional but why it has to be at least one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because empty list is not a valid value for expose_headers parameter.
If we set below:
"cors": {
"rules": [
{
"max_age_seconds": 1,
"allowed_origins": [ "*" ],
"allowed_methods": [ "GET", "POST", "PUT", "DELETE" ],
"expose_headers": []
}
]
}

REST doesn't return any value for expose_headers:

image

So, I have added a condition to have at least one element if mentioned in config, for the better management of state and idempotency.

Comment thread docs/resources/s3_bucket.md Outdated
Requires ONTAP 9.10.1 or later. (see [below for nested schema](#nestedatt--audit_event_selector))
- `comment` (String) Additional information about the bucket.
- `constituents_per_aggregate` (Number) Number of constituents per aggregate. This option is not supported when type is set to NAS.
- `cors_rules` (Attributes Set) The list of object store bucket CORS rules. Requires ONTAP 9.16.1 or later. (see [below for nested schema](#nestedatt--cors_rules))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's 9.16.1 not 9.16?

Copy link
Copy Markdown
Contributor Author

@csahu9 csahu9 May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc, https://docs.netapp.com/us-en/ontap-cli/vserver-create.html
mentions the versions as 9.x.1.
Currently Ansible ontap modules handles version constraints as 9.x.1 instead of 9.x!

Should we incorporate the same in terraform repo too?
Let me update the doc to mention this as 9.16 for now.

Copy link
Copy Markdown
Contributor

@chuyich chuyich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The versions are not consistent in the code and doc.
  2. expose header: optional vs at least one
  3. can you share the test case? removal/update-to-empty case

@csahu9
Copy link
Copy Markdown
Contributor Author

csahu9 commented May 12, 2026

  1. The versions are not consistent in the code and doc.
  2. expose header: optional vs at least one
  3. can you share the test case? removal/update-to-empty case

I've added more test cases in protocols_s3_bucket_resource_test.go to test removing a single cors rule and setting cors_rules to an empty list.

[root@scs000952326 protocols]# TF_ACC=1 go test `go list ./... | grep -e provider` -v -run=TestAccS3BucketResource
=== RUN   TestAccS3BucketResource
--- PASS: TestAccS3BucketResource (40.86s)
PASS
ok      github.com/netapp/terraform-provider-netapp-ontap/internal/provider/protocols   40.879s

@csahu9 csahu9 requested a review from chuyich May 12, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Bucket CORS Rules [New Service]: Support for S3/Object store

2 participants