Skip to content

Defang compose up showing Error: missing configs:"API_KEY" #140

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

Closed
acote88 opened this issue Mar 4, 2024 · 4 comments · Fixed by #516
Closed

Defang compose up showing Error: missing configs:"API_KEY" #140

acote88 opened this issue Mar 4, 2024 · 4 comments · Fixed by #516
Assignees
Labels
customer feedback Feedback from customer good first issue Good for newcomers
Milestone

Comments

@acote88
Copy link
Contributor

acote88 commented Mar 4, 2024

"I don't know is whether that's a Defang api key, an AWS api key, or something else. Why do I need an API key? I'm just following your tutorial. Shouldn't I have been prompted to set one up?"

@acote88 acote88 added the customer feedback Feedback from customer label Mar 4, 2024
@lionello
Copy link
Member

lionello commented Mar 4, 2024

We do show a hint when the compose up fails due to an issue with secrets

@lionello
Copy link
Member

lionello commented Mar 4, 2024

After generate we can detect whether the project was generated with secrets and immediately prompt the user to add the secret? Alternatively we can add to the prompt to not use any secrets, but that severely limits code generation.

@yuta519
Copy link
Contributor

yuta519 commented Mar 5, 2024

@acote88
If it's possible, you can try to generate and run compose up on another directory again.
Although I also faced the same problem at first, I could finally solve the problem by changing the directory where I run the command.

This is the log when I first run the command.

$ defang generate
 * Connecting to fabric-prod1.defang.dev:443
? Please describe the service you'd like to build: Hello World
? What folder would you like to create the service in? service1
 * Working on it. This may take 1 or 2 minutes...
 * Writing files to disk...
   - docker-compose.yml
   - Dockerfile
   - package.json
   - main.js
 * Code generated successfully in folder service1

Check the files in your favorite editor.
To deploy the service, `cd service1` and do:

  defang compose up

A newer version of the CLI is available at https://github.com/defang-io/defang/releases/latest
*
$ defang compose up                                      
 * Connecting to fabric-prod1.defang.dev:443
WARNING ingress port without healthcheck defaults to GET / HTTP/1.1 
WARNING missing memory reservation; specify deploy.resources.reservations.memory to avoid out-of-memory errors 
 * Compressing build context for service1 at /Users/yuta519/work/service1
 * Uploading build context for service1
 * Deploying service service1
Error: failed_precondition: missing secret source:"API_KEY"

To manage service secrets, use:

  defang secret

On the docker-compose.yml which was automatically generated included API_KEY:

version: '3.9'
services:
  service1:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - mode: ingress
        target: 3000
    secrets:
      - API_KEY
secrets:
  API_KEY:
    external: true

When I changed the directory , this yml was different like the below.

version: '3.9'
services:
  service1:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - mode: ingress
        target: 3000
#secrets:
  #API_KEY:
    #external: true

Also, I tried to set a secret, however, I'm not sure yet.

$ defang secret ls 
 * Connecting to fabric-prod1.defang.dev:443
{}
A newer version of the CLI is available at https://github.com/defang-io/defang/releases/latest

$ defang secret set        
 * Connecting to fabric-prod1.defang.dev:443
Error: required flag(s) "name" not set

$ defang secret set API_KEY
Error: unknown command "API_KEY" for "defang secret set"

To manage service secrets, use:

  defang secret

@lionello
Copy link
Member

Need better DX after generating/instantiating a project that requires config. CLI shows defang compose up which results in the error; should show defang config set … instead.

@lionello lionello changed the title Defang compose up showing Error: failed_precondition: missing secret source:"API_KEY" Defang compose up showing Error: missing configs:"API_KEY" Jun 26, 2024
@lionello lionello added the good first issue Good for newcomers label Jun 26, 2024
@lionello lionello added this to the June2024 milestone Jun 26, 2024
@Chrisyhjiang Chrisyhjiang mentioned this issue Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer feedback Feedback from customer good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants