Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build 'amazon-ebs.static-web-ami' errored after 861 milliseconds 814 microseconds: unexpected EOF #12857

Closed
shindam opened this issue Feb 27, 2024 · 1 comment
Labels

Comments

@shindam
Copy link

shindam commented Feb 27, 2024

Hello, i'm using Packer on a docker image for a CI/CD on Gitlab for Amazon AWS.
Here is my packer files : `packer {
required_plugins {
amazon = {
version = "> 1.3"
source = "github.com/hashicorp/amazon"
}
ansible = {
version = "
> 1.1"
source = "github.com/hashicorp/ansible"
}
}
}

variable "associate_public_ip_address" {
type = string
default = "true"
}

variable "base_ami" {
type = string
default = "ami-007855ac798b5175e"
}

variable "instance_type" {
type = string
default = "t2.micro"
}

variable "region" {
type = string
default = "us-east-1"
}

variable "app_name" {
type = string
default = "WebApp"
}

variable "server_port" {
type = string
default = "8080"
}

variable "ssh_username" {
type = string
default = "ubuntu"
}

locals {
timestamp = formatdate("YYYY-MM-DD_hh-mm-ss", timestamp())
cleaned_app_name = replace("${var.app_name}", "/[^a-zA-Z0-9()\\[\\] .\\/@_-]/", "_")
ami_name = "${local.cleaned_app_name}-${local.timestamp}"
}

source "amazon-ebs" "static-web-ami" {
ami_name = local.ami_name
associate_public_ip_address = var.associate_public_ip_address
instance_type = var.instance_type
region = var.region
source_ami = var.base_ami
ssh_username = var.ssh_username
iam_instance_profile = "LabInstanceProfile"
tags = {
Name = "Project-${local.ami_name}"
}
}

build {
sources = [
"source.amazon-ebs.static-web-ami"
]

provisioner "ansible" {
playbook_file = "play.yml"
extra_arguments = ["--extra-vars", "server_port=${var.server_port}"]
ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"]
use_proxy = false
}
}
`

I got this message when using this code for my CI/CD to create a AMI :

Capture d'écran 2024-02-27 144837

And here is the yml file on gitlab CI/CD : `packer-build:
stage: build
image:
name: hashicorp/packer:latest
entrypoint: ["/bin/sh", "-c"]
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN : $AWS_SESSION_TOKEN
APP_NAME: "patate" # Définir le nom du projet ici
SERVER_PORT: "8081" # Définir le port ici
before_script:
- apk add --update --no-cache openssh-client python3 py3-pip python3-dev gcc musl-dev libffi-dev openssl-dev make
- eval $(ssh-agent -s)
script:
- ls
- python3 -m venv venv
- source venv/bin/activate
- pip install --upgrade pip
- pip install ansible
- packer init buildAMI.pkr.hcl
- packer validate buildAMI.pkr.hcl
- packer build -var "app_name=${APP_NAME}" -var "server_port=${SERVER_PORT}" buildAMI.pkr.hcl

only:
- main

`

Log Fragments and crash.log files

I can't locate the crash.log files

It will be very helpful if you can help me thanks a lot.

@shindam shindam added the bug label Feb 27, 2024
@shindam shindam closed this as completed Mar 12, 2024
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant