hashicorp / packer-plugin-alicloud

Packer plugin for Alibaba Cloud Image Builder
https://www.packer.io/docs/builders/alicloud-ecs
Mozilla Public License 2.0
12 stars 21 forks source link

feat: support skip create image #95

Closed newbieJerry closed 1 year ago

newbieJerry commented 1 year ago

Overview of the Issue

Have a flag that allows user to skip the image creation, this can be useful for test builds and rapid validation.

Reproduction Steps

  1. create a packer script with "skip_create_image":"true"
  2. run the packer build

Plugin and Packer Version

  1. Packer v1.8.3
  2. packer-plugin-alicloud v1.0.5

Simplified Packer Buildfile

{
   "variables": {
     "access_key": "{{env `LTAI5tCzUL*********Z1iFQ`}}",
     "secret_key": "{{env `fwVAFD6UWC*********wgmilEhG6Td`}}"
   },
   "builders": [{
     "type":"alicloud-ecs",
     "access_key":"{{user `access_key`}}",
     "secret_key":"{{user `secret_key`}}",
     "region":"cn-beijing",
     "image_name":"packer_basic_2",
     "source_image":"ubuntu_20_04_x64_20G_alibase_20220824.vhd",
     "associate_public_ip_address":"true",
     "skip_create_image":"true",
     "ssh_username":"root",
     "instance_type":"ecs.n1.tiny",
     "internet_charge_type":"PayByTraffic",
     "io_optimized":"true"
   }],
   "provisioners": [{
     "type": "shell",
     "inline": ["echo foo"]
   }]
 }

Operating system and Environment details

macOS Monterey 12.6

Log Fragments and crash.log files

alicloud-ecs: Starting instance: i-2ze1xwqv0qz5fn3xpctk
==> alicloud-ecs: Using SSH communicator to connect: 39.105.44.173
==> alicloud-ecs: Waiting for SSH to become available...
==> alicloud-ecs: Connected to SSH!
==> alicloud-ecs: Provisioning with shell script: /var/folders/70/qctp4fb506l7yr9jxj2ctqx80000gp/T/packer-shell2504466809
alicloud-ecs: foo
==> alicloud-ecs: Stopping instance: i-2ze1xwqv0qz5fn3xpctk
==> alicloud-ecs: Waiting instance stopped: i-2ze1xwqv0qz5fn3xpctk
==> alicloud-ecs: Image build stopped because: you set skip_create_image true
alicloud-ecs: Detach keypair packer_6386b559-8cbe-66d6-8d95-e38bce34772c from instance: i-2ze1xwqv0qz5fn3xpctk
==> alicloud-ecs: Deleting EIP because of cancellation or error...
==> alicloud-ecs: Deleting instance because of cancellation or error...
==> alicloud-ecs: Deleting security group because of cancellation or error...
hashicorp-cla commented 1 year ago

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


1 out of 2 committers have signed the CLA.


mengyu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you already have a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

newbieJerry commented 1 year ago

@nywilken I add a new parameter in packer-plugin-alicloud.

nywilken commented 1 year ago

Hello there, thanks for the contribution; this is looking good so far; Please sign the CLA so that we can work on getting this merged 🙂

newbieJerry commented 1 year ago

done

newbieJerry commented 1 year ago

@nywilken Sorry for error occurred when code merged last time, everything works fine in my Goland when i run make test and go fmt ./.... And it seems 'import format' problem, so I adjust import lines in my last commit.

newbieJerry commented 1 year ago

Code owner review required

Hello, would you mind review the code , thx

newbieJerry commented 1 year ago

Sorry I didn't notice the rules of the CLA, I will resubmit a PR to sign the new CLA