cddeploymentmanager-samples/examples/v2/step_by_step_guide/step6_use_multiple_templates/python
nanocompute-engine-template.py# use your preferred text editor
# Copyright 2016 Google Inc. All rights reserved.## 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."""Creates the Compute Engine."""defGenerateConfig(context):"""Creates the Compute Engine with network and firewall."""resources=[{'name':'vm-1','type':'vm-template.py'},{'name':'vm-2','type':'vm-template-2.py'},{'name':'network-1','type':'network-template.py'},{'name':'firewall-1','type':'firewall-template.py'}]return{'resources':resources}
查看設定
開啟部署作業適用的設定檔:
cddeploymentmanager-samples/examples/v2/step_by_step_guide/step6_use_multiple_templates/python
nanoconfig-with-many-templates.yaml# use your preferred text editor
# Copyright 2016 Google Inc. All rights reserved.## 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.imports:-path:vm-template.py-path:vm-template-2.py-path:network-template.py-path:firewall-template.py-path:compute-engine-template.pyresources:-name:compute-engine-setuptype:compute-engine-template.py
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-14 (世界標準時間)。"],[[["This step involves exploring a template, `compute-engine-template.py`, which imports other templates to manage various resources within a deployment."],["The `compute-engine-template.py` imports templates such as `vm-template.py`, `vm-template-2.py`, `network-template.py`, and `firewall-template.py` to create virtual machines, a network, and a firewall rule."],["The configuration file, `config-with-many-templates.yaml`, only needs to call `compute-engine-template.py`, as this template handles the importing of the other templates."],["Deploying the configuration is done using the command `gcloud deployment-manager deployments create deployment-with-many-templates --config config-with-many-templates.yaml`, and the deployment can be deleted later with the delete command."]]],[]]