我正在建立一个自定义平台来运行我们的应用程序。我们已经删除了默认的VPC,因此根据文档,我几乎在任何地方都必须指定VPC和子网id。因此,我为ebp运行的命令如下所示:
ebp create -v --vpc.id vpc-xxxxxxx --vpc.subnets subnet-xxxxxx --vpc.publicip{code}上面提到的pcakcer环境没有任何问题,但是当packer开始构建一个实例时,我得到了以下错误:
2017-12-07 18:07:05 UTC+0100 ERROR [Instance: i-00f376be9fc2fea34] Command failed on instance. Return code: 1 Output: 'packer build' failed, the build log has been saved to '/var/log/packer-builder/XXX1.0.19-builder.log'. Hook /opt/elasticbeanstalk/hooks/packerbuild/build.rb failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2017-12-07 18:06:55 UTC+0100 ERROR 'packer build' failed, the build log has been saved to '/var/log/packer-builder/XXX:1.0.19-builder.log'
2017-12-07 18:06:55 UTC+0100 ERROR Packer failed with error: '--> HVM AMI builder: VPCIdNotSpecified: No default VPC for this user status code: 400, request id: 28d94e8c-e24d-440f-9c64-88826e042e9d'{code}模板和platform.yaml都指定了vpc_id和子网id,但是packer没有考虑到这一点。platform.yaml
version: "1.0"
provisioner:
type: packer
template: tomcat_platform.json
flavor: ubuntu1604
metadata:
maintainer: <Enter your contact details here>
description: Ubuntu running Tomcat
operating_system_name: Ubuntu Server
operating_system_version: 16.04 LTS
programming_language_name: Java
programming_language_version: 8
framework_name: Tomcat
framework_version: 7
app_server_name: "none"
app_server_version: "none"
option_definitions:
- namespace: "aws:elasticbeanstalk:container:custom:application"
option_name: "TOMCAT_START"
description: "Default application startup command"
default_value: ""
option_settings:
- namespace: "aws:ec2:vpc"
option_name: "VPCId"
value: "vpc-xxxxxxx"
- namespace: "aws:ec2:vpc"
option_name: "Subnets"
value: "subnet-xxxxxxx"
- namespace: "aws:elb:listener:80"
option_name: "InstancePort"
value: "8080"
- namespace: "aws:elasticbeanstalk:application"
option_name: "Application Healthcheck URL"
value: "TCP:8080"tomcat_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",
"region": "eu-west-1",
"source_ami": "ami-8fd760f6",
"instance_type": "t2.micro",
"ami_virtualization_type": "hvm",
"ssh_username": "admin",
"ami_name": "Tomcat running on Ubuntu Server 16.04 LTS (built on {{isotime \"20060102150405\"}})",
"ami_description": "Tomcat running on Ubuntu Server 16.04 LTS (built on {{isotime \"20060102150405\"}})",
"vpc_id": "vpc-xxxxxx",
"subnet_id": "subnet-xxxxxx",
"associate_public_ip_address": "true",
"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"
]
}
]
}感谢任何想法,如何使这一工作,如预期。我在Packer上发现了几个问题,但是似乎已经解决了,所以文档只是说模板必须指定目标VPC和子网。
发布于 2018-01-09 20:43:11
在这种情况下,AWS文档有点误导。您确实需要一个默认的VPC来创建一个自定义平台。据我所见,这是因为您传递给ebp创建命令的VPC标志没有传递给实际构建平台的packer进程。
为了避免这个错误,您可以创建一个新的默认VPC,您只需使用它来创建自定义平台。
发布于 2020-06-19 22:07:56
Packer在创建自定义平台所需的资源(包括启动EC2实例、创建安全组等)时,查找默认VPC (默认包装器的行为),但是,如果该区域中不存在默认VPC (例如,如果删除它),则Packer Build Task将失败,但出现以下错误:
包装失败,错误:‘-> HVM构建器: VPCIdNotSpecified:没有此用户状态代码的默认VPC : 400,请求id: xyx’
要修复此错误,请在“template.json”文件的“构建器”部分使用下面的template.json,以便在创建资源时使用自定义VPC和子网:
vpc_id subnet_id▸▸
https://stackoverflow.com/questions/47702265
复制相似问题