aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
461 stars 116 forks source link

Error: "This environment is missing some parameter values." when try to host new Backend & FrontEnd application from git repo. #3474

Closed geanque closed 1 year ago

geanque commented 1 year ago

Before opening, please confirm:

App Id

d3hv3dy1ixd07q

AWS Region

us-east-1

Amplify Hosting feature

Environment variables

Describe the bug

Recently I tried to deploy a Backend and FrontEnd application from a git repository and get this error at build phase:

"This environment is missing some parameter values. 2023-05-10T04:59:23.055Z [INFO]: [connectInstanceId,connectInstanceId,connectInstanceId,accountId,accountId,appId,type] do not have values. Resolution: Run 'amplify push' interactively to specify values."

I have the same application, from the same git repo, deployed 41 days ago with no changes in the code or in the config files.

Also I have set the custom environment variables in the portal, but I don't know why it asking for the "appId" and "type" variables from the hosting component created by amplify too:

image

One of the lambdas cloud formation template:

``` { "AWSTemplateFormatVersion": "2010-09-09", "Description": "{\"createdOn\":\"Windows\",\"createdBy\":\"Amplify\",\"createdWith\":\"10.2.3\",\"stackType\":\"function-Lambda\",\"metadata\":{}}", "Parameters": { "CloudWatchRule": { "Type": "String", "Default": "NONE", "Description": " Schedule Expression" }, "deploymentBucketName": { "Type": "String" }, "env": { "Type": "String" }, "s3Key": { "Type": "String" }, "connectInstanceId": { "Default": "0234cea5-721b-4f50-9f95-fb93571368ad", "Type": "String" } }, "Conditions": { "ShouldNotCreateEnvResources": { "Fn::Equals": [ { "Ref": "env" }, "NONE" ] } }, "Resources": { "LambdaFunction": { "Type": "AWS::Lambda::Function", "Metadata": { "aws:asset:path": "./src", "aws:asset:property": "Code" }, "Properties": { "Code": { "S3Bucket": { "Ref": "deploymentBucketName" }, "S3Key": { "Ref": "s3Key" } }, "Handler": "index.handler", "FunctionName": { "Fn::If": [ "ShouldNotCreateEnvResources", "campaignsCallContact", { "Fn::Join": [ "", [ "campaignsCallContact", "-", { "Ref": "env" } ] ] } ] }, "Environment": { "Variables": { "ENV": { "Ref": "env" }, "REGION": { "Ref": "AWS::Region" }, "CONNECT_INSTANCE_ID": { "Ref": "connectInstanceId" } } }, "Role": { "Fn::GetAtt": [ "LambdaExecutionRole", "Arn" ] }, "Runtime": "nodejs14.x", "Layers": [], "Timeout": 25 } }, "LambdaExecutionRole": { "Type": "AWS::IAM::Role", "Properties": { "RoleName": { "Fn::If": [ "ShouldNotCreateEnvResources", "campaignsprojectLambdaRole91aa85f5", { "Fn::Join": [ "", [ "campaignsprojectLambdaRole91aa85f5", "-", { "Ref": "env" } ] ] } ] }, "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "lambda.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ] } } }, "lambdaexecutionpolicy": { "DependsOn": [ "LambdaExecutionRole" ], "Type": "AWS::IAM::Policy", "Properties": { "PolicyName": "lambda-execution-policy", "Roles": [ { "Ref": "LambdaExecutionRole" } ], "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": { "Fn::Sub": [ "arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*", { "region": { "Ref": "AWS::Region" }, "account": { "Ref": "AWS::AccountId" }, "lambda": { "Ref": "LambdaFunction" } } ] } } ] } } }, "AwsConnectLambdaExecutionPolicy": { "Type": "AWS::IAM::Policy", "Properties": { "PolicyName": "awsconnect-lambda-execution-policy", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Action": [ "connect:StartOutboundVoiceContact" ], "Effect": "Allow", "Resource": { "Fn::Sub": [ "arn:aws:connect:${region}:${account}:instance/${connectInstanceId}/contact/*", { "region": { "Ref": "AWS::Region" }, "account": { "Ref": "AWS::AccountId" }, "connectInstanceId": { "Ref": "connectInstanceId" } } ] } } ] }, "Roles": [ { "Ref": "LambdaExecutionRole" } ] }, "DependsOn": "LambdaExecutionRole" } }, "Outputs": { "Name": { "Value": { "Ref": "LambdaFunction" } }, "Arn": { "Value": { "Fn::GetAtt": [ "LambdaFunction", "Arn" ] } }, "Region": { "Value": { "Ref": "AWS::Region" } }, "LambdaExecutionRole": { "Value": { "Ref": "LambdaExecutionRole" } }, "LambdaExecutionRoleArn": { "Value": { "Fn::GetAtt": [ "LambdaExecutionRole", "Arn" ] } } } } ```

Expected behavior

The application has not had any changes, so the deployment from the Amplify portal should continue to work as it did 41 days ago.

Reproduction steps

1- Make a serverless application with lambdas for the backend and environment custom variables within. 2- Try to deploy this application connecting to a git repo from the web portal

Build Settings

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/**/*

Log output

``` # Starting phase: build 2023-05-10T04:59:23.054Z [INFO]: 🛑 This environment is missing some parameter values. 2023-05-10T04:59:23.055Z [INFO]: [connectInstanceId,connectInstanceId,connectInstanceId,accountId,accountId,appId,type] 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/d3hv3dy1ixd07q/master/AMPLIFY_function_campaignsCallContact_connectInstanceId /amplify/d3hv3dy1ixd07q/master/AMPLIFY_function_campaignsConnectGetContactFlows_connectInstanceId /amplify/d3hv3dy1ixd07q/master/AMPLIFY_function_campaignsConnectGetPhones_connectInstanceId /amplify/d3hv3dy1ixd07q/master/AMPLIFY_function_campaignsStopScheduledRule_accountId /amplify/d3hv3dy1ixd07q/master/AMPLIFY_function_campaingsSchedulerService_accountId /amplify/d3hv3dy1ixd07q/master/AMPLIFY_hosting_amplifyhosting_appId /amplify/d3hv3dy1ixd07q/master/AMPLIFY_hosting_amplifyhosting_type Learn more at: https://docs.amplify.aws/cli/reference/ssm-parameter-store/#manually-creating-parameters 2023-05-10T04:59:23.061Z [INFO]: 2023-05-10T04:59:23.061Z [INFO]: Session Identifier: a3eb871e-ce26-4737-a124-2988f2d8db45 2023-05-10T04:59:23.062Z [WARNING]: - Creating Zip 2023-05-10T04:59:23.161Z [INFO]: 2023-05-10T04:59:23.162Z [INFO]: ✅ Report saved: /tmp/campaignsproject/report-1683694763072.zip File at path: '/codebuild/output/src317811072/src/Campaigns/amplify/backend/amplify-meta.json' does not exist 2023-05-10T04:59:23.162Z [WARNING]: - Sending zip 2023-05-10T04:59:23.163Z [WARNING]: ✖ Sending zip 2023-05-10T04:59:23.179Z [ERROR]: !!! Build failed 2023-05-10T04:59:23.180Z [ERROR]: !!! Non-Zero Exit Code detected 2023-05-10T04:59:23.180Z [INFO]: # Starting environment caching... 2023-05-10T04:59:23.180Z [INFO]: # Environment caching completed Terminating logging... ```

Additional information

I don't know what else to do, why it doesn't work anymore. I need to deploy my application to a new customer.

ghost commented 1 year ago

Hi @geanque 👋🏽 Amplify CLI version 11 started using SSM Parameter Store to copy various environment variables defined in the team-provider-info.json file. Any variable not present in that file, Amplify will try to read from SSM. In this case, you can try 2 things to fix this:

  1. run amplify push locally which will update the backend environment accordingly
  2. Manually add the missing environment variable to SSM: https://docs.amplify.aws/cli/reference/ssm-parameter-store/#manually-creating-parameters

Please let us know if these steps resolve the issue for you.

github-actions[bot] commented 1 year ago

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.