Skip to content

Commit

Permalink
Merge pull request #109 from Sam-Martin/patch-1
Browse files Browse the repository at this point in the history
Readme MD fix
  • Loading branch information
joekiller committed Dec 18, 2017
2 parents ccf4654 + 0305583 commit 9897266
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
@@ -1,11 +1,11 @@
#DESCRIPTION
# DESCRIPTION
An LWRP that can be used to fetch files from S3.

I created this LWRP to solve the chicken-and-egg problem of fetching files from S3 on the first Chef run on a newly provisioned machine. Ruby libraries that are installed on that first run are not available to Chef during the run, so I couldn't use a library like Fog to get what I needed from S3.

This LWRP has no dependencies beyond the Ruby standard library, so it can be used on the first run of Chef.

#REQUIREMENTS
# REQUIREMENTS
An Amazon Web Services account and something in S3 to fetch.

Multi-part S3 uploads do not put the MD5 of the content in the ETag header. If x-amz-meta-digest is provided in User-Defined Metadata on the S3 Object it is processed as if it were a Digest header (RFC 3230).
Expand All @@ -16,7 +16,7 @@ By default, a catalog file in Chef's cache path will be kept for all downloaded

If credentials are not provided, s3_file will attempt to use the first instance profile associated with the instance. See documentation at http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html for more on instance profiles.

#USAGE
# USAGE
s3_file acts like other file resources. The only supported action is :create, which is the default.

Attribute Parameters:
Expand Down Expand Up @@ -49,14 +49,14 @@ Example:
decrypted_file_checksum "SHA256 hex digest of decrypted file"
end

#MD5 and Multi-Part Upload
# MD5 and Multi-Part Upload
s3_file compares the MD5 hash of a local file, if present, and the ETag header of the S3 object. If they do not match, then the remote object will be downloaded and notifiations will be fired.

In most cases, the ETag of an S3 object will be identical to its MD5 hash. However, if the file was uploaded to S3 via multi-part upload, then the ETag will be set to the MD5 hash of the first uploaded part. In these cases, MD5 of the local file and remote object will never match.

To work around this issue, set an X-Amz-Meta-Digest tag on your S3 object with value set to `md5=MD5 of the entire object`. s3_file will then use that value in place of the ETag value, and will skip downloading in case the MD5 of the local file matches the value of the X-Amz-Meta-Digest header.

#USING ENCRYPTED S3 FILES
# USING ENCRYPTED S3 FILES
s3_file can decrypt files that have been encrypted using an AES-256-CBC cipher. To use the decryption part of the resource, you must provide a decryption_key which can be generated by following the instructions below. You can also include an optional decrypted_file_checksum which allows Chef to check to see if it needs to redownload the encrypted file. Note that this checksum is different from the one in S3 because the file you compare to is already decrypted so a SHA256 checksum is used instead of the MD5. Instructions to generate the decrypted_file_checksum are below as well.

To use s3_file with encrypted files:
Expand All @@ -77,7 +77,7 @@ Try `bin/s3_crypto -g > my_new_key`.

You can use the utility `bin/s3_crypto` to encrypt files prior to uploading to S3 and to decrypt files prior to make sure the encryption is working.

#ChefSpec matcher
# ChefSpec matcher
s3_file comes with a matcher to use in [ChefSpec](https://github.com/sethvargo/chefspec).

This spec checks the code from the USAGE example above:
Expand All @@ -87,7 +87,7 @@ This spec checks the code from the USAGE example above:
.with(bucket: "my-s3-bucket", remote_path: "/my/s3/key")
end

#Testing
# Testing

This cookbook has Test Kitchen integration tests. To test, create a .s3.yml file with the following S3 details.

Expand Down

0 comments on commit 9897266

Please sign in to comment.