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

Failed to get private ip of instance #96

Closed konstantin-kornienko closed 1 year ago

konstantin-kornienko commented 1 year ago

Overview of the Issue

Getting error "Failed to get private ip of instance" when using VPC network when associate_public_ip_address = false

Reproduction Steps

use config as follows:

vpc_id = ...
vswitch_id = ...
associate_public_ip_address = false

Instance is creating with the private IP address assigned:

aliyun ecs DescribeInstances --RegionId cn-shanghai --InstanceIds "['i-uf63g7an1rd3tack5r9q']"
...
"InnerIpAddress": {
                                        "IpAddress": []
                                },
...
 "VpcAttributes": {
                                        "NatIpAddress": "",
                                        "PrivateIpAddress": {
                                                "IpAddress": [
                                                        "10.35.243.237"
                                                ]
                                        },
                                        "VSwitchId": "vsw-xxx",
                                        "VpcId": "vpc-xxx"
                                },
                                "ZoneId": "cn-shanghai-b"

Plugin and Packer version

1.0.4, 1.0.5. Worked before 1.0.4.

Log Fragments and crash.log files

==> base_image.alicloud-ecs.base: Prevalidating source region and copied regions...
==> base_image.alicloud-ecs.base: Force delete flag found, skipping prevalidating image name.
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepPreValidate'. Press enter to continue.
    base_image.alicloud-ecs.base: Found image ID: ubuntu_20_04_x64_20G_alibase_20220824.vhd
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepCheckAlicloudSourceImage'. Press enter to continue.
==> base_image.alicloud-ecs.base: Creating temporary keypair: packer_637c64d4-b76a-755b-3e7a-ecf663a2111c
    base_image.alicloud-ecs.base: Saving key for debug purposes: ecs_base.pem
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepConfigAlicloudKeyPair'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepConfigAlicloudVPC'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepConfigAlicloudVSwitch'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepConfigAlicloudSecurityGroup'. Press enter to continue.
==> base_image.alicloud-ecs.base: Creating instance...
    base_image.alicloud-ecs.base: Created instance: i-uf63g7an1rd3tack5r9q
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepCreateAlicloudInstance'. Press enter to continue.
==> base_image.alicloud-ecs.base: Failed to get private ip of instance
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepCreateAlicloudInstance'. Press enter to continue.
==> base_image.alicloud-ecs.base: Deleting instance because of cancellation or error...
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepConfigAlicloudSecurityGroup'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepConfigAlicloudVSwitch'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepConfigAlicloudVPC'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepConfigAlicloudKeyPair'. Press enter to continue.
==> base_image.alicloud-ecs.base: Deleting temporary keypair...
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepCheckAlicloudSourceImage'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepPreValidate'. Press enter to continue.
Build 'base_image.alicloud-ecs.base' finished after 15 minutes 4 seconds.
ar-nim commented 1 year ago

Seems like it's caused by https://github.com/hashicorp/packer-plugin-alicloud/pull/52

bittopaz commented 1 year ago

While I'm working on a fix for this, a temporary workaround is setting the two fields as below:

"associate_public_ip_address": true,
"internet_charge_type": "PayByTraffic",
konstantin-kornienko commented 1 year ago

@bittopaz , @nywilken thanks a lot! Now it works, checked.