首页 > 解决方案 > 无法创建具有“不匹配区域”的 ElasticBeanstalk 自定义平台

问题描述

我正在尝试按照aws 文档为区域 ap-northeast-1 创建一个自定义平台。

ebp create以失败结束,并ebp events显示错误指示创建的 AMI 与服务区域位于不同的区域。

2018-04-28 00:49:18    INFO    Initiated platform version creation for 'NodePlatform_Ubuntu/1.0.0'.
2018-04-28 00:49:22    INFO    Creating Packer builder environment 'eb-custom-platform-builder-packer'.
2018-04-28 00:52:39    INFO    Starting Packer building task.
2018-04-28 00:52:44    INFO    Creating CloudWatch log group '/aws/elasticbeanstalk/platform/NodePlatform_Ubuntu'.
2018-04-28 01:03:48    INFO    Successfully built AMI(s): 'ami-5f2f4527' for 'arn:aws:elasticbeanstalk:ap-northeast-1:392559473945:platform/NodePlatform_Ubuntu/1.0.0'
2018-04-28 01:04:03    ERROR   Unmatched region for created AMI 'ami-5f2f4527': 'us-west-2' (service region: 'ap-northeast-1').
2018-04-28 01:04:03    INFO    Failed to create platform version 'NodePlatform_Ubuntu/1.0.0'.

我使用了 aws 文档中提供的这个示例自定义平台,并且只修改了 custom_platform.jsonbuilders.regionbuilders.source_ami以匹配我的自定义平台生成器的区域。

.elasticbeanstalk/config.yml

global:
  application_name: Custom Platform Builder
  branch: null
  default_ec2_keyname: null
  default_platform: null
  default_region: ap-northeast-1
  instance_profile: null
  platform_name: NodePlatform_Ubuntu
  platform_version: null
  profile: eb-cli
  repository: null
  sc: git
  workspace_type: Platform

custom_platform.json

{
  "variables": {
    "platform_name": "{{env `AWS_EB_PLATFORM_NAME`}}",
    "platform_version": "{{env `AWS_EB_PLATFORM_VERSION`}}",
    "platform_arn": "{{env `AWS_EB_PLATFORM_ARN`}}"
  },
  "builders": [
    {
      "type": "amazon-ebs",
      "name": "HVM AMI builder",
      "region": "ap-northeast-1",
      "source_ami": "ami-60a4b21c",
      "instance_type": "m3.medium",
      "ssh_username": "ubuntu",
      "ssh_pty": "true",
      "ami_name": "NodeJs running on Ubuntu Server 16.04 LTS (built on {{isotime \"20060102150405\"}})",
      "tags": {
        "eb_platform_name": "{{user `platform_name`}}",
        "eb_platform_version": "{{user `platform_version`}}",
        "eb_platform_arn": "{{user `platform_arn`}}"
      }
    }
  ],
  "provisioners": [
    {
      "type": "file",
      "source": "builder",
      "destination": "/tmp/"
    },
    {
      "type": "shell",
      "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo {{ .Path }}",
      "scripts": [
        "builder/builder.sh"
      ]
    }
  ]
}

看来我对 custom_platform.json 的修改没有生效。

标签: amazon-elastic-beanstalk

解决方案


我错过的是提交更改...

尽管 EB 和 Packer 文档没有提及任何关于 vcs 或 git 的内容,但似乎 packer 使用 git 创建自定义平台文件的存档,因此我所做的更改未包含在其中,因为我没有提交它们。

我注意到这ebp create给了我这个警告......

mac.local:NodePlatform_Ubuntu% ebp create
WARNING: You have uncommitted changes.

推荐阅读