开发者

How to move files from S3 bucket to EC2 on creation of instance

I am creating Flash Media Servers using an AMI that Adobe provides. I need to load some config.xml files into particular directories of the server so that when FMS starts up it will have the security configs that I want and a few other things that I want to do.

I have a basic understanding that you can pass user-data in the form of a bash file to an instance. Would that be the best option?

Could someone provide me with a good example as to what a bash file would look like if I would like to copy an xml file from S3 into a开发者_运维知识库 DIR on the FMS / CentOS instance?


A couple options come to mind, and I'm certainly no expert. I'm fairly new to these but have been trying things out just to get up to speed.

  1. Amazon EBS (Elastic Block Store) - it's a persistent block storage (like a mountable drive) that you can attach to EC2 instances.
  2. chef from Opscode - it's probably overkill if you have a simple setup, but there are some nifty "recipes" for automated setup+config of EC2 instances. I've really only played with this one a bit, having gone through a few of their samples just to see what it's capable of.

The advantages of these setups is that you don't need to modify your own AMI instances whenever you change you application/config. Although if you're always fetching your app from S3 that sortof already solves this problem.

If all you need is a simple shell script for fetching a file from AWS, you could use the unix tools wget or curl.

#!/bin/bash
cd /some/destination/path/
curl -v --header 'Date: Fri, 27 May 2011 14:17:00 -0500' \
        --header 'Authorization: AWS AWSAccessKeyId:Signature' \
        "https://s3.amazonaws.com/your-s3-bucket/path/to/file.xml"

It would be a heckuvalot easier if the file is public, since generating the Signature for the authorization is not trivial to do.

There is a suite of command-line tools called s3-bash but it would still need your secret access key for authorization...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜