Skip to content

Update instance name logic in GCP packer plugin startup script - #355

Merged
tanmay-hc merged 2 commits into
hashicorp:mainfrom
duncanspani:patch-1
Aug 3, 2026
Merged

Update instance name logic in GCP packer plugin startup script#355
tanmay-hc merged 2 commits into
hashicorp:mainfrom
duncanspani:patch-1

Conversation

@duncanspani

Copy link
Copy Markdown
Contributor

Get instance name via metadata server instead of using ${HOSTNAME}

Some Linux distros on GCP allows the ${HOSTNAME} to resolve to the FQDN by default (ie: {NAME}.{ZONE}.c.{PROJECT}.internal) which causes the startup script to throw an error during completion, even if all other tasks were successful. This errors results in the metadata never being updated and the startup script running forever.

This change removes the only reference to the HOSTNAME env var, and replaces it with the name returned by the GCP metadata server (similar to ZONE in this same file).

Get instance name via metadata server instead of using ${HOSTNAME}

Depending on the OS, ${HOSTNAME} can resolve to the FQDN (ie: `{NAME}.{ZONE}.c.{PROJECT}.internal`) which causes the startup script to fail during completion, even if all other tasks were successful.
@duncanspani
duncanspani requested a review from a team as a code owner July 29, 2026 03:28
@hashicorp-cla-app

hashicorp-cla-app Bot commented Jul 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@duncanspani duncanspani changed the title Update GCP packer plugin Update instance name logic in GCP packer plugin Jul 31, 2026
@duncanspani duncanspani changed the title Update instance name logic in GCP packer plugin Update instance name logic in GCP packer plugin startup script Jul 31, 2026
@tanmay-hc
tanmay-hc merged commit aad3634 into hashicorp:main Aug 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants