Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set Storage Class in aws_s3_bucket_object. #8174

Conversation

kwilczynski
Copy link
Contributor

An S3 Bucket owner may wish to select a different underlying storage class
for an object. This commit adds an optional "storage_class" attribute to the
aws_s3_bucket_object resource so that the owner of the S3 bucket can specify
an appropriate storage class to use when creating an object.

Signed-off-by: Krzysztof Wilczynski [email protected]

@kwilczynski kwilczynski force-pushed the feature/support-for-storage-class-aws_s3_bucket_object branch 2 times, most recently from 1a7e460 to f8052a8 Compare August 14, 2016 15:01
An S3 Bucket owner may wish to select a different underlying storage class
for an object. This commit adds an optional "storage_class" attribute to the
aws_s3_bucket_object resource so that the owner of the S3 bucket can specify
an appropriate storage class to use when creating an object.

Signed-off-by: Krzysztof Wilczynski <[email protected]>
@kwilczynski kwilczynski force-pushed the feature/support-for-storage-class-aws_s3_bucket_object branch from f8052a8 to 95fc7fe Compare August 14, 2016 15:20
@kwilczynski
Copy link
Contributor Author

Tests are passing:

$ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSS3BucketObject_storageClass'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/08/14 23:06:15 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSS3BucketObject_storageClass -timeout 120m
=== RUN   TestAccAWSS3BucketObject_storageClass
--- PASS: TestAccAWSS3BucketObject_storageClass (83.39s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    83.409s
$ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestResourceAWSS3BucketObjectStorageClass_validation'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/08/14 23:04:43 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestResourceAWSS3BucketObjectStorageClass_validation -timeout 120m
=== RUN   TestResourceAWSS3BucketObjectStorageClass_validation
--- PASS: TestResourceAWSS3BucketObjectStorageClass_validation (0.00s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    0.021s
$ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccDataSourceAWSS3BucketObject'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/08/15 00:21:27 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccDataSourceAWSS3BucketObject -timeout 120m
=== RUN   TestAccDataSourceAWSS3BucketObject_basic
--- PASS: TestAccDataSourceAWSS3BucketObject_basic (83.39s)
=== RUN   TestAccDataSourceAWSS3BucketObject_readableBody
--- PASS: TestAccDataSourceAWSS3BucketObject_readableBody (83.71s)
=== RUN   TestAccDataSourceAWSS3BucketObject_kmsEncrypted
--- PASS: TestAccDataSourceAWSS3BucketObject_kmsEncrypted (419.33s)
=== RUN   TestAccDataSourceAWSS3BucketObject_allParams
--- PASS: TestAccDataSourceAWSS3BucketObject_allParams (95.09s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    681.548s

@kwilczynski
Copy link
Contributor Author

@stack72 over to you 🚀

@stack72
Copy link
Contributor

stack72 commented Aug 14, 2016

Hey @kwilczynski

Thanks for the PR here :) Unfortunately, the storage_class parameter in the schema is still set as Computed. It hasn't been set as Optional. Therefore, we cannot set the storage_class

P.

@stack72 stack72 added the waiting-response An issue/pull request is waiting for a response from the community label Aug 14, 2016
@stack72 stack72 self-assigned this Aug 14, 2016
@kwilczynski
Copy link
Contributor Author

@stack72 thank you for looking at the code.

I can see it being set to both Computed and Optional in the commit, as per:

"storage_class": &schema.Schema{
  Type:         schema.TypeString,
  Optional:     true,
  Computed:     true,
  ValidateFunc: validateS3BucketObjectStorageClassType,
},

(commit: resource_aws_s3_bucket_object.go#L85-L90)

While testing, it seem to be working fine:

$ aws s3api list-objects --bucket storage-class-test-bucket-123
{
    "Contents": [
        {
            "LastModified": "2016-08-14T22:36:37.000Z",
            "ETag": "\"b10a8db164e0754105b7a99be72e3fe5\"",
            "StorageClass": "REDUCED_REDUNDANCY",
            "Key": "test123",
            "Owner": {
                "DisplayName": "krzysztof.wilczynski",
                "ID": "a5d3be8b581b81a30e799f9cb38b04b5c6cff18ffebfe364ebcf5a06d616b7c5"
            },
            "Size": 11
        },
        {
            "LastModified": "2016-08-14T22:36:37.000Z",
            "ETag": "\"c0e89a293bd36c7a768e4e9d2c5475a8\"",
            "StorageClass": "STANDARD",
            "Key": "test456",
            "Owner": {
                "DisplayName": "krzysztof.wilczynski",
                "ID": "a5d3be8b581b81a30e799f9cb38b04b5c6cff18ffebfe364ebcf5a06d616b7c5"
            },
            "Size": 15
        }
    ]
}

(saved execution log for the above):
https://gist.github.com/kwilczynski/90d8fd7688fc4c0d782b84ffa3f8d534

If there is something wrong, I am happy to correct it. Let me know :)

@stack72
Copy link
Contributor

stack72 commented Aug 15, 2016

@kwilczynski that's so odd - looks like for some reason - I cou;dnt see that locally at first glance. I'm blaming jetlag :)

Tests look good to me!

% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSS3BucketObject_'
==> Checking that code complies with gofmt requirements...
/Users/stacko/Code/go/bin/stringer
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/08/14 21:42:37 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSS3BucketObject_ -timeout 120m
=== RUN   TestAccAWSS3BucketObject_source
--- PASS: TestAccAWSS3BucketObject_source (56.10s)
=== RUN   TestAccAWSS3BucketObject_content
--- PASS: TestAccAWSS3BucketObject_content (62.68s)
=== RUN   TestAccAWSS3BucketObject_withContentCharacteristics
--- PASS: TestAccAWSS3BucketObject_withContentCharacteristics (60.24s)
=== RUN   TestAccAWSS3BucketObject_updates
--- PASS: TestAccAWSS3BucketObject_updates (88.72s)
=== RUN   TestAccAWSS3BucketObject_updatesWithVersioning
--- PASS: TestAccAWSS3BucketObject_updatesWithVersioning (92.33s)
=== RUN   TestAccAWSS3BucketObject_kms
--- PASS: TestAccAWSS3BucketObject_kms (220.18s)
=== RUN   TestAccAWSS3BucketObject_acl
--- PASS: TestAccAWSS3BucketObject_acl (94.00s)
=== RUN   TestAccAWSS3BucketObject_storageClass
--- PASS: TestAccAWSS3BucketObject_storageClass (92.27s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    766.537s

Thanks :)

Paul

@stack72 stack72 merged commit e943851 into hashicorp:master Aug 15, 2016
kwilczynski added a commit to kwilczynski/terraform that referenced this pull request Aug 18, 2016
…8174)

An S3 Bucket owner may wish to select a different underlying storage class
for an object. This commit adds an optional "storage_class" attribute to the
aws_s3_bucket_object resource so that the owner of the S3 bucket can specify
an appropriate storage class to use when creating an object.

Signed-off-by: Krzysztof Wilczynski <[email protected]>
@ghost
Copy link

ghost commented Apr 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement provider/aws waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants