Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

Elastic Beanstalk Template Snippets

With Elastic Beanstalk, you can quickly deploy and manage applications in AWS without worrying about the infrastructure that runs those applications. The following sample template can help you describe Elastic Beanstalk resources in your AWS CloudFormation template.

Elastic Beanstalk Sample PHP

The following sample template deploys a sample PHP web application that is stored in an Amazon S3 bucket. The Elastic Beanstalk environment is 64-bit Amazon Linux running PHP 5.3. The environment is also an autoscaling, load-balancing environment, with a minimum of two Amazon EC2 instances and a maximum of six.

JSON

Copy
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "sampleApplication": { "Type": "AWS::ElasticBeanstalk::Application", "Properties": { "Description": "AWS Elastic Beanstalk Sample Application" } }, "sampleApplicationVersion": { "Type": "AWS::ElasticBeanstalk::ApplicationVersion", "Properties": { "ApplicationName": { "Ref": "sampleApplication" }, "Description": "AWS ElasticBeanstalk Sample Application Version", "SourceBundle": { "S3Bucket": { "Fn::Join": [ "-", [ "elasticbeanstalk-samples", { "Ref": "AWS::Region" } ] ] }, "S3Key": "php-sample.zip" } } }, "sampleConfigurationTemplate": { "Type": "AWS::ElasticBeanstalk::ConfigurationTemplate", "Properties": { "ApplicationName": { "Ref": "sampleApplication" }, "Description": "AWS ElasticBeanstalk Sample Configuration Template", "OptionSettings": [ { "Namespace": "aws:autoscaling:asg", "OptionName": "MinSize", "Value": "2" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "MaxSize", "Value": "6" }, { "Namespace": "aws:elasticbeanstalk:environment", "OptionName": "EnvironmentType", "Value": "LoadBalanced" } ], "SolutionStackName": "64bit Amazon Linux running PHP 5.3" } }, "sampleEnvironment": { "Type": "AWS::ElasticBeanstalk::Environment", "Properties": { "ApplicationName": { "Ref": "sampleApplication" }, "Description": "AWS ElasticBeanstalk Sample Environment", "TemplateName": { "Ref": "sampleConfigurationTemplate" }, "VersionLabel": { "Ref": "sampleApplicationVersion" } } } } }

YAML

Copy
AWSTemplateFormatVersion: '2010-09-09' Resources: sampleApplication: Type: AWS::ElasticBeanstalk::Application Properties: Description: AWS Elastic Beanstalk Sample Application sampleApplicationVersion: Type: AWS::ElasticBeanstalk::ApplicationVersion Properties: ApplicationName: Ref: sampleApplication Description: AWS ElasticBeanstalk Sample Application Version SourceBundle: S3Bucket: !Sub "elasticbeanstalk-samples-${AWS::Region}" S3Key: php-sample.zip sampleConfigurationTemplate: Type: AWS::ElasticBeanstalk::ConfigurationTemplate Properties: ApplicationName: Ref: sampleApplication Description: AWS ElasticBeanstalk Sample Configuration Template OptionSettings: - Namespace: aws:autoscaling:asg OptionName: MinSize Value: '2' - Namespace: aws:autoscaling:asg OptionName: MaxSize Value: '6' - Namespace: aws:elasticbeanstalk:environment OptionName: EnvironmentType Value: LoadBalanced SolutionStackName: 64bit Amazon Linux running PHP 5.3 sampleEnvironment: Type: AWS::ElasticBeanstalk::Environment Properties: ApplicationName: Ref: sampleApplication Description: AWS ElasticBeanstalk Sample Environment TemplateName: Ref: sampleConfigurationTemplate VersionLabel: Ref: sampleApplicationVersion