mooyoul / serverless-latest-layer-version

A serverless plugin that replaces 'latest' version tag to actual lambda layer version
MIT License
25 stars 9 forks source link

Does not work #14

Open n3v3rd1e opened 3 years ago

n3v3rd1e commented 3 years ago

Hello, I assume it must be a mistake on my side, as it seems to work for others, but I just really cannot find any. I have serverless @1.74.1, is it maybe not compatible with this plugin?

layers:
      - arn:aws:lambda:eu-west-1:65435731276:layer:google-ads-api:latest
plugins:
  modules:
    - serverless-webpack
    - serverless-latest-layer-version
    - serverless-offline # @note must be last plugin

I'm getting the same error about name constraints as others.

e.g: An error occurred: FLSLSDPersistLsdTestResultsLambdaLambdaFunction - 1 validation error detected: Value '[arn:aws:lambda:ap-southeast-2:xxxxxxxxxxxx:layer:oraclelib:latest]' at 'layers' failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 140, Member must have length greater than or equal to 1, Member must satisfy regular expression pattern: (arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\d{12}:layer:[a-zA-Z0-9-]+:[0-9]+)|(arn:[a-zA-Z0-9-]+:lambda:::awslayer:[a-zA-Z0-9-]+)] (Service: AWSLambdaInternal; Status Code: 400; Error Code: ValidationException; Request ID: 6b295596-80c7-425b-b8f3-7c03673b333c).

Is there anything more to do, than install the plugin and use it the serverless as I did?. Thanks.

holderl5 commented 3 years ago

I am seeing this issue as well. The serverless command shows logs from the plugin:

Serverless: Excluding development dependencies... Serverless: [serverless-latest-layer-version] Detected unknown Layer ARN arn:aws:lambda:eu-west-1:928616498424:layer:dev-my-shared-library:latest. Please create a new issue to github.com/mooyoul/serverless-latest-layer-version Serverless: [serverless-latest-layer-version] Detected unknown Layer ARN arn:aws:lambda:eu-west-1:928616498424:layer:dev-my-shared-library:latest. Please create a new issue to github.com/mooyoul/serverless-latest-layer-version Serverless: Uploading CloudFormation file to S3...

I am using the c-sharp-layer template from serverless guru examples: https://github.com/serverless-guru/templates.git

holderl5 commented 3 years ago

I had some time this morning and decided to play around with this to see if I could determine what is wrong. It seems like the version list coming back empty is the problem, but I am not entirely sure. I tried the edit below and at least I get a different error now and no longer get the warning, but I am not sure. Still looking.

async fetchLatestVersions(layerARNs) { const dict = new Map();

for (const layerARN of layerARNs) {
  const version = await this.lookupLatestLayerVersionArn(layerARN);
        if ( !version ) {
            dict.set(layerARN, 'arn:aws:lambda:eu-west-1:REDACTED:layer:dev-my-shared-library:1');
        }
        else {
            dict.set(layerARN, version);
        }

}

return dict;

}