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

Feature aws s3 #968

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Feature aws s3 #968

wants to merge 14 commits into from

Conversation

kaffein
Copy link
Member

@kaffein kaffein commented Oct 10, 2019

hey guys,

I just wanted to let you know that I have (at last) made some progress on the aws s3 command. Sorry for the little delay, I have been on another planet lately :).

I have made a minor modification to the early aws-invoke function for calling aws service APIs by adding an aws-client parameter. This parameter should allow any aws service clients (iam, s3 etc.) to be plugged in and should ease any upcoming integration.

At the moment, it covers (almost) all the features we had in the previous version of the s3 command. This is still a work in progress as I intend to add some (of the most useful) commands to it but feel free to let me know if there is anything that you would like me to put in.

I will keep you in the loop ;-)
thanks in advance

@kaffein kaffein requested a review from devth October 10, 2019 21:52
Copy link
Member

@devth devth left a comment

Choose a reason for hiding this comment

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

Awesome! Glad to see a PR from you @kaffein 😃welcome back. Left a few thoughts.

"aws s3 mb s3://<bucket-name> # Creates a new s3 bucket"
{:yb/cat #{:util :info}}
[{[_ bucket-name] :match}]
(-> (aws/s3-create-bucket bucket-name {:LocationConstraint "eu-west-1"})
Copy link
Member

Choose a reason for hiding this comment

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

Can we make Availability Zones configurable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I will include it in the configuration 👍

src/yetibot/commands/aws/formatters.clj Show resolved Hide resolved
(defmethod format-s3-response ::S3BucketListed
[{:keys [Buckets]}]
{:result/data {:buckets Buckets}
Copy link
Member

Choose a reason for hiding this comment

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

Same - more data?

Copy link
Member Author

Choose a reason for hiding this comment

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

For the bucket list, we have more infos related to the buckets. I will paste the response format here and we will decide which data we will include in the formatted response.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have the following spec for the :ListBuckets API call :

:ListBuckets {:name "ListBuckets",
               :documentation "<p>Returns a list of all buckets owned by the authenticated sender of the request.</p>",
               :documentationUrl "http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTServiceGET.html",
               :request nil,
               :required nil,
               :response {:Buckets [:seq-of {:Name string, :CreationDate timestamp}],
                          :Owner {:DisplayName string, :ID string}}},

Apart from the Buckets list, we have an additional :Owner field included.
Do you want it to be included within the response @devth ?

Copy link
Member

Choose a reason for hiding this comment

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

Sure. Can't hurt to have extra data behind the pipe :)

(defmethod format-s3-response ::S3ObjectsListed
[{:keys [Contents]}]
{:result/data {:contents Contents}
Copy link
Member

Choose a reason for hiding this comment

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

Same - more data?

Copy link
Member Author

Choose a reason for hiding this comment

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

Same for the objects listing, we have more infos returned by the API. I will paste the format here later and we will decide which infos we will keep in the formatted response.

Copy link
Member Author

Choose a reason for hiding this comment

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

for the :ListObjectsV2 API call, we have the following spec :

:ListObjectsV2 {:name "ListObjectsV2",
                 :documentation "<p>Returns some or all (up to 1000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket. Note: ListObjectsV2 is the revised List Objects API and we recommend you use this revised API for new application development.</p>",
                 :request {:Prefix string,
                           :StartAfter string,
                           :Bucket string,
                           :EncodingType string,
                           :Delimiter string,
                           :FetchOwner boolean,
                           :RequestPayer string,
                           :ContinuationToken string,
                           :MaxKeys integer},
                 :required [:Bucket],
                 :response {:Prefix string,
                            :StartAfter string,
                            :EncodingType string,
                            :Delimiter string,
                            :NextContinuationToken string,
                            :CommonPrefixes [:seq-of {:Prefix string}],
                            :ContinuationToken string,
                            :Contents [:seq-of
                                       {:Key string,
                                        :LastModified timestamp,
                                        :ETag string,
                                        :Size integer,
                                        :StorageClass string,
                                        :Owner {:DisplayName string, :ID string}}],
                            :MaxKeys integer,
                            :IsTruncated boolean,
                            :Name string,
                            :KeyCount integer}},

I only took the :Contents but the :response key is assoc-ed to much more information, mostly meta-data such as pagination-related stuff (I will also have to think about how to manage it too by the way ^^).
Which other keys do you think we should include in the response for this one ?

Copy link
Member

Choose a reason for hiding this comment

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

I think everything. I'm aiming to make data behind pipes super powerful. I'd prob only omit something if it was massive, unrelated, or a security issue.

@kaffein
Copy link
Member Author

kaffein commented Oct 11, 2019

Awesome! Glad to see a PR from you @kaffein welcome back. Left a few thoughts.

thanks a lot @devth :) ... and thanks for the feedback!! I will check them out

@kaffein
Copy link
Member Author

kaffein commented Mar 31, 2020

hey guys,

Sorry for the delay on this PR, I was a little bit busy the last few months ^^ but I think we are ready this time.

So this PR emulates a few aws s3 CLI commands :

  • bucket creation
  • bucket listing
  • bucket content listing
  • object copying
  • object deletion
  • (empty) bucket deletion

There were a few interesting commands in the official aws CLI that were not available through the API though, for e.g : renaming/moving (mv) objects, or sync-ing buckets content (à la rsync). Especially for the renaming/moving objects, I wonder if it is possible to have a combination of copy and delete (in an atomic operation) to emulate it.

I can make another round of testing to make sure we do not have regressions and I will include the screenshots here if you want @devth. It will probably ease your job but of course feel free to play with the PR to see if there are things that need to be fixed.

thanks in advance

@kaffein kaffein marked this pull request as ready for review March 31, 2020 22:02
@kaffein
Copy link
Member Author

kaffein commented Apr 2, 2020

Yo,

just to give a quick update on the last round of tests for the aws s3 feature. I have included some screenshots so that we can have an idea of how it looks like. The whole thing can probably be improved so feel free to suggest anything that can help us make it better ;-).

  • bucket creation

s3_mb

  • bucket creation with an already existing bucket name

s3_mb_same_name_bucket_failure

  • bucket listing

s3_ls

  • bucket content listing

s3_ls_bucket

  • Non existent bucket content listing

s3_ls_non_existent_bucket

  • object copying

s3_cp_success

  • invalid object copying attempt

s3_cp_failure_invalid_source_uri

  • object deletion

s3_rm_success

  • (empty-only) bucket deletion

s3_rb_workflow

can you PTAL @devth

thanks in advance ^^

@devth
Copy link
Member

devth commented Apr 2, 2020

@kaffein looks awesome! I will try to find some time to review this tomorrow if that's ok.

@kaffein
Copy link
Member Author

kaffein commented Apr 3, 2020

Take your time ... we're not in a hurry 😉😊

Thanks 🙏

@kaffein kaffein force-pushed the feature-aws-s3 branch 3 times, most recently from 6443e0e to 66b9b2a Compare April 7, 2020 14:24
@devth devth self-requested a review April 13, 2020 17:33
@devth
Copy link
Member

devth commented Apr 13, 2020

Playing with this now!

@kaffein
Copy link
Member Author

kaffein commented Apr 13, 2020

Enjoy and take your time!! it's a big chunk haha

Copy link
Member

@devth devth left a comment

Choose a reason for hiding this comment

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

This is awesome! I setup an AWS account and played with it. I didn't test every command yet. Found a couple things and left some comments.

Thanks! ☁️ ☁️ ☁️

src/yetibot/api/aws.clj Show resolved Hide resolved
src/yetibot/api/aws.clj Show resolved Hide resolved
src/yetibot/commands/aws.clj Show resolved Hide resolved
src/yetibot/commands/aws.clj Show resolved Hide resolved
@kaffein kaffein requested a review from devth April 19, 2020 15:21
@kaffein kaffein force-pushed the feature-aws-s3 branch 2 times, most recently from 8a770e3 to 9ab4e07 Compare April 24, 2020 19:18
@kaffein
Copy link
Member Author

kaffein commented Oct 28, 2020

I might want to refactor the whole aws suite of commands : there are probably some possibilities to generate all the needed functions from the ops (operations) made available by each aws client.

@devth
Copy link
Member

devth commented Oct 29, 2020

@kaffein code gen sounds cool and makes sense for such a large set of commands.

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.

None yet

2 participants