Loading...
Loading...
### Terraform Version ```shell 1.7.4 ``` ### Terraform Configuration Files module "gce_instance_app" { source = "tfe.example.com/org/compute/google" version = "0.1.16" name = "app" project_id = "example-project-id" zone = "us-central1-a" boot_disk_size = 75 machine_type = "n2-standard-8" boot_disk_type = "pd-standard" service_account_email = "EMAIL" additional_service_scopes = [] # min_cpu_platform = var.min_cpu_platform subnetwork = "projects/example-project-id/regions/us-central1/subnetworks/example-subnet" static_ip = "192.168.16.254" vpc = "example-vpc" image_id = "custom-image-id" google_kms_key_ring = "example-key-ring" google_kms_crypto_key = "example-crypto-key" key_ring_location = "us-central1" additional_network_tags = [] network_tags = ["allow-health-check","allow-i-health-check","custom-tag-1","custom-tag-2"] startup_script = templatefile("./init-platform-playwright.sh", { user = "some", testEnabled = "true" }) # labels app_name = "example-app" app_env = "dev" provisioner_repo = "example-repo" } ### Debug Output FE coming , If we procure the same VM again with the IP .It will start procuring , the but the things we run in startup_script: . There is residual things on the VM. In the application if we need to install podman - It will install in the first time, However in the next run with changes it fails and not runs successfully. Something is residual and not working properly. ### Expected Behavior Expected Behavior: First Provisioning (Fresh VM): The startup_script runs on a clean VM. All required packages (e.g., podman) are installed. Application setup completes without errors. Success messages are logged (e.g., Podman installed successfully., Startup script completed successfully.). Subsequent Runs (Same VM, Script Re-run): The script checks if packages like podman are already installed and skips reinstallation if present. Any temporary or residual files from previous runs are cleaned up at the start. The script is idempotent: running it multiple times does not cause failures or duplicate installations. Success messages are logged again, indicating a clean, successful run. On Failure: If any step fails, the script logs a clear error message and exits with a non-zero status. The provisioning process reports the failure, allowing for troubleshooting. ### Actual Behavior This issue is common when reusing VMs: residual files, packages, or state from previous runs can cause idempotency problems in your startup_script. To resolve it make your script and ensure clean, repeatable runs, But ideally it shouldn't be the case: 1. Make your script idempotent: Check if podman is already installed before installing. Clean up or reset any files, configs, or state that may interfere with re-runs. 2. Log success/failure clearly: Output clear success messages at the end. Exit with a non-zero code on failure. ### Steps to Reproduce terraform init terraform apply #!/bin/bash set -e echo "Starting startup script..." # Idempotent podman install if ! command -v podman &> /dev/null; then echo "Podman not found, installing..." # Example for RHEL/CentOS sudo yum -y install podman echo "Podman installed successfully." else echo "Podman already installed, skipping." fi # Clean up residual files (example) rm -rf /tmp/my-app-tmp || true # Your app setup here... echo "Startup script completed successfully." exit 0 on the config provided with the same IP for the setting provided. ### Additional Context _No response_ ### References _No response_ ### Generative AI / LLM assisted development? _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.