This week I will talk about Amazon Web Service Elastic Beanstalk, a PAAS solution with lots of supported languages and platforms. If you have little knowledge about infrastructure,network etc stuff and only want to work on your code, Elastic Beanstalk is the solution for you. By using Elastic Beanstalk, you upload your code to AWS and AWS do the rest for you including scalability, security and connectivity.
With Elastic Beanstalk , first you create an application. This application includes environments (like dev,test,prod), application versions (all of your code versions which are kept on Amazon S3) and environments configurations (resources for your infrastructure, settings etc). For the environments, you can select either web tier (process web requests) or worker tier (runs background jobs). It is better to check the Elastic Beanstalk architectural overview in the documentation.
Today I will create a basic application and then talk about managing Elastic Beanstalk applications.
Os in the Elastic Beanstalk dashboard, We have two options. First we can directly launch the application, or we can create a new application.
I select “Create New Application” and proceed. Here we should select our tier, web or worker. I select web tier and continue.
Now we need an IAM role that Elastic Beanstalk will use to access other AWS services like S3, Cloudwatch. If you don’t have any , Elastic Beanstalk will create it for you (as default). I select my previously created role and continue.
Elastic Beanstalk supports different platforms as Java, PHP, Python, Node.js etc. In my example I select Python, the latest python and Amazon Linux version and “Single instance” as environment type (We can also use load balancing here, I’ll talk about it in management).
As application, we can use sample application, upload our files as zip or war file format or we can deploy it from a S3 bucket. If you want to upload your code, there are some limitations that you should check here. I select the sample application and proceed. (I’ll deploy my own code with Elastic Beanstalk cli later)
I give “wekanbanDjangoApp-dev” as my environment name and url. The url must be unique and you have to check your url availability before you proceed.
If you need additional resources ( rds and vpc ), you can configure here. Elastic beanstalk can create the RDS instance for you, but you can manually create it. I select creating environment in VPC and proceed.
Here, we configure our instance settings. I select my instance type as t2.micro. If you need to connect to your instance(s), you can select your key pair. You can also select your volume type and size then proceed.
I specify my tags and proceed.
I’ve selected the environment to be created in vpc. Here I select my subnets and the security group for my environment.
After I review my settings, I continue and the environment is being launched. A you see health is gray , since environment is being launched.
Environment is launched and now in Green state. We can click the environment url and browse our application.
Our sample application is ready.
Now let’s talk about the management and configuration of our environment.
In dashboard screen we can see the status of our applications. As you see I have only one application with a web tier, running the sample application version. I can see the last modification time and the url of it.
If you click the Wekanban-django-app link, you will see the environments, application versions and saved configurations.
I have only one application versions. Here I can deploy my previous versions, upload a new source bundle or delete a version.
Currently I have no saved configuration. Configurations are the settings for your resources. You can save your configurations settings and load them anytime.
Now let’s save our configuration settings. I select “Save configuration” from the actions menu in my environment dashboard.
I give a name and save.
Now our config is saved. It is located in our Elastic Beanstalk bucket in the resources/templates/Wekanban-Django-app folder as Demo-config-sample-app file. Let’s open it and see what is saved.
EnvironmentConfigurationMetadata: DateModified: '1438158639000' DateCreated: '1438158639000' Tags: AWS: Rocks AWSConfigurationTemplateVersion: 184.108.40.206 EnvironmentTier: Name: WebServer Type: Standard SolutionStack: 64bit Amazon Linux 2015.03 v1.4.3 running Python 3.4 OptionSettings: aws:ec2:vpc: VPCId: vpc-89ea05e0 AssociatePublicIpAddress: true Subnets: subnet-b11401c9,subnet-bf3ad0d6 aws:autoscaling:launchconfiguration: IamInstanceProfile: aws-elasticbeanstalk-ec2-role SecurityGroups: sg-a855bcc1 EC2KeyName: '' InstanceType: t2.micro aws:elasticbeanstalk:environment: EnvironmentType: SingleInstance aws:elasticbeanstalk:sns:topics: Notification Endpoint: ''
As you see all the environment settings are kept in this file. I can create another environment with the same configuration settings.
Again I do the same steps, but for the environment type, I select “Start from saved configuration”.
So this was the simple introduction of Elastic Beanstalk. I will continue to explain the remaining parts (configuration, logs, monitoring, alarms, events) in the part2.If you have any question or comment, please feel free to write and don’t forget to share please.