A library cookbook for the s3_put
resource, which uploads a file to S3.
- An AWS account
- An S3 bucket
- AWS credentials
s3:PutObject
permissions for what path(s) you want to upload to on the aforementioned S3 bucket
Add a dependency on this cookbook to your cookbook’s metadata or Berksfile.
Then, in your recipe, to upload a file:
s3_put 'path/to/my/file.tar.gz' do
bucket 'my_bucket'
remote_path '/path/on/s3'
access_key_id 'access_key_id'
secret_access_key 'secret_access_key'
action :upload
end
Note that the resultant path will be the remote_path
combined with the filename you are uploading. For this example, that would be #{remote_path}/file.tar.gz
.
The access_key_id
and secret_access_key
are optional; credentials will be picked up per the AWS SDK from a user’s credentials file or an instance role if you do not provide the credentials directly.
Conversely, to delete one:
s3_put 'path/to/my/file.tar.gz' do
bucket 'my_bucket'
remote_path '/path/on/s3'
access_key_id 'access_key_id'
secret_access_key 'secret_access_key'
action :delete
end
Author:: Eric Herot eric.herot@evertrue.com
Author:: Jeff Byrnes thejeffbyrnes@gmail.com