amplify init fails on validation caused [$LATEST] inside 'stackName' value - amazon-web-services

I developing Vue project and have problem with amplify deployment console:
I configured an Amplify project with Cognito Id Pools (Google).
Added an environment 'dev' into the project located on the 'dev' git-branch. Successfully pushed to cloud.
Then using Amplify console created Deployment project based on Github. Checked the environment and branch, and other settings properly. And tried to deploy project
'Provision' stage passed successfully
'Build' failed
After searching info about problem with no result I deleted Amplify from my project locally and on the cloud, using 'amplify delete'. Cleared my git-project from amplify's files and folder. Did all create actions again and got same error:
ValidationError: 1 validation error detected: Value '2019/08/17/[$LATEST]84c0b31765d7431faf5d8f4b51322d03' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]|arn:[-a-zA-Z0-9:/._+]
Value: '2019/08/17/[$LATEST]84c0b31765d7431faf5d8f4b51322d03' is abnormal. And [$LATEST] looks like variable name, that copied directly instead of being interpreted.
I don't know what to do. And what is the reason of problem.

The problem was on version of Amplify module on the cloud is lower than my local version
My local amplify module version is 1.12.0.
Cloud's amplify version is 1.7.2.
After downgraded my local amplify version to 1.11.0 and recreated amplify project it works successfully.

Related

How can I configure Amplify to create a new backend environment for each branch?

I'm trying to configure Amplify to deploy every branch or PR on my Github repo to a new environment.
Using Previews:
Pull Request Previews is enabled
The configuration for the backend is "Create new backend environment for every Pull Request"
But every build skips the backend step with this message "No backend environment association found, continuing..." and because of that the frontend build fails because it requires the aws-exports file that should be generated on the backend stage.
The same occurs with Branch autodetection (With the option Create new backend environment for every connected branch selected)
I'm opening this question here because I couldn't get any answer from AWS on their repo
We were recently facing the same issue and discovered that in order to be able to automatically create new BE environments for Previews or Branch autodetection, you need to add backend build step into Build settings in Amplify (amplify.yml).
It can be found in Amplify documentation and in the most simple form it should look like this:
backend:
phases:
build:
commands:
- amplifyPush --simple
It is not very well documented or obvious, we stumbled across the solution by chance.

Google Cloud Build/App engine error at Syncinc

I'm Attempting to deploy a Flask (python3) App to Google App Engine using Google Cloud Build, but am getting the following error:
failed unmarshalling build config app.yaml: unknown field "runtime"
My app.yaml is as follows:
runtime: python37
resources:
memory_gb: 2.0
The weird things is that I can deploy the service correctly using the CLI, but not using the activators.
I'm currently using Bitbucket and it seems that the activator is ok (webhook is activated as soon as I push a commit to the desired branch, but the mentioned message appears and the build is unsuccessful).
I followed this tutorial: https://cloud.google.com/appengine/docs/standard/python3/building-app/writing-web-service

How do i continue working with Amplify on a new machine?

I'm using react native for my project. On my old machine, when i ran amplify status, i had Auth, Api and Storage services listed.
I moved to my new machine, installed node, watchman, brew etc... and then navigated to my react native project and ran: react-native run-ios, and voila, my app is running. All the calls to my AWS Api, Auth and Storage are working perfectly.
Now i can make some amplify commands. Such as amplify status. I tried: amplify env add: here's what i got:
Users-MBP-2:projectname username$ amplify env add
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: dev
Using default provider awscloudformation
✖ There was an error initializing your environment.
init failed
Error: ENOENT: no such file or directory, open '/Users/username/.aws/credentials'
at Object.openSync (fs.js:462:3)
at Proxy.readFileSync (fs.js:364:35)
at Object.readFileSync (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/util.js:95:26)
at IniLoader.parseFile (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:6:47)
at IniLoader.loadFrom (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:56:30)
at Config.region (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/node_loader.js:100:36)
at Config.set (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/config.js:507:39)
at Config.<anonymous> (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/config.js:342:12)
at Config.each (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/util.js:507:32)
at new Config (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/config.js:341:19) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/Users/username/.aws/credentials'
}
Do you think credentials info needs to be brought/configured to my new machine?
When i run amplify configure project it's like doing an amplify init and building a project from scratch. I'm being asked:
? Enter a name for the project: ProjectName
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using (Use arrow keys)
angular
ember
ionic
react
❯ react-native
vue
none
etc....
I also already have a region, username and accessKey, secretAccess key etc..
I do not want to replace or ruin anything in my current backend or current project! Whats going on?
Ensure amplify-cli is installed and you're logged in with your AWS details.
npm install -g #aws-amplify/cli
amplify configure
Running amplify configure is mainly to give the cli knowledge of your AWS account so subsequent commands can have access to things.
If you get amplify: command not found errors try restarting your terminal. If still no luck, you will need to check amplify has been added to your PATH variable.
Run amplify env add , but choose an existing environment. This will let you choose the environment you created on your other machine so you can pull those settings down to your new machine.
amplify env add
? Do you want to use an existing environment? Yes
Production
Follow up with:
amplify pull
You don't need to run amplify add auth again or anything. All of that will pull down automatically after you've done the above.
You DO NOT need to do all config again, but some for sure
You have to install amplify cli npm install -g #aws-amplify/cli
use amplify pull
https://docs.amplify.aws/cli/start#amplify-pull
Follow the rest of steps -
-- provide the accessKeyId, secretAccessKey
-- region
-- select amplify project
and then rest of app related thing like IDE, directory......
I tried every solution then I found this. (in MacBook)
% sudo -i
Password:
~ root# npm install -g #aws-amplify/cli
-- Ctrl+D to exist from Root user
% amplify pull --appId xxxx --envName yyyy.
Note: To get --appId xxxx --envName yyyy
Log in to the AWS console. Choose AWS Amplify. Click your app. Go to Backend
environments. Find the backend environment you wish to pull. Click
Edit backend. See top right then click 'Local setup instructions
' ( amplify pull --appId
YOUR_APP_ID --envName YOUR_ENV_NAME )
Waiting until it request to verify your amplify.
✔ Successfully received Amplify Studio tokens.
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path: src
? Distribution Directory Path: build
? Build Command: npm run-script build
? Start Command: npm run-script start
✔ Synced UI components.
? Do you plan on modifying this backend? Yes
⠴ Building resource api/xxxx✅ GraphQL schema compiled successfully.
Edit your schema at ....
✔ Successfully pulled backend environment yyyy from the cloud.
✅
Successfully pulled backend environment staging from the cloud.
Run 'amplify pull' to sync future upstream changes.
% amplify pull
% npm install
% npm start
Hope this help every one!!
Happy Coding :)

When trying to deploy to aws-lambda Error: operation not permitted occurs

I am trying to deploy a function to aws that takes screenshot of the given url and tweets it.I am using puppeteer-core, #serverless-chrome/lambda and serverless-plugin-chrome to take screenshot following these articles(but instead of uploading to aws I tweet the image): https://swizec.com/blog/serverless-chrome-on-aws-lambda-the-guide-works-in-2019-beyond/swizec/9024 and https://nadeesha.github.io/headless-chrome-puppeteer-lambda-servelerless/.
It works fine on invoking locally and does everything but when I try to deploy it show an error that 'operation not permitted'. Below is the console log when I try to deploy.
Serverless: Injecting Headless Chrome...
Error --------------------------------------------------
EPERM: operation not permitted, symlink 'C:\Users\xx\yy\zz\node_modules' -> 'C:\Users\xx\yy\zz\.build\node_modules'
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
OS: win32
Node Version: 8.10.0
Serverless Version: 1.45.1
I initially tried using just puppeteer but the package size was too big so I decided to go with this serverless-chrome approach and here is a relevant link but I haven't been able to solve it https://github.com/adieuadieu/serverless-chrome/issues/155
Try removing your .build folder, before deploying.

Travis CI deploy: invalid option "--secret_access_key="

I am building a Java web app with Travis CI and trying to deploy it to an AWS Elastic Beanstalk instance. The build goes well:
The command "mvn test -B" exited with 0.
... but the deploy fails and says:
Fetching: dpl-1.8.31.gem (100%)
Successfully installed dpl-1.8.31
1 gem installed
invalid option "--secret_access_key="
failed to deploy
my .travis.yml file seems to be valid and I have stored in it my encrypted secret access key for AWS using the travis CLI tool:
travis encrypt secret_access_key="< my secret access key >"
So why can't I deploy to AWS? why does Travis tell me invalid option "--secret_access_key="?
I have checked the Travis dpl docs for Elastic Beanstalk and they say the option for the key should be --secret-access-key=..., with dashes (instead of underscores like in invalid option "--secret_access_key=" from my Travis log).
How can I deploy my application?
I also encountered this issue and it was because the encrypted environment variable I used for secret_access_key: was spelled incorrectly. Most likely the value used here is wrong or non-existent and will produce this error.
secret_access_key: $ENCRYPTED_VAR_SPELLED_WRONG