If you have your own deployment tools and workflows, you can download templates or applications as Terraform files.
The following files are generated:
main.tf
: Infrastructure code that includes a module for each component in the template.outputs.tf
: Exposes information about infrastructure components that are deployed.variables.tf
: Declares name, type, and description for variables used in themain.tf
file.input.tfvars
: Defines values for variables used in themain.tf
file.providers.tf
: Defines labels that help Terraform interact with Google Cloud APIs and resources.
For background information, see Overview of Terraform on Google Cloud.
If you don't have your own deployment tools and workflows, see Deploy an application from the Google Cloud console.
Before you begin
Ask your administrator to grant you one of the following roles on the app-enabled folder or management project:
- Application Admin (
roles/designcenter.applicationAdmin
). - Application Editor (
roles/designcenter.applicationEditor
).
Export Terraform code
If you want to maintain your templates and applications outside of Google Cloud, you can generate Terraform and export to your local machine, or to your code repository.
Export locally
You can export Terraform code generated from a template or from an application.
Template
In the Google Cloud console, go to the Templates page.
Click the Template ID that you want to export.
Click Get Code.
The system downloads a zip file to your local computer. You can deploy the application using your own deployment tools and workflows.
Application
In the Google Cloud console, go to the Applications page.
Click the Application name that you want to export.
Click Get Code.
The system downloads a zip file to your local computer. You can deploy the application using your own deployment tools and workflows.
Export to your repository
To maintain your templates through your source code management repository, you can export templates and applications to GitHub. For example, you might export to do the following:
- Use your existing version control workflows.
- Trigger builds, tests, and deployments using your own CI/CD pipeline.
Connect to your repository
To create a Developer Connect connection between your GitHub repository and your management project, do the following:
Change your organization policy to add the following services to your allowlist:
developerconnect.googleapis.com
.secretmanager.googleapis.com
.
For steps to change your organization policy, see Using the restrict resource service usage constraint.
Create a Developer Connect connection to your GitHub repository, including the following:
- Select Enable data residency.
- Link the repository where you want to export your application.
For steps to create a connection and link a repository, see Connect GitHub.
To copy the repository URI, do the following:
- Open the Developer Connect Git repositories page.
- In the Repositories table, click More Options and select Copy resource path.
Generate and export
To generate Terraform code and export to your GitHub repository, do the following:
Template
Identify your space ID.
gcloud alpha design-center spaces list \ --project=PROJECT \ --location=LOCATION
Replace the following:
PROJECT
: Your management project ID.LOCATION
: Your location ID.
Identify the template ID for the template that you want to export
gcloud alpha design-center spaces application-templates list \ --space=SPACE \ --project=PROJECT \ --location=LOCATION
Replace the following:
SPACE
: Your space ID.PROJECT
: Your management project ID.LOCATION
: Your location ID.
Generate your template's Terraform code, and export to GitHub.
gcloud alpha design-center spaces application-templates generate APPLICATION_TEMPLATE \ --space=SPACE \ --project=PROJECT \ --location=LOCATION \ --developer-connect-export-config-repo-uri=DEVELOPER_CONNECT_EXPORT_CONFIG_REPO_URI \ --developer-connect-export-config-dir=DEVELOPER_CONNECT_EXPORT_CONFIG_DIR \ --developer-connect-export-config-branch=DEVELOPER_CONNECT_EXPORT_CONFIG_BRANCH
Replace the following:
APPLICATION_TEMPLATE
: The template ID of the template that you want to export.SPACE
: Your space ID.PROJECT
: Your management project ID.LOCATION
: Your location ID.DEVELOPER_CONNECT_EXPORT_CONFIG_DIR
: The directory relative to your GitHub repository.DEVELOPER_CONNECT_EXPORT_CONFIG_BRANCH
: The branch in your GitHub repository.
For more information, see gcloud alpha design-center spaces application-templates generate
View your repository to verify that the template was exported successfully.
Application
Identify your space ID.
gcloud alpha design-center spaces list \ --project=PROJECT \ --location=LOCATION
Replace the following:
PROJECT
: Your management project ID.LOCATION
: Your location ID.
Identify the application ID for the application that you want to export.
gcloud alpha design-center spaces applications list \ --space=SPACE \ --project=PROJECT \ --location=LOCATION
Replace the following:
SPACE
: Your space ID.PROJECT
: Your management project ID.LOCATION
: Your location ID.
Generate your application's Terraform code, and export to GitHub.
gcloud alpha design-center spaces applications generate APPLICATION \ --space=SPACE \ --project=PROJECT \ --location=LOCATION \ --developer-connect-export-config-repo-uri=DEVELOPER_CONNECT_EXPORT_CONFIG_REPO_URI \ --developer-connect-export-config-dir=DEVELOPER_CONNECT_EXPORT_CONFIG_DIR \ --developer-connect-export-config-branch=DEVELOPER_CONNECT_EXPORT_CONFIG_BRANCH
Replace the following:
APPLICATION
: The application ID of the application that you want to export.SPACE
: Your space ID.PROJECT
: Your management project ID.LOCATION
: Your location ID.DEVELOPER_CONNECT_EXPORT_CONFIG_DIR
: The directory relative to your GitHub repository.DEVELOPER_CONNECT_EXPORT_CONFIG_BRANCH
: The branch in your GitHub repository.
For more information, see gcloud alpha design-center spaces applications generate
View your repository to verify that the application was exported successfully.
What's next
Overview of Terraform on Google Cloud