Different ElasticsearchInstanceType's per environment
** Which Category is your question related to? ** API
** What AWS Services are you utilizing? ** Elasticsearch
** Provide additional details e.g. code snippets ** Maybe I'm missing something, but we want some of our environments (test, staging) to keep the default instance class (t2.small.elasticsearch) while using another for the production environment.
I know you set this in parameters.json with ElasticsearchInstanceType, but how can you accomplish different classes for different environments?
I have not tried this, but from the source code it appears that the team-provider-info.json file in the amplify folder already provides this functionality. Any keys added here should override the parameters.json key supplied. So for your prod environment you would want to merge in: "prod": { "categories":{ "api": { $API_NAME: { "ElasticsearchInstanceType": $INSTANCE_SIZE } } } }
Option 2 in case the above doesn't work:
Add a custom resource inside the api/API_NAME/stacks folder named CustomResources.json. Take in "env" as a parameter, add a conditional block and a IsProd property ("IsProd": {"Fn::Equals" : [{"Ref":"env"}, "production"]} and output the instance type ("ESInstanceType":{"Value": { "Fn::If": ["IsProd","m5.xlarge",t2.small"], "Description":"..."}) based on that condition.
Inside your parameters.json file, you can use "Fn::GetAtt": ["CustomResourcesjson","Outputs.ESInstanceType"] as the value for "ElasticsearchInstanceType"
Thanks @RossWilliams. I think that works for me. I'll give it a shot, but I'll close this and re-open if I hit a wall.
Little late to the party, but anyone coming here - neither of those options work. Option 1 is just ignored and Option 2 fails to compile because CustomResourcesjson is not available
Template error: instance of Fn::GetAtt references undefined resource CustomResourcesjson
I take that back immediately. Option #1 DOES work, but you have to make a change to your API in order for it to deploy. Otherwise the CLI doesn't pickup the change and it is ignored.
I take that back immediately. Option #1 DOES work, but you have to make a change to your API in order for it to deploy. Otherwise the CLI doesn't pickup the change and it is ignored.
@CodySwannGT Can you share a generic example of what you did to "make a change to your API"?
I'm facing the same scenario, but I didn't author the API and am not sure how to proceed with making a change to it.
I take that back immediately. Option #1 DOES work, but you have to make a change to your API in order for it to deploy. Otherwise the CLI doesn't pickup the change and it is ignored.
@CodySwannGT Can you share a generic example of what you did to "make a change to your API"?
I'm facing the same scenario, but I didn't author the API and am not sure how to proceed with making a change to it.
I've figured it out.
A whitespace change (adding a new line to the bottom of a schema file amplify/backend/api/<api name>/schema/<schema file name>) and running amplify push did detect the change and therefor enact the addition of ElasticSearch parameter overrides (in team-provider-info.json) available in the Amplify code-generated CloudFormation template.
ElasticSearch parameter overrides in team-provider-info.json.
"categories": {
"api": {
"api-name-here": {
"ElasticSearchInstanceCount": 2,
"ElasticSearchInstanceType": "c4.large.elasticsearch",
"ElasticSearchEBSVolumeGB": 100
}
},
Amplify seems pleasant for prototyping, but terrible for production - where stable, commonly-understood, non-magic are desirable operational traits.
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.