# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

blueprint_name: cloud-batch

vars:
  project_id:  ## Set GCP Project ID Here ##
  deployment_name: batch
  region: us-central1
  zone: us-central1-c

deployment_groups:
- group: primary
  modules:
  - source: ./community/modules/scheduler/cloud-batch-job
    kind: terraform
    id: batch-job
    settings:
      runnable: "echo 'hello world'"
    outputs: [instructions]

# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

blueprint_name: cloud-batch

vars:
  project_id:  ## Set GCP Project ID Here ##
  deployment_name: batch
  region: us-central1
  zone: us-central1-c

deployment_groups:
- group: primary
  modules:
  - source: modules/network/pre-existing-vpc
    kind: terraform
    id: network1

  - source: modules/scripts/startup-script
    kind: terraform
    id: hello-startup-script
    settings:
      runners:
      - type: shell
        destination: generate_hello.sh
        content: |
          #!/bin/sh
          echo "Hello World" > /home/hello.txt

  - source: github.com/terraform-google-modules/terraform-google-vm//modules/instance_template?ref=v7.8.0
    kind: terraform
    id: batch-compute-template
    use: [hello-startup-script]
    settings:
      # Boiler plate to work with Cloud Foundation Toolkit
      network: $(network1.network_self_link)
      service_account: {email: null, scopes: ["https://www.googleapis.com/auth/cloud-platform"]}
      access_config: [{nat_ip: null, network_tier: null}]
      # Batch customization
      machine_type: n2-standard-4

  - source: ./community/modules/scheduler/cloud-batch-job
    kind: terraform
    id: batch-job
    settings:
      runnable: "cat /home/hello.txt"
      instance_template: $(batch-compute-template.self_link)
    outputs: [instructions]

Add startup script example using seperate instance template module
Add startup script example using seperate instance template module
