Deploying an App Engine application in GCP can be done using the Google Cloud Console, CLI commands, or Terraform. Here, we will explain each approach in detail:
- Google Cloud Console:
a. Go to the GCP Console: https://console.cloud.google.com/
b. Select your project.
c. Navigate to the App Engine dashboard by clicking the hamburger menu, then click on “App Engine.”
d. Click “Create Application” if you haven’t created an application yet, and follow the instructions.
e. Once the application is created, click “Deploy” on the top-right corner.
f. Select a runtime environment (e.g., Python, Java, Node.js, Go, etc.).
g. Follow the instructions to create theapp.yaml
file.
h. Upload your application’s source code as a ZIP file, or choose a repository.
i. Click “Deploy” to start the deployment process. - CLI Commands (gcloud):
a. Install and set up the Google Cloud SDK: https://cloud.google.com/sdk/docs/install
b. Authenticate with your GCP account:gcloud auth login
c. Set the active project:gcloud config set project PROJECT_ID
d. Navigate to your application’s source code directory.
e. Create anapp.yaml
file with the necessary configurations (runtime, service, etc.).
f. Deploy the App Engine application:gcloud app deploy app.yaml
- Terraform:
a. Install Terraform: https://learn.hashicorp.com/tutorials/terraform/install-cli
b. Create amain.tf
file with the required provider and resource configurations:
provider "google" {
project = "PROJECT_ID"
region = "REGION"
}
resource "google_app_engine_application" "app" {
project = "PROJECT_ID"
location_id = "REGION"
serving_status = "SERVING"
feature_settings {
split_health_checks = true
}
}
resource "google_app_engine_standard_app_version" "app_version" {
version_id = "v1"
service = "default"
runtime = "RUNTIME_ENV"
entrypoint {
shell = "ENTRYPOINT_COMMAND"
}
deployment {
zip {
source_url = "https://storage.googleapis.com/YOUR_BUCKET/YOUR_APP_SOURCE.zip"
}
}
env_variables = {
VAR_NAME = "VAR_VALUE"
}
automatic_scaling {
cool_down_period_seconds = 120
max_instances = 5
min_instances = 1
target_cpu_utilization = 0.75
target_throughput_utilization = 0.75
}
}
resource "google_storage_bucket" "bucket" {
name = "YOUR_BUCKET"
}
c. Initialize the Terraform project: terraform init
d. Review the Terraform plan: terraform plan
e. Apply the Terraform plan: terraform apply
Replace the placeholders (e.g., PROJECT_ID, REGION, YOUR_BUCKET, RUNTIME_ENV, ENTRYPOINT_COMMAND, and YOUR_APP_SOURCE) with the appropriate values for your project. Make sure to upload your application’s source code as a ZIP file to the specified Google Cloud Storage bucket.
Leave a Reply