I want to create a Instance using a InstanceTemplate via the java google-api-client. After executing the operation the new instance is displayed, beein created, in the Compute Engine frontend of GCP. After 10-15s the instance disappears.
Following the Reference Manual i cant get my head around why my code is not working.
https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert
Compute.Instances.Insert insert = compute
.instances()
.insert("{{project-id}}","europe-west1-c",instance)
.setSourceInstanceTemplate("/compute/v1/projects/{{project-id}}/global/instanceTemplates/instance-template-1")
.setZone("europe-west1-c")
.setProject("{{project-id}}");
Operation op = insert.execute();
The instance Object looks like that:
Instance instance = new Instance();
instance.setName(instanceName);
instance.setMachineType("zones/europe-west1-c/machineTypes/g1-small");
Gradle Dependencies
compile 'com.google.api-client:google-api-client:1.31.2'
compile group: 'com.google.apis', name: 'google-api-services-compute', version: 'v1-rev235-1.25.0'
Log from the GCP:
{
"protoPayload": {
"@type": "type.googleapis.com/google.cloud.audit.AuditLog",
"status": {
"code": 3,
"message": "INVALID_PARAMETER"
},
"authenticationInfo": {
"principalEmail": "compute-dev-me@{{project-id}}.iam.gserviceaccount.com"
},
"requestMetadata": {
"callerIp": "12.34.56.78",
"callerSuppliedUserAgent": "redacted/0.1 Google-API-Java-Client/1.31.2 Google-HTTP-Java-Client/1.37.0 (gzip),gzip(gfe)"
},
"serviceName": "compute.googleapis.com",
"methodName": "v1.compute.instances.insert",
"resourceName": "projects/{{project-id}}/zones/europe-west1-c/instances/test-mit-richtig",
"request": {
"@type": "type.googleapis.com/compute.instances.insert"
}
},
"insertId": "-duwg4fde7a2",
"resource": {
"type": "gce_instance",
"labels": {
"instance_id": "redacted-number",
"zone": "europe-west1-c",
"project_id": "{{project-id}}"
}
},
"timestamp": "2021-02-xxTxx:xx:xx.565227Z",
"severity": "ERROR",
"logName": "projects/{{project-id}}/logs/cloudaudit.googleapis.com%2Factivity",
"operation": {
"id": "operation-1613xxxx41-xxxxxxxx-xxxxxxxx-xxxxxxx",
"producer": "compute.googleapis.com",
"last": true
},
"receiveTimestamp": "2021-02-xxTxx:xx:xx.569578819Z"
}