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

Feature/support skip create image #99

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
All committers have signed the CLA.

newbieJerry commented 1 year ago

@nywilken Sorry for my novice behavior, I resubmit a PR to sign the CLA, and change the code according to your suggestion here, please review my code, thx :smile:

newbieJerry commented 1 year ago

@nywilken, would you please review this code and get this PR merged?

newbieJerry commented 1 year ago

@lbajolet-hashicorp Could I trouble you to review this PR 😄?