gpt4 book ai didi

amazon-web-services - AWS CloudFormation + Elastic Beanstalk 错误

转载 作者:行者123 更新时间:2023-12-03 07:40:37 25 4
gpt4 key购买 nike

我是 AWS CloudFormation 和 Elastic Beanstalk 的新手。我能够在 Elastic Beanstalk 上成功部署 Java(Spring Boot)应用程序,但是当我尝试通过 CloudFormation 进行部署时,尽管我通过 root 帐户运行它,但它不起作用。这是一个简单的CloudFormation脚本,大部分取自官方页面herehere :

Cloudformation Error:The following resource(s) failed to create: [MyInstanceProfile, sampleEnvironment]. Rollback requested by user.

CloudFormation Json 文件:

{
"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": [ "-", [ "bucket-elasticbeanstalk", { "Ref": "AWS::Region" } ] ] },
"S3Key": "helloworld-0.0.1-SNAPSHOT.jar"
}
}
},
"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 2 v3.2.5 running Corretto 11"
}
},
"sampleEnvironment": {
"Type": "AWS::ElasticBeanstalk::Environment",
"Properties": {
"ApplicationName": { "Ref": "sampleApplication" },
"Description": "AWS ElasticBeanstalk Sample Environment",
"TemplateName": { "Ref": "sampleConfigurationTemplate" },
"VersionLabel": { "Ref": "sampleApplicationVersion" }
}
},
"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"
}
]
}
}
}
}

完整事件:

2021-10-06 09:27:05 UTC+0530    main-cf-sb2-2   ROLLBACK_COMPLETE   -
2021-10-06 09:27:04 UTC+0530 sampleApplication DELETE_COMPLETE -
2021-10-06 09:26:33 UTC+0530 MyInstanceRole DELETE_COMPLETE -
2021-10-06 09:26:33 UTC+0530 sampleApplication DELETE_IN_PROGRESS -
2021-10-06 09:26:33 UTC+0530 sampleConfigurationTemplate DELETE_COMPLETE -
2021-10-06 09:26:33 UTC+0530 sampleApplicationVersion DELETE_COMPLETE -
2021-10-06 09:26:32 UTC+0530 sampleConfigurationTemplate DELETE_IN_PROGRESS -
2021-10-06 09:26:32 UTC+0530 sampleApplicationVersion DELETE_IN_PROGRESS -
2021-10-06 09:26:32 UTC+0530 MyInstanceRole DELETE_IN_PROGRESS -
2021-10-06 09:26:32 UTC+0530 MyInstanceProfile DELETE_COMPLETE -
2021-10-06 09:26:32 UTC+0530 sampleEnvironment DELETE_COMPLETE -
2021-10-06 09:26:31 UTC+0530 MyInstanceProfile DELETE_IN_PROGRESS -
2021-10-06 09:26:31 UTC+0530 sampleEnvironment DELETE_IN_PROGRESS -
2021-10-06 09:26:28 UTC+0530 main-cf-sb2-2 ROLLBACK_IN_PROGRESS The following resource(s) failed to create: [MyInstanceProfile, sampleEnvironment]. Rollback requested by user.
2021-10-06 09:26:27 UTC+0530 MyInstanceProfile CREATE_FAILED Resource creation cancelled
2021-10-06 09:26:27 UTC+0530 sampleEnvironment CREATE_FAILED Environment failed to launch as it entered Terminated state
2021-10-06 09:26:05 UTC+0530 MyInstanceProfile CREATE_IN_PROGRESS Resource creation Initiated
2021-10-06 09:26:05 UTC+0530 MyInstanceProfile CREATE_IN_PROGRESS -
2021-10-06 09:26:03 UTC+0530 MyInstanceRole CREATE_COMPLETE -
2021-10-06 09:25:56 UTC+0530 sampleEnvironment CREATE_IN_PROGRESS Resource creation Initiated
2021-10-06 09:25:55 UTC+0530 sampleEnvironment CREATE_IN_PROGRESS -
2021-10-06 09:25:53 UTC+0530 sampleConfigurationTemplate CREATE_COMPLETE -
2021-10-06 09:25:53 UTC+0530 sampleConfigurationTemplate CREATE_IN_PROGRESS Resource creation Initiated
2021-10-06 09:25:53 UTC+0530 sampleApplicationVersion CREATE_COMPLETE -
2021-10-06 09:25:53 UTC+0530 sampleApplicationVersion CREATE_IN_PROGRESS Resource creation Initiated
2021-10-06 09:25:52 UTC+0530 sampleApplicationVersion CREATE_IN_PROGRESS -
2021-10-06 09:25:52 UTC+0530 sampleConfigurationTemplate CREATE_IN_PROGRESS -
2021-10-06 09:25:50 UTC+0530 sampleApplication CREATE_COMPLETE -
2021-10-06 09:25:50 UTC+0530 sampleApplication CREATE_IN_PROGRESS Resource creation Initiated
2021-10-06 09:25:50 UTC+0530 MyInstanceRole CREATE_IN_PROGRESS Resource creation Initiated
2021-10-06 09:25:50 UTC+0530 MyInstanceRole CREATE_IN_PROGRESS -
2021-10-06 09:25:50 UTC+0530 sampleApplication CREATE_IN_PROGRESS -
2021-10-06 09:25:46 UTC+0530 main-cf-sb2-2 CREATE_IN_PROGRESS User Initiated

最佳答案

终于,我解决了这个问题。由于错误含糊不清,我在官方页面上使用了另一个示例 CloudFormation 脚本,该脚本使用 Elastic Beanstalk 部署 PHP 应用程序。该脚本有一个区别:

 {
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "IamInstanceProfile",
"Value": {
"Ref": "MyInstanceProfile"
}
}

希望对其他人有帮助。完整脚本:

{
"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::Sub": "elasticbeanstalk-samples-${AWS::Region}"
},
"S3Key": "helloworld-0.0.1-SNAPSHOT.jar"
}
}
},
"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"
},
{
"Namespace": "aws:autoscaling:launchconfiguration",
"OptionName": "IamInstanceProfile",
"Value": {
"Ref": "MyInstanceProfile"
}
}
],
"SolutionStackName": "64bit Amazon Linux 2 v3.2.5 running Corretto 11"
}
},
"sampleEnvironment": {
"Type": "AWS::ElasticBeanstalk::Environment",
"Properties": {
"ApplicationName": {
"Ref": "sampleApplication"
},
"Description": "AWS ElasticBeanstalk Sample Environment",
"TemplateName": {
"Ref": "sampleConfigurationTemplate"
},
"VersionLabel": {
"Ref": "sampleApplicationVersion"
}
}
},
"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"
}
]
}
}
}
}

关于amazon-web-services - AWS CloudFormation + Elastic Beanstalk 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69469829/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com