Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This environment is missing some parameter values. [appId,type] do not have values. in PR Preview envs, auto-detected branch envs #12644

Closed
2 tasks done
josefaidt opened this issue May 17, 2023 · 9 comments · Fixed by #12674
Assignees
Labels
bug Something isn't working hosting Issues tied to hosting category p1 platform Issues tied to the general CLI platform

Comments

@josefaidt
Copy link
Contributor

josefaidt commented May 17, 2023

How did you install the Amplify CLI?

pnpm

If applicable, what version of Node.js are you using?

18

Amplify CLI Version

12.0.0

What operating system are you using?

mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

n/a

Describe the bug

After adding hosting to a project with Amplify Hosting and connecting to git, I enabled PR Previews off of the main branch and enabled pattern-based feature branch deployments.

Roughly following the steps in #12640 (comment) led me to the error where the new environment is missing the App ID and "type" parameters for hosting.

In my case, the project has a few resources (to allow Hosting to recognize I have a backend associated with the project)

"categories": {
  "auth": {
    "12640b6261213": {}
  },
  "hosting": {
    "amplifyhosting": {
      "appId": "d33s566qkjqjly",
      "type": "cicd"
    }
  },
  "function": {
    "12640133b89bd": {}
  }
}

sample repo: https://github.com/josefaidt/12640

Expected behavior

preview envs are created without manual intervention

Reproduction steps

  1. amplify init -y
  2. amplify add auth
  3. amplify push -y (so Hosting will recognize I have backend resources when I add hosting)
  4. gh repo create --source . --public
  5. git push...
  6. amplify add hosting > w/ Amplify Hosting / Continuous...
  7. let that build
  8. turn on "Previews", set to create a new env for each PR
  9. checkout a new branch with a name like the one in that issue comment, git checkout -b feature/12640
  10. add a function for good luck, amplify add function
  11. push to new branch and open a PR
  12. observe failure

Project Identifier

eddab42993450b84ffcff526bc832648

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@josefaidt josefaidt added pending-triage Issue is pending triage platform Issues tied to the general CLI platform labels May 17, 2023
@ykethan
Copy link
Member

ykethan commented May 18, 2023

Was able to reproduce the issue, marking as bug.

@ykethan ykethan added bug Something isn't working hosting Issues tied to hosting category and removed pending-triage Issue is pending triage labels May 18, 2023
@josefaidt
Copy link
Contributor Author

I was also able to reproduce a similar issue by using imported auth
image

@aguayma-kipu
Copy link

I experienced this same issue on deployment of a new branch in an existing Amplify project. Following the prompts I ran amplify push and was met with an error of not having access to do the command even though I have all the Administrative rights to do so and my keys are valid.

Here is the output of running the amplify push --debug command to get a little more insight into why this is happening. If there is any updates or suggestions feel free to let me know.


Not pulling components because this project is not Amplify Studio enabled.
✖ There was an error pulling the backend environment develop.

🛑 Access Denied
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

BackendPullFault: Access Denied
at syncCurrentCloudBackend (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/current-cloud-backend-utils.js:52:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/push.js:20:9)
at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:189:9)
at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:135:5)
at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:33:9)
at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:117:5)

Access Denied
AccessDenied: Access Denied
at Request.extractError (/snapshot/repo/build/node_modules/aws-sdk/lib/services/s3.js:711:35)
at Request.callListeners (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
at callNextListener (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
at IncomingMessage.onEnd (/snapshot/repo/build/node_modules/aws-sdk/lib/event_listeners.js:417:13)
at IncomingMessage.emit (node:events:525:35)
at IncomingMessage.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Session Identifier: 85191f25-c21d-4074-ad86-1e08c8b81252

@josefaidt josefaidt linked a pull request May 30, 2023 that will close this issue
6 tasks
@github-actions
Copy link

github-actions bot commented Jun 7, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@ankitv1
Copy link

ankitv1 commented Jul 14, 2023

Hello Team,
I see that that the issue was fixed linked with PR.
I tested this with Amplify CLI Version - 12.2.0-rc.a3b139fb36.0 and observe similar issue

Steps of Reproduction

  1. created sample react project.
  2. amplify init -y
  3. amplify add function (make sure you add environment variables to the function)
  4. initialize git repo and git push
  5. Deploy this master/main branch using CI/CD on Amplify console. The build would be triggered and deployed successfully.
  6. enable pr preview on amplify console with option "Create new backend environment"
  7. On local -> git checkout -b testbranch
  8. make some changes in index.js of lambda function.
  9. Commit and push to git repo
  10. raise PR with main/master branch which is already hosted on amplify
  11. The PR build will create a new backend environment with random name and would get failed with error shown in build logs below -
2023-07-12T06:13:53.961Z [INFO]: # Retrieving environment cache...
2023-07-12T06:13:53.993Z [WARNING]: ! Unable to write cache: {"code":"ERR_BAD_REQUEST","message":"Request failed with status code 404"})}
2023-07-12T06:13:53.993Z [INFO]: ---- Setting Up SSM Secrets ----
2023-07-12T06:13:53.993Z [INFO]: SSM params {"Path":"/amplify/d1d2qz3ywham00/prg/","WithDecryption":true}
2023-07-12T06:14:11.144Z [INFO]: # Patching NPM package '@aws-amplify/cli' from 10.5.2 to 12.2.0-rc.a3b139fb36.0...
2023-07-12T06:14:27.556Z [INFO]: # Done patching NPM package '@aws-amplify/cli' to version 12.2.0-rc.a3b139fb36.0
2023-07-12T06:14:27.641Z [INFO]: # Retrieving cache...
2023-07-12T06:14:27.666Z [INFO]: # Retrieved cache
2023-07-12T06:14:31.785Z [INFO]: ## Starting Backend Build
                                 # Starting phase: build
2023-07-12T06:14:33.654Z [INFO]: �[33mNote: It is recommended to run this command from the root of your app directory�[39m
2023-07-12T06:14:33.958Z [INFO]: �[0mAmplify AppID found: d1d2qz3ywham00. Amplify App name is: reactmultipage�[0m
2023-07-12T06:14:34.012Z [INFO]: �[0mAdding backend environment prg to AWS Amplify app: d1d2qz3ywham00�[0m
2023-07-12T06:14:39.605Z [INFO]: 
2023-07-12T06:14:39.610Z [INFO]: CREATE_IN_PROGRESS amplify-reactmultipage-prg-61433 AWS::CloudFormation::Stack Wed Jul 12 2023 06:14:34 GMT+0000 (Coordinated Universal Time) User Initiated
                                 CREATE_IN_PROGRESS UnauthRole                       AWS::IAM::Role             Wed Jul 12 2023 06:14:37 GMT+0000 (Coordinated Universal Time)
                                 CREATE_IN_PROGRESS AuthRole                         AWS::IAM::Role             Wed Jul 12 2023 06:14:37 GMT+0000 (Coordinated Universal Time)
                                 CREATE_IN_PROGRESS DeploymentBucket                 AWS::S3::Bucket            Wed Jul 12 2023 06:14:37 GMT+0000 (Coordinated Universal Time)
                                 CREATE_IN_PROGRESS UnauthRole                       AWS::IAM::Role             Wed Jul 12 2023 06:14:38 GMT+0000 (Coordinated Universal Time) Resource creation Initiated
                                 CREATE_IN_PROGRESS AuthRole                         AWS::IAM::Role             Wed Jul 12 2023 06:14:38 GMT+0000 (Coordinated Universal Time) Resource creation Initiated
                                 CREATE_IN_PROGRESS DeploymentBucket                 AWS::S3::Bucket            Wed Jul 12 2023 06:14:38 GMT+0000 (Coordinated Universal Time) Resource creation Initiated
2023-07-12T06:14:54.593Z [INFO]: 
2023-07-12T06:14:54.594Z [INFO]: CREATE_COMPLETE UnauthRole AWS::IAM::Role Wed Jul 12 2023 06:14:51 GMT+0000 (Coordinated Universal Time)
                                 CREATE_COMPLETE AuthRole   AWS::IAM::Role Wed Jul 12 2023 06:14:51 GMT+0000 (Coordinated Universal Time)
2023-07-12T06:15:04.660Z [INFO]: �[K
2023-07-12T06:15:04.867Z [INFO]: �[K
2023-07-12T06:15:04.918Z [INFO]: �[1A�[K
2023-07-12T06:15:04.929Z [WARNING]: - Uploading files.
2023-07-12T06:15:04.969Z [INFO]: �[1A
2023-07-12T06:15:04.969Z [INFO]: �[K
2023-07-12T06:15:05.020Z [INFO]: �[1A
2023-07-12T06:15:05.020Z [INFO]: �[K
2023-07-12T06:15:05.084Z [INFO]: �[1A�[K
2023-07-12T06:15:05.135Z [INFO]: �[1A
2023-07-12T06:15:05.136Z [INFO]: �[K
2023-07-12T06:15:05.185Z [INFO]: �[1A�[K
2023-07-12T06:15:05.189Z [INFO]: �[1A
2023-07-12T06:15:05.190Z [INFO]: �[K
2023-07-12T06:15:05.191Z [WARNING]: - Uploading files.
2023-07-12T06:15:05.383Z [WARNING]: - Initializing your environment: prg
2023-07-12T06:15:05.414Z [WARNING]: ✔ Initialized provider successfully.
2023-07-12T06:15:05.469Z [WARNING]: ✖ There was an error initializing your environment.
2023-07-12T06:15:05.469Z [INFO]: 🛑 This environment is missing some parameter values.
2023-07-12T06:15:05.469Z [INFO]: [variable1,variable2] do not have values.
                                 Resolution: Run 'amplify push' interactively to specify values.
                                 Alternatively, manually add values in SSM ParameterStore for the following parameter names:
                                 /amplify/d1d2qz3ywham00/prg/AMPLIFY_function_reactmultipage5cc10a9d_variable1
                                 /amplify/d1d2qz3ywham00/prg/AMPLIFY_function_reactmultipage5cc10a9d_variable2
                                 Learn more at: https://docs.amplify.aws/cli/reference/ssm-parameter-store/#manually-creating-parameters
2023-07-12T06:15:05.478Z [INFO]: 
2023-07-12T06:15:05.479Z [INFO]: Session Identifier: 448cca09-c44d-4a5e-ab29-61f47afa8a5e
2023-07-12T06:15:05.495Z [ERROR]: !!! Build failed
2023-07-12T06:15:05.495Z [ERROR]: !!! Non-Zero Exit Code detected
2023-07-12T06:15:05.496Z [INFO]: # Starting environment caching...
2023-07-12T06:15:05.496Z [INFO]: # Environment caching completed
Terminating logging...

Amplify.yml

version: 1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Another follow-up query as the random name creates confusion in understanding that which PR is related to which branch -

  • How we can specify the name of backend environment which is initialised during build or is there any way using which we know that random name before deployment.
  • Would it be possible if we can replace the random backend environment with the name of git branch from which PR was raised.

@0618 0618 reopened this Jul 14, 2023
@josefaidt
Copy link
Contributor Author

Hey @anivarsh did you also point Amplify Hosting to use this RC version?

@josefaidt
Copy link
Contributor Author

Following the steps above I am encountering a slightly different message:

2023-07-14T21:51:31.513Z [INFO]: 🛑 This environment is missing some function environment variable values.
2023-07-14T21:51:31.514Z [INFO]: Function 126446643a84e is missing values for environment variables: my_var

@josefaidt
Copy link
Contributor Author

Since the original issue has since been resolved, I've filed a separate issue to track the new behavior with function env vars. Closing in favor of tracking #12950

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hosting Issues tied to hosting category p1 platform Issues tied to the general CLI platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants