Downloading Your Source Code

To download an application's files, run the appcfg.py command with the download_app action.

appcfg.py -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID] download_app [OUTPUT_DIR]

where:

  • [YOUR_PROJECT_ID] is your GCP project ID.
  • [YOUR_VERSION_ID] is the version ID of your application that you want to download.
  • [OUTPUT_DIR] is the full directory path to where you want your files downloaded.

For more information about this command, see the appcfg.py download_app reference.

If the command is successful, you get output similar to the following:

Getting file list...
Fetching files...
Getting files...

[1/5] request.go
[2/5] login.go
[3/5] static/screen.css
[4/5] static/print.css
[5/5] images/bird.png

Troubleshooting

Command not found

If you installed the Google Cloud SDK and use the gcloud tool, the appcfg.py command is available from the [SDK_INSTALL_PATH]/google-cloud-sdk/platform/google_appengine/ directory.

For example, to use the Google Cloud SDK, you run the appcfg.py by specifying the directory path:

[SDK_INSTALL_PATH]/google-cloud-sdk/platform/google_appengine/appcfg.py -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID] download_app [OUTPUT_DIR]
You do not have permission to download this app version

Only the authenticated user who deployed the version of the application as well as the users with the project Owner role have the privileges to download files. Other users who attempt to download the application will receive an error message similar to the following:

Fetching file list...
Error 403: --- begin server output ---
You do not have permission to download this app version.
--- end server output ---

Preventing Source Code Downloads

Download access to any available source code can be restricted by using an Organization Policy.

The constraint for controlling code downloads is:

constraints/appengine.disableCodeDownload

The default value for the constraint is false, meaning that code downloads are enabled. You can enable this policy constraint on an organization, project and folder and are inherited by child resources. For example, a project inherits policy constraints set on its containing folder, and a folder inherits constraints set on an organization.

Permissions

You can set the appengine.disableCodeDownload constraint if you have been granted the orgpolicy.policyAdmin role on the organization.

Setting the policy constraint on the organization level

You need your project's organization ID to set the constraints/appengine.disableCodeDownload constraint.

Find your organization ID

Console

You can find the ID on the Google Cloud Platform Console:

  1. Log in to the Google Cloud Platform Console.
  2. Click on the project selector.

    Screenshot of organization and project selector

  3. Select an organization and look for the organization ID.

    Screenshot of organization ID

gcloud

Run the following gcloud command and look for the ID:

gcloud organizations list

Example gcloud output something like the following, where ID is the project ID:

DISPLAY_NAME           ID
example-organization   29252605212

Setting your policy constraint

Console

To set the organization policy, configure the constraint to disable source code download:

  1. Go to the Organization policies page in the Google Cloud Platform Console.

    Go to the Organization policies page

  2. Click the Organization drop-down list at the top of the page and then select your organization.
  3. Click Disable Source Code Download.
  4. Click the Edit button.
  5. Under Applies to, select Customize.
  6. Under Enforcement, select On.
  7. Click Save. A notification will appear to confirm that the policy has been updated.

gcloud

Policies can be set using the gcloud command-line tool.

To disable source code download, run the following command:

gcloud alpha resource-manager org-policies enable-enforce \
    --organization 'ORGANIZATION_ID' \
    appengine.disableCodeDownload

To disable the policy, the same command can be issued with the

disable-enforce
command.

You can set the appengine.disableCodeDownload constraint at the folder and project level. To learn more about using constraints in organization policies, see Using Constraints.

Was this page helpful? Let us know how we did:

Send feedback about...

App Engine standard environment for Go