Amplify-cli: Elasticsearch Creation Fails due to name length

Created on 9 Dec 2018  路  25Comments  路  Source: aws-amplify/amplify-cli

Describe the bug
I get this error when creating the elasticsearch for a GraphQL API with a @searchable directive.

1 validation error detected: Value 'DynamoDBToElasticSearchFunction-p7gynnfosbettdoceeqj43qaii-develop' at 'functionName' failed to satisfy constraint: Member must have length less than or equal to 64 (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: a5bd0b54-fb52-11e8-84ba-4d1bb5abfc41)

To Reproduce
Steps to reproduce the behavior:
i'm not sure what led to this problem.

Expected behavior
Hopefully these names can be checked so that they don't result in this error.

IMHO, DynamoDBToElasticSearchFunction-p7gynnfosbettdoceeqj43qaii is a bit verbose.
DynamoDBToElasticSearchFunction probably isn't necessary - could be shortened, I think.
I'm not sure if p7gynnfosbettdoceeqj43qaii or if it's derived from some other part of the API, but it's a bit long as well.

Thanks for all your help!

investigating

Most helpful comment

Got hit by this today as wel, solved it for now to set a short name (max 5 characters) in ElasticSearchStreamingFunctionName in the parameters.json

@mikeparisstuff how does one make a good PR; of course I can fork the repo; change code and submit a PR, but I mean how do you solve it the right way (like truncate the name if longer then 64, what part is important in the name, etc) and how do I test it in a good manner

All 25 comments

Thanks for reporting this issue, I have recorded it and it will get picked up as soon as possible. The relevant code to update is https://github.com/aws-amplify/amplify-cli/blob/22e987295837c584736453ab7f5b219f240c0b52/packages/graphql-elasticsearch-transformer/src/resources.ts#L134-L140 and I would also be happy to review a PR :). You should be able to customize the name via the parameter as well.

I had this issue before, and I think it starts to occur when using amplify multi-environment cli. You can avoid that by choosing environment name that is less than five characters.

I got the same error and my env name was "master" and it worked when I created an env named "dev"

Got hit by this today as wel, solved it for now to set a short name (max 5 characters) in ElasticSearchStreamingFunctionName in the parameters.json

@mikeparisstuff how does one make a good PR; of course I can fork the repo; change code and submit a PR, but I mean how do you solve it the right way (like truncate the name if longer then 64, what part is important in the name, etc) and how do I test it in a good manner

Setting ElasticSearchStreamingFunctionName in parameters.json does not work for me. Any changes I make to parameters.json are lost. I believe this change is the cause c8fdbff.

@jesse-bonzo @wbroek
what's the version of your cli?

Mine is 0.2.1-multienv.11, which I think is a little behind the mainline.

Could you please try to update to the latest of the multienv? 0.2.1-multienv.15, see if it resolves your issue.

@UnleashedMind 0.2.1-multienv.15 does deploy the stack with no errors, however now the appsync API name is missing the environment name.

Edit: I've tried building again and the environment name is correct now.

@jesse-bonzo Where are you checking for the API name? Did you check the AppSync console or the parameters.json file?

@kaustavghosh06 I'm checking the resulting resources that are created. For instance, the dynamodb tables and the AppSync API name. When I use amplify push on my local machine, the resources are created without the environment name suffix, which is not expected. When I push my changes and build within the Amplify Console, the resources are created with the environment suffix except in this case the Lambda ElasticSearch name is too long and the stack fails to completely build and is rolled back.

@jesse-bonzo I'm taking a look at it right now.

@jesse-bonzo Could you take a look at my response in #631?

I wasn't able to reproduce the issue with the the latest version of the CLI.
Did you by any chance mess around with your parameters.json in the amplify/backend// directory?

@kaustavghosh06
I did originally try adding "ElasticSearchStreamingFunctionName" to parameters.json, but that was being overwritten and lost. So, no I don't think any changes were made to parameters.json, just whatever is generated.

I added npm update -g in my amplify.yml to get the latest version in the amplify console build. I still see the name issue with version 0.2.1-multienv.16.

@jesse-bonzo Does it also fail when you do amplify push using the CLI? I was able to create the API with @searchable using the CLI with an env name of mylongenv.
As for the Amplify console, I'll engage with the team to update the version of CLI they are using on their end. That should mediate the issue with the Amplify console.

@jesse-bonzo Sorry, you're right, the ElasticSearchStreamingLambdaFunction resource creation still fails due to the naming constraints. I'm taking a look at it.

@jesse-bonzo @mwarger We published a new version of the CLI (0.2.1-multienv.17) with a fix for the naming issue (#635)

@jesse-bonzo Also, I've notified the Amplify console team to update the CLI version on their end to avoid build issues. They'll be rolling out the change soon.

@kaustavghosh06 Thanks for your help!

@kaustavghosh06 Thanks! I will update and give this a shot.

@kaustavghosh06 This appears to not be working, and updating the parameters.json file doesn't appear to fix it. Did this not get deployed?

@mwarger There was an issue with the version of the graphql packages published because of which you were seeing this. Please download the latest verision of the CLI (with the multienv tag) - 0.2.19-multienv and let me know if you're still seeing this issue.

@kaustavghosh06
I just pushed to the amplify console and this still failed for the same reason.

1 validation error detected: Value 'DynamoDBToElasticSearchFunction-ofrev3hk2fefjbvyqk2rfb26ri-develop' at 'functionName' failed to satisfy constraint: Member must have length less than or equal to 64 (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: e5d10435-0d17-11e9-a812-d1ad551d6bd2)

My local dev stack was able to be created successfully, even before this latest update.

I am a little concerned that the console is possibly ever running an out-of-date version - would easily lead to confusion like this when I can have an environment working, but then the same thing doesn't work when I push to a remote.

Can the console be updated so I can try again by re-building? Please let me know. Thanks!

@mwarger I鈥檝e communicated this is to the console team to update the CLI on their end. I鈥檒l update this issue after a successful deploymen.

@kaustavghosh06 It appears that the console was updated - that latest deploy worked. Thanks!

Was this page helpful?
0 / 5 - 0 ratings