AWS Elastic Beanstalk-环境必须具有与其关联的实例配置文件 [英] AWS Elastic Beanstalk - Environment must have instance profile associated with it

查看:115
本文介绍了AWS Elastic Beanstalk-环境必须具有与其关联的实例配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个项目,该项目将以编程方式在AWS Elastic beantalk中创建环境.我正在使用适用于PHP版本3的AWS开发工具包.

I am working on a project that will programmatically create environments in AWS elastic beanstalk. I am using the AWS SDK for PHP Version 3.

我的脚本创建了环境.在AWS控制台中,环境以灰色显示,并表示已终止.查看事件显示错误环境必须具有与其关联的实例配置文件".

My script creates the environment. From the AWS console, the environment is displayed in gray and says that it is terminated. Viewing the events shows that an error of "Environment must have instance profile associated with it".

我尝试使用两个不同用户的访问密钥和机密.一个用户拥有AmazonEC2FullAccess,IAMFullAccess和AWSElasticBeanstalkFullAccess权限.另一个用户具有AWSAdmin权限.两个用户都可以从AWS控制台创建环境.

I have tried using the access key and secret of two different users. One user has AmazonEC2FullAccess, IAMFullAccess, and AWSElasticBeanstalkFullAccess permissions. The other user has AWSAdmin permissions. Both users can create environments from the AWS console.

我不知道如何将实例配置文件与SDK中的环境相关联.我看不到使用createEnvironment函数执行此操作的选项:

I do not know how to associate an instance profile with an environment from the SDK. I do not see an option to do it with the createEnvironment function: createEnvironment syntax I also do not see a way to do it when creating an instance of the ElasticBeanstalkClient object.

我的代码如下.谢谢.

<?php
    require 'vendor/autoload.php';
    use Aws\ElasticBeanstalk\ElasticBeanstalkClient;
    use Aws\Credentials\Credentials;

    $key = '***key***';
    $secret = '***secret***';

    $credentials = new Credentials($key, $secret);
    $ebClient = new ElasticBeanstalkClient([
        'region'  => 'us-east-2',
        'version' => '2010-12-01',
        'credentials' => $credentials
    ]);

    $ebEnv = $ebClient->createEnvironment([
        'ApplicationName' => 'app-from-sdk',
        'EnvironmentName' => 'env-from-sdk-1',
        'CNAMEPrefix'     => 'sdk-test1',
        'Description'     => 'Test environment created from SDK.',
        //'TemplateName'    => 'PHP 7.1 version 2.7.1',
        'SolutionStackName' => '64bit Amazon Linux 2018.03 v2.7.1 running PHP 
7.1',
        'VersionLabel'    => 'Sample Application'
    ]);
    echo '<pre>';
    var_dump($ebEnv);
    echo '</pre>';

推荐答案

您在传递的createEnvironment属性映射/哈希中缺少以下属性:

You are missing the following attributes in your createEnvironment attribute map/hash you pass:

OptionSettings.member.1.Namespace = aws:autoscaling:launchconfiguration
OptionSettings.member.1.OptionName = IamInstanceProfile
OptionSettings.member.1.Value = aws-elasticbeanstalk-ec2-role

来源: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-create-api.html

这篇关于AWS Elastic Beanstalk-环境必须具有与其关联的实例配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆