简体   繁体   中英

Chef 12 + AWS Opsworks + Deploy App from s3

I Needed to setup a deployment process using AWS Opsworks. I have created my stack and added respective layers. I have configured my application and which basically a war archive stored in s3 bucket

When I trigger a deploy event for the app, My recipe is getting executed, but the Problem is i am getting an s3 url. There is no official aws sdk which supports s3 file copy using s3 url.

One way i can split the url and get the bucket key and region from it and can use it with aws sdk. But What is the right way to do it. Is there any other library i can use.

Asking this question to understand what is the right procedure to do it.

Looking at the s3_file cookbook , you can indeed specify a full s3 url:

s3_file "/tmp/somefile" do
    remote_path "/my/s3/key"
    bucket "my-s3-bucket"
    aws_access_key_id "mykeyid"
    aws_secret_access_key "mykey"
    s3_url "https://s3.amazonaws.com/bucket"
    owner "me"
    group "mygroup"
    mode "0644"
    action :create
    decryption_key "my SHA256 digest key"
    decrypted_file_checksum "SHA256 hex digest of decrypted file"
end

AWS maintains a cookbook for integration with its various services. The s3_file resource should be able to accomplish what you need. Here's an example from their readme:

aws_s3_file '/tmp/foo' do
  bucket 'i_haz_an_s3_buckit'
  remote_path 'path/in/s3/bukket/to/foo'
  aws_access_key aws['aws_access_key_id']
  aws_secret_access_key aws['aws_secret_access_key']
  region 'us-west-1'
end

You can include this in your cookbook by adding it as a dependency in your metadata.rb (ensure you have the cookbook downloaded and in your local cookbooks path).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM