Cheruiyot Felix
Cheruiyot Felix

Reputation: 1597

How to provision an EC2 Server programmatically and configure default settings

I would like to provision an AWS EC2 server using python and set default user and password among other things. The idea is that the developer selects from our site menu the items they would like to have installed e.g MySQL, Nginx etc. When one clicks submit, I'm using boto to create the EC2 server and now I would like to install the softwares and set the default user credentials so that it can be mailed to the user.

I would like to make the above self service i.e everything is well automated and one can customize as per the needs without system engineer involvement. Note: I don't want to share the aws keypairs, that will be left for the servers admin.

I'm thinking of using fabric on the above but it seems it will require a lot of code and configuration. Is there the best and recommended way one can provision a linux server and do the above? How does providers like digitalOceans set default root passwords during create? I would like to keep this details unique as possible.

Upvotes: 0

Views: 637

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269666

Use the User Data field to pass a #cloud-config setup to the Amazon EC2 instance. Some of the things it can do include:

  • Including users and groups, including defining user passwords
  • Writing out arbitrary files
  • Add yum / apt repository
  • Install via chef / puppet
  • Run commands on first boot
  • Install arbitrary packages

See: Cloud config examples

Upvotes: 1

Related Questions