Open dhoulker opened 3 years ago
I just started using @searchable and have run into the same issue. To get around the specific case you mention, I created paramters-dev.json, parameters-qa.json, and parameters-prod.json and then as part of the build pipeline I copy over the appropriate file before pushing. It would be nice if the push would allow you to have different settings based on the environment name.
The bigger issue that I am having is that the cloudformation options that are available don't appear to be enough to support a real production environment. The cluster that gets built from amplify has been unreliable even with a very small amount of data and one user. AWS support recommends dedicated master nodes. I may be missing something, but I don't see a way to set parameters like DedicatedMasterCount, DedicatedMasterEnabled, and DedicatedMasterType. I have been hacking the graphql-elasticsearch-transformer/lib/resources.js and graphql-transformer-common/lib/ResourceConstants.js files to get those parameters added to the cloudformation script. I am wondering if I am missing something. Seems like there should be an easier way.
Hi @dhoulker
You can use different values in parameters.json
in different environments as parameters.json
file is specific to one environment. So you can easily set different ES configs in the file and when you switch environment this file also gets changed based on your previous setting just like having 3 files parameters-dev.json, parameters-qa.json, and parameters-prod.json.
@gwasserman4856
For using advanced variables like DedicatedMasterCount
, DedicatedMasterEnabled
, and DedicatedMasterType
, you can set the values of these parameters in parameters.json
file and also set the REF
value in the parameters section of elastic search CFN template. For example:
"ElasticSearchDomain": {
"Type": "AWS::Elasticsearch::Domain",
"Properties": {
"DedicatedMasterCount": {
"Ref": "DedicatedMasterCountValue"
}
},
}
},
Parameters section for CFN
"Parameters": {
... Other variables
"DedicatedMasterCount": {
"Type": "Number",
"Default": 1
},
}
Also set the value in parameters.json
for the DedicatedMasterCountValue```.
For documentation you can check here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html
You may also need to check the pricing for changing parameters :) Let me know if this works for you?
Thanks @akshbhu. I'm finding that elasticsearch can get really pricey, really fast. I was hoping the basic amplify setup would work for dev and qa, but even for a very small amount of data the cluster keeps having issues. Can you expand a little bit more on where the elastic search CFN template is? It looked like it was getting built on the fly which is why I thought I had to modify graphql-elasticsearch-transformer/lib/resources.js. I have that working, but would prefer your more direct method if it is available.
Hi @gwasserman4856 , @akshbhu ,
Thanks both for your responses on this, it's a massive help.
@akshbhu - What you have described sounds perfect, but i don't fully follow what you are suggesting.
The parameters.json
file is managed in git, so if we make a change in develop
then merge into qa
then production
won't all environments end up exactly the same?
I'm most likely missing something :)
If not, i think @gwasserman4856 suggestion would work for us.
Thanks again!
Hi @dhoulker
No. If you make changes to develop env , that parameters.json
file will be specific to develop
env. IF you want to make changes in qa
, you need to do amplify env checkout qa
and now in this environment parameters.json
file will be specific to qa env, you just need to checkout environment . After making changes you need to do amplify push
so that your changes are deployed in their specific environments.
For more details you can check here: https://docs.amplify.aws/cli/teams/commands#environment-cli-commands
@gwasserman4856
You can find the ElasticSearch CFN template in <projectfolder>/amplify/backend/api/build/stacks/<ElasticSeacrhCFN.json>
. Though you are correct this builds every time you change your schema and do ampify api gql-compile
or amplify push
.
In your project make changes in this tempate and parameters.json
file as I mentioned in above comment,and then do an
amplify push
and amplify will detect your local changes changes and deploy them.
Let me know if this answers your question?
Which Category is your question related to?
Amplify @searchable, ElasticSearch sizing in different environments
Amplify CLI Version
Latest
What AWS Services are you utilizing?
Amplify with AppSync using dynamodb and elasticsearch datasources
Provide additional details e.g. code snippets
We are sizing our ElasticSearch instance using
parameters.json
, as described here:https://docs.amplify.aws/cli/graphql-transformer/config-params#elasticsearchinstancetype
We'd like to have different instances sizes for pre-production environments.
Has anyone found a way to manage a different parameters.json file for different environments?
Using the standard workflow we have develop, qa, and production, so whatever we set in develop will end up in production, unless i'm missing something.
Thanks in advance!