I am deploying a PHP application to ElasticBeanstalk. First, I am deploying a sample PHP application.
This is my template.
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'AWS CloudFormation Sample Template ElasticBeanstalk_PHP_Sample: Configure
and launch the AWS Elastic Beanstalk PHP sample application. **WARNING** This template
creates one or more Amazon EC2 instances. You will be billed for the AWS resources
used if you create a stack from this template.'
Parameters:
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the AWS Elastic
Beanstalk instance
Type: String
MinLength: '1'
MaxLength: '255'
AllowedPattern: "[\\x20-\\x7E]*"
ConstraintDescription: can contain only ASCII characters.
Resources:
webApplication:
Type: AWS::ElasticBeanstalk::Application
Properties:
Description: AWS Elastic Beanstalk PHP Sample Application
ApplicationVersions:
- VersionLabel: Initial Version
Description: Version 1.0
SourceBundle:
S3Bucket:
Fn::Join:
- "-"
- - elasticbeanstalk-samples
- Ref: AWS::Region
S3Key: php-sample.zip
ConfigurationTemplates:
- TemplateName: DefaultConfiguration
Description: Default Configuration Version 1.0 - with SSH access
SolutionStackName: 64bit Amazon Linux 2 v3.0.3 running PHP 7.3
OptionSettings:
- Namespace: aws:autoscaling:launchconfiguration
OptionName: EC2KeyName
Value:
Ref: KeyName
testEnvironment:
Type: AWS::ElasticBeanstalk::Environment
Properties:
ApplicationName:
Ref: webApplication
Description: AWS Elastic Beanstalk Environment running PHP Sample Application
TemplateName: DefaultConfiguration
VersionLabel: Initial Version
Outputs:
URL:
Description: URL of the AWS Elastic Beanstalk Environment
Value:
Fn::Join:
- ''
- - http://
- Fn::GetAtt:
- testEnvironment
- EndpointURL
When I deploy executing the command in the terminal, it is failing. This is the logs.
{
"StackEvents": [
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "cb6d7aa0-cdf6-11ea-b52a-0af573e17780",
"ResourceStatus": "ROLLBACK_COMPLETE",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": "2020-07-24T21:44:04.668Z",
"StackName": "CloudFormationLaravelBeanstalk",
"PhysicalResourceId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"LogicalResourceId": "CloudFormationLaravelBeanstalk"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "webApplication-DELETE_COMPLETE-2020-07-24T21:44:04.000Z",
"ResourceStatus": "DELETE_COMPLETE",
"ResourceType": "AWS::ElasticBeanstalk::Application",
"Timestamp": "2020-07-24T21:44:04Z",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"Description\":\"AWS Elastic Beanstalk PHP Sample Application\",\"ApplicationVersions\":[{\"Description\":\"Version 1.0\",\"VersionLabel\":\"Initial Version\",\"SourceBundle\":{\"S3Bucket\":\"elasticbeanstalk-samples-eu-west-1\",\"S3Key\":\"php-sample.zip\"}}],\"ConfigurationTemplates\":[{\"Description\":\"Default Configuration Version 1.0 - with SSH access\",\"OptionSettings\":[{\"Value\":\"MyanEat\",\"Namespace\":\"aws:autoscaling:launchconfiguration\",\"OptionName\":\"EC2KeyName\"}],\"TemplateName\":\"DefaultConfiguration\",\"SolutionStackName\":\"64bit Amazon Linux 2 v3.0.3 running PHP 7.3\"}]}",
"PhysicalResourceId": "CloudFormationLaravelBeanstalk-webApplication-197H2GUL24WJ7",
"LogicalResourceId": "webApplication"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "webApplication-DELETE_IN_PROGRESS-2020-07-24T21:43:33.166Z",
"ResourceStatus": "DELETE_IN_PROGRESS",
"ResourceType": "AWS::ElasticBeanstalk::Application",
"Timestamp": "2020-07-24T21:43:33.166Z",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"Description\":\"AWS Elastic Beanstalk PHP Sample Application\",\"ApplicationVersions\":[{\"Description\":\"Version 1.0\",\"VersionLabel\":\"Initial Version\",\"SourceBundle\":{\"S3Bucket\":\"elasticbeanstalk-samples-eu-west-1\",\"S3Key\":\"php-sample.zip\"}}],\"ConfigurationTemplates\":[{\"Description\":\"Default Configuration Version 1.0 - with SSH access\",\"OptionSettings\":[{\"Value\":\"MyanEat\",\"Namespace\":\"aws:autoscaling:launchconfiguration\",\"OptionName\":\"EC2KeyName\"}],\"TemplateName\":\"DefaultConfiguration\",\"SolutionStackName\":\"64bit Amazon Linux 2 v3.0.3 running PHP 7.3\"}]}",
"PhysicalResourceId": "CloudFormationLaravelBeanstalk-webApplication-197H2GUL24WJ7",
"LogicalResourceId": "webApplication"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "testEnvironment-DELETE_COMPLETE-2020-07-24T21:43:32.486Z",
"ResourceStatus": "DELETE_COMPLETE",
"ResourceType": "AWS::ElasticBeanstalk::Environment",
"Timestamp": "2020-07-24T21:43:32.486Z",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"ApplicationName\":\"CloudFormationLaravelBeanstalk-webApplication-197H2GUL24WJ7\",\"Description\":\"AWS Elastic Beanstalk Environment running PHP Sample Application\",\"VersionLabel\":\"Initial Version\",\"TemplateName\":\"DefaultConfiguration\"}",
"PhysicalResourceId": "Clou-test-2HSOCMRY8B2",
"LogicalResourceId": "testEnvironment"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "testEnvironment-DELETE_IN_PROGRESS-2020-07-24T21:43:31.824Z",
"ResourceStatus": "DELETE_IN_PROGRESS",
"ResourceType": "AWS::ElasticBeanstalk::Environment",
"Timestamp": "2020-07-24T21:43:31.824Z",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"ApplicationName\":\"CloudFormationLaravelBeanstalk-webApplication-197H2GUL24WJ7\",\"Description\":\"AWS Elastic Beanstalk Environment running PHP Sample Application\",\"VersionLabel\":\"Initial Version\",\"TemplateName\":\"DefaultConfiguration\"}",
"PhysicalResourceId": "Clou-test-2HSOCMRY8B2",
"LogicalResourceId": "testEnvironment"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "b5e05bd0-cdf6-11ea-80b1-062b1cfafef6",
"ResourceStatus": "ROLLBACK_IN_PROGRESS",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": "2020-07-24T21:43:28.511Z",
"ResourceStatusReason": "The following resource(s) failed to create: [testEnvironment]. . Rollback requested by user.",
"StackName": "CloudFormationLaravelBeanstalk",
"PhysicalResourceId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"LogicalResourceId": "CloudFormationLaravelBeanstalk"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "testEnvironment-CREATE_FAILED-2020-07-24T21:43:27.905Z",
"ResourceStatus": "CREATE_FAILED",
"ResourceType": "AWS::ElasticBeanstalk::Environment",
"Timestamp": "2020-07-24T21:43:27.905Z",
"ResourceStatusReason": "Environment failed to launch as it entered Terminated state",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"ApplicationName\":\"CloudFormationLaravelBeanstalk-webApplication-197H2GUL24WJ7\",\"Description\":\"AWS Elastic Beanstalk Environment running PHP Sample Application\",\"VersionLabel\":\"Initial Version\",\"TemplateName\":\"DefaultConfiguration\"}",
"PhysicalResourceId": "Clou-test-2HSOCMRY8B2",
"LogicalResourceId": "testEnvironment"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "testEnvironment-CREATE_IN_PROGRESS-2020-07-24T21:42:57.297Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::ElasticBeanstalk::Environment",
"Timestamp": "2020-07-24T21:42:57.297Z",
"ResourceStatusReason": "Resource creation Initiated",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"ApplicationName\":\"CloudFormationLaravelBeanstalk-webApplication-197H2GUL24WJ7\",\"Description\":\"AWS Elastic Beanstalk Environment running PHP Sample Application\",\"VersionLabel\":\"Initial Version\",\"TemplateName\":\"DefaultConfiguration\"}",
"PhysicalResourceId": "Clou-test-2HSOCMRY8B2",
"LogicalResourceId": "testEnvironment"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "testEnvironment-CREATE_IN_PROGRESS-2020-07-24T21:42:55.237Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::ElasticBeanstalk::Environment",
"Timestamp": "2020-07-24T21:42:55.237Z",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"ApplicationName\":\"CloudFormationLaravelBeanstalk-webApplication-197H2GUL24WJ7\",\"Description\":\"AWS Elastic Beanstalk Environment running PHP Sample Application\",\"VersionLabel\":\"Initial Version\",\"TemplateName\":\"DefaultConfiguration\"}",
"PhysicalResourceId": "",
"LogicalResourceId": "testEnvironment"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "webApplication-CREATE_COMPLETE-2020-07-24T21:42:53.537Z",
"ResourceStatus": "CREATE_COMPLETE",
"ResourceType": "AWS::ElasticBeanstalk::Application",
"Timestamp": "2020-07-24T21:42:53.537Z",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"Description\":\"AWS Elastic Beanstalk PHP Sample Application\",\"ApplicationVersions\":[{\"Description\":\"Version 1.0\",\"VersionLabel\":\"Initial Version\",\"SourceBundle\":{\"S3Bucket\":\"elasticbeanstalk-samples-eu-west-1\",\"S3Key\":\"php-sample.zip\"}}],\"ConfigurationTemplates\":[{\"Description\":\"Default Configuration Version 1.0 - with SSH access\",\"OptionSettings\":[{\"Value\":\"MyanEat\",\"Namespace\":\"aws:autoscaling:launchconfiguration\",\"OptionName\":\"EC2KeyName\"}],\"TemplateName\":\"DefaultConfiguration\",\"SolutionStackName\":\"64bit Amazon Linux 2 v3.0.3 running PHP 7.3\"}]}",
"PhysicalResourceId": "CloudFormationLaravelBeanstalk-webApplication-197H2GUL24WJ7",
"LogicalResourceId": "webApplication"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "webApplication-CREATE_IN_PROGRESS-2020-07-24T21:42:51.643Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::ElasticBeanstalk::Application",
"Timestamp": "2020-07-24T21:42:51.643Z",
"ResourceStatusReason": "Resource creation Initiated",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"Description\":\"AWS Elastic Beanstalk PHP Sample Application\",\"ApplicationVersions\":[{\"Description\":\"Version 1.0\",\"VersionLabel\":\"Initial Version\",\"SourceBundle\":{\"S3Bucket\":\"elasticbeanstalk-samples-eu-west-1\",\"S3Key\":\"php-sample.zip\"}}],\"ConfigurationTemplates\":[{\"Description\":\"Default Configuration Version 1.0 - with SSH access\",\"OptionSettings\":[{\"Value\":\"MyanEat\",\"Namespace\":\"aws:autoscaling:launchconfiguration\",\"OptionName\":\"EC2KeyName\"}],\"TemplateName\":\"DefaultConfiguration\",\"SolutionStackName\":\"64bit Amazon Linux 2 v3.0.3 running PHP 7.3\"}]}",
"PhysicalResourceId": "CloudFormationLaravelBeanstalk-webApplication-197H2GUL24WJ7",
"LogicalResourceId": "webApplication"
},
{
"StackId": "arn:aws:cloudformation:eu-west-1:733553390213:stack/CloudFormationLaravelBeanstalk/9a32a280-cdf6-11ea-8a9a-0aa806e28382",
"EventId": "webApplication-CREATE_IN_PROGRESS-2020-07-24T21:42:51.125Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::ElasticBeanstalk::Application",
"Timestamp": "2020-07-24T21:42:51.125Z",
"StackName": "CloudFormationLaravelBeanstalk",
"ResourceProperties": "{\"Description\":\"AWS Elastic Beanstalk PHP Sample Application\",\"ApplicationVersions\":[{\"Description\":\"Version 1.0\",\"VersionLabel\":\"Initial Version\",\"SourceBundle\":{\"S3Bucket\":\"elasticbeanstalk-samples-eu-west-1\",\"S3Key\":\"php-sample.zip\"}}],\"ConfigurationTemplates\":[{\"Description\":\"Default Configuration Version 1.0 - with SSH access\",\"OptionSettings\":[{\"Value\":\"MyanEat\",\"Namespace\":\"aws:autoscaling:launchconfiguration\",\"OptionName\":\"EC2KeyName\"}],\"TemplateName\":\"DefaultConfiguration\",\"SolutionStackName\":\"64bit Amazon Linux 2 v3.0.3 running PHP 7.3\"}]}",
"PhysicalResourceId": "",
"LogicalResourceId": "webApplication"
},
{
What is wrong with my code and how can I fix it?
I tried to verify the issue and deploy your template on my sandbox account.
I found that the deployment fails due to missing instance profile inConfigurationTemplates
:
- Namespace: aws:autoscaling:launchconfiguration
OptionName: IamInstanceProfile
Value: !Ref MyInstanceProfile
Thus you have to create AWS::IAM::InstanceProfile with IAM role that your EB instances will have. In basic form you could do:
MyInstanceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- sts:AssumeRole
Description: Beanstalk EC2 role
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AWSElasticBeanstalkWebTier
- arn:aws:iam::aws:policy/AWSElasticBeanstalkMulticontainerDocker
- arn:aws:iam::aws:policy/AWSElasticBeanstalkWorkerTier
MyInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref MyInstanceRole
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.