Google cloud: invalid build: failed to check access to key - google-app-engine

Trying to create cloudbuild config for App Engine on Google cloud.
There are some encrypted environment variables that app needs. I did everything as this documentation says. When new Git commit has been pushed I'm always getting this error in cloudbuild log:
invalid build: failed to check access to "projects/$PROJECT_ID/locations/global/keyRings/my-key-ring/cryptoKeys/my-key"
Also, there is one more question. If I execute gcloud app deploy command from my laptop app is being deployed and then fails to run because of absent environment variables. Is that correct that I need to define these variables along with command like
> MY_VAR1=a MY_VAR2=b gcloud app deploy
?
And if that's correct why it's not working?

I think the error is that the $PROJECT_ID variable is not supported in the kmsKeyName field. I had the same error and replacing $PROJECT_ID with my literal project-name was the fix.
See https://stackoverflow.com/a/56984975/771768 for a related problem.

Related

Why am I still getting a warning after including app_engine_apis in app.yaml?

I have just deployed an app on Google App Engine using gcloud app deploy and I get a warning such as below:
WARNING: There is a dependency on App Engine APIs, but they are not enabled in your app.yaml. Set the app_engine_apis property.
So what I did was to include app_engine_apis: true in the app.yaml, saved it, and proceed to gcloud app deploy again. However I'm still getting the same warning. What am I missing?
I fixed the warning by running:
google beta app deploy
instead of
google app deploy
I got the fix from this document. I believe it's necessary because at the time of this answer the migration of the python2 app_engine_apis to python3 isn't complete.

Google App Engine - Failed to generate quickstart-web.xml

I have java8 project in Google App Engine . I already deployed one version of it. Now I made some changes and trying to redeploy with same command as before:
mvn package appengine:deploy
But it always fails with message:
Failed to generate quickstart-web.xml
Any idea what to do? I don't know what happened that it suddenly stopped working. Only thing I thought it could be was that I generated indexes for datastore inside Google Shell with .yaml file (java-11 version), so it somehow messed up, but I am not really sure.
The log looks like this
com.google.appengine.tools.admin.AdminException: Unable to stage app: Failed to generate quickstart-web.xml.
at com.google.appengine.tools.admin.AppAdminImpl.stageApplication(AppAdminImpl.java:543)
at com.google.appengine.tools.admin.AppAdminImpl.stageApplicationWithDefaultResourceLimits(AppAdminImpl.java:492)
at com.google.appengine.tools.admin.AppCfg$StagingAction.execute(AppCfg.java:2508)
at com.google.appengine.tools.admin.AppCfg.executeAction(AppCfg.java:363)
at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:211)
at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:118)
at com.google.appengine.tools.admin.AppCfg.main(AppCfg.java:114)
Caused by: java.lang.IllegalStateException: Failed to generate quickstart-web.xml.
at com.google.appengine.tools.admin.Application.createQuickstartWebXml(Application.java:1732)
at com.google.appengine.tools.admin.Application.populateStagingDirectory(Application.java:1002)
at com.google.appengine.tools.admin.Application.createStagingDirectory(Application.java:862)
at com.google.appengine.tools.admin.AppAdminImpl.stageApplication(AppAdminImpl.java:539)
... 6 more
To migrate from Java8 project to Java11 in App Engine Standard, you can follow the next Official Documentation.

Error initializing environment after running "amplify init."

Working on a web app using react.js that I picked up from another developer. Currently, trying to use AWS Amplify and I will eventually use AWS Cognito for authentication purposes.
I am using the following tutorial: https://hackernoon.com/react-authentication-in-depth-4deebda9aa45
I've already executed the following commands:
$ npm i -g #aws-amplify/cli
$ amplify configure
I've set up my CLI with the amplify config command, to include setting up the environment, access key ID and Secret Access key.
Error comes after running
$ amplify init
I've already seen a stack overflow post that states that this is a known error for the CLI, and that a fix has been implemented in the latest version of the CLI. I've tried updating amplify and re-installing. This is my second attempt to reinstall.
Here is a copy of the error in terminal.
MacBook-Air% amplify init
Note: It is recommended to run this command from the root of your app directory
? Do you want to use an existing environment? Yes
? Choose the environment you would like to use: discrete
Using default provider awscloudformation
✖ There was an error initializing your environment.
init failed
{ AccessDenied: Access Denied
at Request.extractError (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/services/s3.js:585:35)
at Request.callListeners (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
message: 'Access Denied',
code: 'AccessDenied',
region: null,
time: 2019-05-01T18:09:17.901Z,
requestId: '7814262360A7DF07',
extendedRequestId:
'Y1woT4qs3VOtSCQG7sWNu7zexB2O+ZNP3oiBugTdfkHbK4Um5vzOS05P5qsZRcRFUPVTAbey8Q0=',
cfId: undefined,
statusCode: 403,
retryable: false,
retryDelay: 155.200421877319 }
Expect environment to properly initialize and amplify to be properly configured.
In my case, I cloned a repo from codecommit and doing amplify init and facing the same problem. To solve this, I rename aws-export.js to aws-export.mjs and again run amplify init and it initialize the project without any error.
You can check those issues reported at github project.
We had a similar issue using '#aws-amplify/cli' is version: '2.0.0', at aws Amplify Console.
Our envs develop, PR, etc. were building fine but master did not.
So, we change the version from 2.0.0 to 4.0.0 and build start working again.
Check
Console broken again (probably related to aws-amplify/cli 2.0.0)
AccessDenied error when deploying backend
It looks like the git repo has already teamproviderinfo.json present or some environment setting checking conflicting with your current setting. So when you try to init the project with environment name 'dev' or the one with the copied repo from git, it is trying to reuse the existing resources.
Solution: Try using a different name for the environment instead of dev and see if that works.
In my case it solved such issue.

Google App Engine: Build Timed Out during Deployment

Edit: Google Cloud at its finest. Made absolutely no changes but deployed fine this morning.
Error after ~10m of deployment (10+ deploy attempts).
I've changed the app to add a simply function with less than 10 lines of code. It has no affect on libraries and uses native python only and hence I'm not sure how it can affect the deployment.
I've tested the app and it runs fine locally.
Here is the error that I get:
ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at
https://console.cloud.google.com/xxxxxxxx/ Failure status: UNKNOWN:
Error Response: [4] DEADLINE_EXCEEDED
Previously to that, logs don't show any errors, in fact everything is going as expected.
Newest entries first:
9302e2430a0e: Pushed
4f56eb74b6bf: Pushed
21df82f90a72: Layer already exists
f0e2b3558b28: Layer already exists
99c71ba2c817: Layer already exists
2483da9621d1: Layer already exists
af09d2110abe: Layer already exists
d968669f4b42: Pushed
4b1e707066a6: Layer already exists
55530b72c8c8: Layer already exists
62c169a7d462: Layer already exists
According to this you can change the build timeout setting with:
gcloud config set app/cloud_build_timeout 1000
Setting it to 1000 seconds in this example.
I have this problem too when deploying my custom image to AppEngine flex. My image requires a few ML models and takes around 2 hours to build and GAE does not seem to like it.
To build your container images outside of Google Cloud Platform, you must first upload your images to a container image repository before you can deploy your images to App Engine with the gcloud app deploy command.
In short, push your image to Google Container Registry or container image repository of your choice, then deploy with this command
gcloud app deploy --image-url gcr.io/YOUR_PROJECT_ID/YOUR_CONTAINER_IMAGE
More info here and here
For my case, I've found out the problem was that I have the same version for all gcloud app deploy command.
When there's traffic, the deployment will timeout.

I can't deploy a Go module to App Engine using the google.golang.org/appengine modules

From the latest material I can read, and also based on documentation on certain APIs (for example, the Go Datastore API), I'm supposed to use google.golang.org/appengine etc. instead of the old appengine/... paths. However, when I try to deploy using gcloud preview app deploy, I get the following error:
Deployment contains files that cannot be compiled: Compile failed:
2016/01/14 14:32:43 go-app-builder: build timing: 2×6g (113ms total), 0×6l (0 total)
2016/01/14 14:32:43 go-app-builder: failed running 6g: exit status 1
server/alexa.go:10: can't find import: "golang.org/x/net/context"
The golang.org/x/net/context package supposedly replaces the old appengine/context one, but it doesn't appear to be available in the deployment server's GOROOT.
I tried including all the dependencies and their dependencies in my package repo but that only lead me to this obscure error (the directory it's complaining about actually exists):
Deployment contains files that cannot be compiled: Compile failed:
2016/01/14 14:27:04 go-app-builder: build timing: 18×6g (1.819s total), 0×6l (0 total)
2016/01/14 14:27:04 go-app-builder: failed running 6g: exit status 1
github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go:27: can't find import: "github.com/golang/protobuf/protoc-gen-go/testdata/multi"
Have I misunderstood the documentation and am only supposed to use the old packages?
You need to do a go get golang.org/x/net/context to save that package in your go src directory. Though, when working with App Engine it is not necessary. Those libraries can be imported and used, but they mostly focused on applications run outside of App Engine, i.e. Container Engine or Compute Engine. They essentially hook into the RESTful APIs Google cooked up for those services. If you decide to work directly with Google Cloud Storage you would need those libraries since App Engine expects you to use Blobstore instead. Hope this helps.
If you are using gosdk, just run goapp get in the same directory as your .go file and it will download and install the dependencies to your gosdk installation. You then deploy the app again and it should compile without problem.
When it's working there's no prompt and files will be downloaded to gosdk\gopath\src
After fininshing there will be a warning message which can be ignored:
go install: no install location for directory
C:\your_current_directory outside GOPATH
For more details see: go help gopath
For the record, this issue is now fixed with gcloud version 142.
One should now be able to deploy using gcloud beta app deploy --project <project> app.yaml. Use gcloud components update to upgrade the command line.
Here is an example project to see it work: https://github.com/aubm/my-test-app
And the Travis build logs: https://travis-ci.org/aubm/my-test-app/builds/198057096

Resources