brefphp / bref

Serverless PHP on AWS Lambda
https://bref.sh
MIT License
3.12k stars 366 forks source link

Invalid configuration encountered: at 'functions.app.image': unsupported string format #1835

Closed Kremzeeq closed 3 months ago

Kremzeeq commented 3 months ago

Description:

With the following configuration in my serverless.yml, I encounter "[!] Invalid configuration encountered at 'functions.app.image': unsupported string format" when I attempt to deloy. The deploy succeeds, but it would be good to have more confidence with regard to this.

serverless.yml extract:

provider:
  name: aws
  ecr:
    images:
      appImage:
        uri: ${param:imageURI}
  region: eu-west-2
  runtimeManagement: auto
  memorySize: 512
  timeout: 10

functions:
  app:
    name: ${param:functionName}
    image: appImage

I'm raising this as a bug, on the basis that the ${param:imageURI} in the provided case is provided and the lambda successfully deploys and works. Here are more details with regard to the deploy:

[!] Invalid configuration encountered
  at 'functions.app.image': unsupported string format

Learn more about configuration validation here: http://slss.io/configuration-validation
Deploying "scraper" to stage "feature" (***)
✔ Pruning of functions complete
✔ Service deployed to stack scraper-feature ([41](https://github.com/Org/repo/actions/runs/9742419787/job/run-id#step:8:42)s)
functions:
  app: scraper-feature 

Related docs are here I think I am providing the image reference correctly according to this. Otherwise, please advise.

How to reproduce:

Serverless version: 4.1.7 With regard to ${param:targetApi1}, this is set to ${{ secrets.aws-account-id }}.dkr.ecr.${{ secrets.aws-region }}.amazonaws.com/${{ vars.APP }}:latest (as an example and the values are populated).

I pass this as a parameter in a GitHub actions workflow e.g. as ...

image_uri="imageURI=${{ steps.docker-push.outputs.imageURI }}"
serverless deploy --stage ${{ vars.ENV }} --param=${image_uri}
mnapoli commented 3 months ago

It should be image: name:, check out the docs here: https://bref.sh/docs/deploy/docker#deployment

Kremzeeq commented 2 months ago

Hi @mnapoli , Maybe I should have been clearer about my use case.

The pattern you've pointed me to is one where you want to reference the path to a Dockerfile and trigger the 'Build the Docker images according to their specified path' as per the link you've shared.

With my use-case, I just want to simply reference the ECR image URI without triggering the 'Invalid configuration warning'. In such a case, the docker image would already have been built and pushed to AWS ECR. I've managed to now achieve this with:

functions:
  your-lambda-name:
    image:
      uri: ${param:imageURI}
mnapoli commented 2 months ago

Ah sorry about the misunderstanding, glad to know it's fixed!