cookbook:
  name: Tutorial 07 Optional Cloud Infrastructure
  canonical_name: tutorial-07-optional-cloud-infrastructure
  environment:
    public:
      - GCP_REGION=us-central1
      - GCP_ZONE=us-central1-a
      - IMAGE=debian-cloud/debian-12
    secrets:
      - GOOGLE_CREDENTIALS
  pages:
    - page: 1
      name: Optional GCP Virtual Machine
      recipes:
        - recipe: Provision GCP VM
          canonical_name: provision-gcp-vm
          description: Create one VM and schedule its exact teardown after one hour.
          form:
            - variable: MACHINE_TYPE
              description: Select the smallest permitted machine type.
              type: select
              options:
                - label: E2 Small
                  value: e2-small
            - variable: SOURCE_CIDR
              description: Enter the one approved public IPv4 address with a /32 prefix.
              type: text
              placeholder: 198.51.100.42/32
            - variable: CONFIRM_CREATE
              description: Enter CREATE to accept cost and resource creation.
              type: text
          now:
            steps:
              - step: 1
                name: Confirm cloud creation
                image: tutorial-cloud-guard:dev
                timeout: 1.minute
              - step: 2
                name: Provision GCP VM
                image: lemc-gcp-terraform-vm:dev
                environment:
                  - TERRAFORM_FUNCTION=apply
                  - DISK_SIZE=20
                  - ENABLE_NESTED_VIRTUALIZATION=false
                  - IS_WINDOWS=false
                timeout: 10.minutes
          in:
            duration: 1.hour
            steps:
              - step: 3
                name: Destroy GCP VM after one hour
                image: lemc-gcp-terraform-vm:dev
                environment:
                  - TERRAFORM_FUNCTION=destroy
                timeout: 10.minutes
        - recipe: Destroy GCP VM
          canonical_name: destroy-gcp-vm
          description: Destroy the VM now and cancel its pending scheduled teardown.
          form:
            - variable: CONFIRM_DESTROY
              description: Enter DESTROY to confirm teardown.
              type: text
          now:
            steps:
              - step: 1
                name: Confirm cloud teardown
                image: tutorial-cloud-guard:dev
                timeout: 1.minute
              - step: 2
                name: Destroy GCP VM
                image: lemc-gcp-terraform-vm:dev
                environment:
                  - TERRAFORM_FUNCTION=destroy
                timeout: 10.minutes
