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

"prefix" of s3_bucket have_lifecycle_rule does not work #365

Closed
oosumi opened this issue Apr 20, 2018 · 7 comments
Closed

"prefix" of s3_bucket have_lifecycle_rule does not work #365

oosumi opened this issue Apr 20, 2018 · 7 comments
Assignees
Labels

Comments

@oosumi
Copy link

oosumi commented Apr 20, 2018

  • awspec v1.5.1

It seems that 'nil' will be returned by AWS side change.
Instead we will use filter.prefix.
However, I do not know if it has changed in all environments.

This is deprecated; use Filter instead.

@htnosm
Copy link
Collaborator

htnosm commented Apr 20, 2018

The above pull request is a draft.
As a separate issue from the above,
'awspec' abends abnormally if there is tag setting in filter of lifecycle.

`child_frame': NotImplementedError (NotImplementedError)

@htnosm
Copy link
Collaborator

htnosm commented Apr 20, 2018

It is a failure case by tag setting.

Error Pattern

S3 lifecycle-configuration

Set Filter Tag.

$ aws s3api get-bucket-lifecycle-configuration --bucket check-dummy-bucket --query 'Rules[]'
[
    {
        "Filter": {
            "And": {
                "Prefix": "",
                "Tags": [
                    {
                        "Value": "test",
                        "Key": "tagtest"
                    }
                ]
            }
        },
        "Status": "Enabled",
        "Expiration": {
            "Days": 365
        },
        "ID": "test-lifecycle"
    }
]

spec

$ cat spec/s3_bucket_spec.rb
require 'awspec'

describe s3_bucket('check-dummy-bucket') do
  it { should exist }
  it do
    should have_lifecycle_rule(
      id: 'test-lifecycle',
      expiration: { days: 365 },
      transitions: [],
      status: 'Enabled'
    )
  end
end

rake result

Failures:

  1) s3_bucket 'check-dummy-bucket' should have lifecycle rule {:id=>"test-lifecycle", :expiration=>{:days=>365}, :transitions=>[], :status=>"Enabled"}
     Failure/Error:
       should have_lifecycle_rule(
         id: 'test-lifecycle',
         expiration: { days: 365 },
         transitions: [],
         status: 'Enabled'
       )

     NotImplementedError:
       NotImplementedError
     # ./spec/s3_bucket_spec.rb:6:in `block (2 levels) in <top (required)>'

Finished in 0.48581 seconds (files took 1.76 seconds to load)

generate result

$ awspec generate s3_bucket check-dummy-bucket
/home/ec2-user/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/aws-sdk-core-3.19.0/lib/aws-sdk-core/xml/parser/frame.rb:148:in `child_frame': NotImplementedError (NotImplementedError)

Normal Pattern

S3 lifecycle-configuration

Set Filter Prefix
or
Not set tag and prefix

$ aws s3api get-bucket-lifecycle-configuration --bucket check-dummy-bucket --query 'Rules[]'
[
    {
        "Filter": {
            "Prefix": ""
        },
        "Status": "Enabled",
        "Expiration": {
            "Days": 365
        },
        "ID": "test-lifecycle"
    }
]
$ aws s3api get-bucket-lifecycle-configuration --bucket check-dummy-bucket --query 'Rules[]'
[
    {
        "Filter": {
            "Prefix": "logs/"
        },
        "Status": "Enabled",
        "Expiration": {
            "Days": 365
        },
        "ID": "test-lifecycle"
    }
]

@inokappa inokappa added the bug label Apr 20, 2018
@inokappa inokappa self-assigned this Apr 20, 2018
@inokappa
Copy link
Collaborator

@htnosm

Thanks for reporting this problem.
it’s a bug... 🙇
I'll fix it.

@inokappa
Copy link
Collaborator

inokappa commented Apr 20, 2018

I confirmed NotImplementedError exception in aws-sdk-s3 v1.9.1 (+ aws-sdk-core v1.9.0)... 😱

# OS
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.6
BuildVersion:   15G19009

# Ruby Version
$ ruby --version
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin15]

# Gem List
$ bundle exec gem list

*** LOCAL GEMS ***

aws-partitions (1.80.0)
aws-sdk-core (3.19.0)
aws-sdk-kms (1.5.0)
aws-sdk-s3 (1.9.1)
aws-sigv4 (1.0.2)
bundler (1.16.1)
coderay (1.1.2)
jmespath (1.4.0)
method_source (0.9.0)
pry (0.11.3)

$ bundle exec pry
[1] pry(main)> require 'pp'
=> false
[2] pry(main)> require 'aws-sdk-s3'
=> true
[3] pry(main)> s3 = Aws::S3::Client.new(region: 'ap-northeast-1', profile: 'xxxxxxxxxxxx')
=> #<Aws::S3::Client>
[4] pry(main)> bcl = s3.get_bucket_lifecycle_configuration(bucket: 'oreno-bucket')
NotImplementedError: NotImplementedError

I don’t know what to do...

@inokappa
Copy link
Collaborator

I submitted an issue to aws-sdk-core as follows.

k1LoW added a commit that referenced this issue Apr 22, 2018
(ref #365) Change prefix to filter.prefix
k1LoW pushed a commit that referenced this issue May 20, 2018
k1LoW pushed a commit that referenced this issue May 20, 2018
k1LoW added a commit that referenced this issue May 20, 2018
(ref #365) Change prefix to filter.prefix
@htnosm
Copy link
Collaborator

htnosm commented May 28, 2018

@inokappa
Thank you for support.
I confirmed that it can be executed without error after upgrading SDK.

@inokappa
Copy link
Collaborator

inokappa commented Aug 1, 2018

@oosumi

Thank you for your report.
I will close this issue.

Thank you.

@inokappa inokappa closed this as completed Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants