Creating a new 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 or create a new one.
c. Navigate to the App Engine dashboard by clicking the hamburger menu, then click on “App Engine.”
d. Click “Create Application.”
e. Select a region for your application and click “Next.”
f. Choose a runtime environment (e.g., Python, Java, Node.js, Go, etc.) and click “Next.”
g. Follow the instructions to create theapp.yaml
file and deploy your application. - 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. Create anapp.yaml
file with the necessary configurations (runtime, service, etc.).
e. 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 = "python39"
entrypoint {
shell = "gunicorn -b :$PORT main:app"
}
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, and YOUR_APP_SOURCE) with the appropriate values for your project.
Leave a Reply