In questo articolo vedremo come configurare una webapp su Amazon Elastic BeanStalk per installare l’applicativo da riga di comando s3cmd, che consente di interagire tramite script bash con Amazon S3.
Il seguente script inserito dentro la directory ebextensions nella root della webapp consente di installare il comando s3cmd, salvando anche il file di configurazione necessario per utilizzarlo. A questo proposito, andranno sostituiti alcuni settaggi, vale a dire amazon.accesskey, amazon.secretkey. Ricordo che gli script di configurazione vanno formattati secondo le regole di YAML
Lo script di configurazione è il seguente:
sources:
/root: http://downloads.sourceforge.net/project/s3tools/s3cmd/1.1.0-beta3/s3cmd-1.1.0-beta3.zip? r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fs3tools%2F%3Fsource%3Ddlp&ts=1357131877&use_mirror=heanet
files:
“/root/s3cmd.config”:
mode: “000600”
owner: root
group: root
content: |
[default]
access_key = @amazon.accesskey@
bucket_location = US
cloudfront_host = cloudfront.amazonaws.com
default_mime_type = binary/octet-stream
delete_removed = False
dry_run = False
enable_multipart = True
encoding = UTF-8
encrypt = False
follow_symlinks = False
force = False
get_continue = False
gpg_command = /usr/bin/gpg
gpg_decrypt = %(gpg_command)s -d –verbose –no-use-agent –batch –yes –passphrase-fd %(passphrase_fd)s -o %(output_file)s % (input_file)s
gpg_encrypt = %(gpg_command)s -c –verbose –no-use-agent –batch –yes –passphrase-fd %(passphrase_fd)s -o %(output_file)s % (input_file)s
gpg_passphrase =
guess_mime_type = True
host_base = s3.amazonaws.com
host_bucket = %(bucket)s.s3.amazonaws.com
human_readable_sizes = False
invalidate_on_cf = False
list_md5 = False
log_target_prefix =
mime_type =
multipart_chunk_size_mb = 15
preserve_attrs = True
progress_meter = True
proxy_host =
proxy_port = 0
recursive = False
recv_chunk = 4096
reduced_redundancy = False
secret_key = @amazon.secretkey@
send_chunk = 4096
simpledb_host = sdb.amazonaws.com
skip_existing = False
socket_timeout = 300
urlencoding_mode = normal
use_https = False
verbosity = WARNING
website_endpoint = http://%(bucket)s.s3-website-%(location)s.amazonaws.com/
website_error =
website_index = index.html
commands:
change_s3cmd_permissions:
command: chmod -R 755 /root/s3cmd-1.1.0-beta3
cwd: /root
Potrete a questo punto usare il comando con una sintassi come la seguente:
/root/s3cmd-1.1.0-beta3/s3cmd –config=/root/s3cmd.config (…)