[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[[["\u003cp\u003eExternal templates can be hosted on the internet, such as Google Cloud Storage or GitHub, offering advantages like easy sharing and automatic updates.\u003c/p\u003e\n"],["\u003cp\u003eDeployment Manager automatically fetches the latest version of external templates upon each redeployment and handles the importing of any dependent templates.\u003c/p\u003e\n"],["\u003cp\u003eTemplates hosted in Google Cloud Storage allow for controlled access through bucket-level or specific file access controls, unlike templates hosted on other public URLs.\u003c/p\u003e\n"],["\u003cp\u003eTo call an external template, users should provide the full URL to the template file as the type in their configuration, similar to how they would with local templates.\u003c/p\u003e\n"],["\u003cp\u003eDeployment Manager can manage importing other dependent files, like schemas, that are referenced in an external template, as long as they are located within the same directory or in a relative subdirectory.\u003c/p\u003e\n"]]],[],null,["# Storing Templates on an External Host\n\nThis document describes how to use external templates in your deployment\nthat are hosted somewhere on the Internet instead of your local machine.\n\nYou can store templates on an external host anywhere on the Internet and\ncall these templates from within your configuration. Hosting templates\nexternally has certain advantages over storing your templates locally:\n\n- Easily share templates with others\n- Ensure that configurations are always using the most up-to-date template\n- Automatically manage relevant imports and schemas\n\nDeployment Manager always fetches the latest version of external templates each\ntime you redeploy your configuration. If you maintain your templates, then your\ndeployments will always be up to date as well. Deployment Manager will also\nhandle importing other dependent templates for you if they are referenced in the\nexternal template.\n\n**Example**\n\nThis configuration imports an external template: \n\n resources:\n - name: my-frontend\n type: gs://my-frontend-templates/webserver-frontend.jinja\n\nBefore you begin\n----------------\n\n- If you want to use the command-line examples in this guide, install the [\\`gcloud\\` command-line tool](/sdk).\n- If you want to use the API examples in this guide, set up [API access](/deployment-manager/docs/reference/latest).\n- Read the [Configuration](/deployment-manager/docs/configuration/create-basic-configuration) documentation.\n- Read the [Templates](/deployment-manager/docs/configuration/templates/create-basic-template) documentation.\n\nHosting external templates\n--------------------------\n\nYou can host external templates in Google Cloud Storage or in a\npublicly-accessible location, such as GitHub. As long as there is a URL to the\nfile and you have access to the templates, Deployment Manager will be able to\ndownload it. If the file uses a schema to import other templates, you must\nalso host those templates in the same base URL.\n\n### On Google Cloud Storage\n\nTo host templates in Google Cloud Storage:\n\n1. [Create a bucket](/storage/docs/getting-started-console#create_a_bucket) for the templates, or use an existing bucket.\n2. [Upload your templates](/storage/docs/getting-started-console#upload_objects_into_the_bucket) and related template files, like schemas, to the bucket.\n3. If you plan to use the templates from a different Google Cloud Platform project than the project the templates belong to, set [access controls](/storage/docs/access-control) to allow that access.\n\nHosting templates in Google Cloud Storage lets you control who has access\nto the templates because you can set access control options on the respective\nCloud Storage bucket or the specific template.\n\nIn contrast, hosting your templates on other publicly-accessible URLs requires\nthat you make the templates widely available.\n\n### On a publicly-accessible URL\n\nAlternatively, you can host external templates outside of Google Cloud Storage,\nso long as the templates are publicly-accessible. For example, you can\nhost templates on GitHub and reference the templates using the GitHub URL.\n\nFor GitHub specifically, you need to provide the raw GitHub URL so that\nDeployment Manager gets the template instead of the HTML GitHub page. For\nexample, a raw URL looks like this: \n\n https://raw.githubusercontent.com/GoogleCloudPlatform/deploymentmanager-samples/master/examples/v2/single_vm/jinja/vm_template.jinja\n\nCalling an external template\n----------------------------\n\nCall an external template like you would a local template, but provide the\nfull URL to the template file as the type. For example: \n\n resources:\n - name: my-salt-cluster\n type: gs://v2/saltstack/salt_cluster.jinja\n\nFor a GitHub URL: \n\n resources:\n - name: my-salt-cluster\n type: https://raw.githubusercontent.com/GoogleCloudPlatform/deploymentmanager-samples/master/examples/v2/single_vm/vm_template.jinja\n\nIf an external template imports other templates or if there is an accompanying\nschema, you can store the related files in the same directory or relative\nsubdirectory and include these other templates with a relative URL. Deployment\nManager will look for these other templates using the relative path based on the\nbase URL.\n\nFor example, if your configuration looked like this: \n\n resources:\n - name: my-salt-cluster\n type: gs://v2/saltstack/salt_cluster.jinja\n\nAnd there was a schema file named `salt_cluster.jinja.schema` that imported\nthese files: \n\n imports:\n - path: minion.py\n - path: master.py\n - path: examples/source/example.py\n\nDeployment Manager will download and import all of the necessary files for the\ntemplate automatically."]]