Closed ra-external closed 4 years ago
Before you run your app in ‘AWS ECS/Fargate‘ be sure your environmental variables ‘ S3_KEY’, ‘ S3_SECRET’, ‘ S3_REGION’, ‘S3_BUCKET’ and ‘S3_PATH’ are properly defined. Because in most of the services of AWS, enviromental variables which is ‘.env’ in this case, needs to be defined by yourself on AWS console.
Consequently, you can run your app in your localhost without any problem, but if you run the app in AWS ECS/Fargate service you have to define .env (environmental variables) from AWS Console.
EDIT: Detailed information is available in AWS Fargate Documentation
@chtonal --Thanks. All those variables are good in the AWS secrets manager and are being translated correctly to the deployed .env
file
@ra-external AWS Fargate does not load .env file from your app. Only variables that you can use comes from fargate console. In order to make sure your app is configured well, just log those variables, or create a test page to display them. If it is fine, then fine.
@chtonal -- I'm just passing on what the DevOps said -- all the variables are in the 'Secrets Manager' -- I think he's retrieving them from there and on build/deploy writing out a new .env file for the app to read from. In any case, whatever he's doing is working for everything else in the app -- it's all built using Terraform, which is managing this.
I'm just passing on what the DevOps said -- all the variables are in the 'Secrets Manager' -- I think he's retrieving them from there and on build/deploy writing out a new .env file for the app to read from. In any case, whatever he's doing is working for everything else in the app -- it's all built using Terraform, which is managing this.
😁 If you are not able to reach AWS console, the best way is to load those variables from string. Not secure but for your situation it is a must 😀
Just replace S3_ variables in your js file with the .env 😉
EDIT: If your devops give s3 read-write access right for fargate. Ask him for S3_ variables. In some cases you may use different environmental variable name (For S3_KEY => AWS_ACCESS_KEY_ID, for S3_SECRET => AWS_SECRET_ACCESS_KEY)
Hi,
I'm the devops. We passed as env variables S3_KEY and S3_SECRET (and the others). They are stored ins secret manager and passed to the containers in Fargate as ENV Variable during the deployment. As it is working locally do we need to do something more on the Fargate ? Just using the S3_KEY and S3_SECRET should be enough no ? Is there a way to activate some verbose logs to see the call to S3 ?
Much thanks
are you assuming the environment variables as global variable or using something like this few lines before.
const process = require('process');
const { S3_KEY, S3_SECRET, S3_REGION, S3_BUCKET, S3_PATH } = process.env;
it is obvious that you would do that, just making sure this was the case.
@gautamsi As a understand, they have some issue on AWS Services. AWS is completely different subject then keystonejs. They have huge amount of services and AWS Fargate
is one of them. In order to clarify your current state i am going to explain a little about the procedures you have to follow;
These are the procedures you have to follow. In which step you have encountered with the problem?
Hi @chtonal , @gautamsi
thank for your help. i did all the check listed by @chotnal and they were already OK. i finally found the issue.. tricky one..
for S3_PATH we had "/public/images" instead of "public/images". For some reason having "/" at the beginning of the path made the insert in S3 fail..
Removing it solved my issue.
thanks
So, it is time to close this issue. @ra-external
Thanks to all, @chtonal, @gautamsi, @CheikhSambaM! The issue was that we had removed the leading '/' a while ago in the .env (took a while to figure it out), which was why it worked locally, but that hadn't gotten translated to the S3 variables.
We have a KeystoneJS app that is using the S3 File Adapter to upload images to an S3 bucket.
This works fine from the local environment.
However it does not work when the app is hosted in our AWS dev environment. The code is deployed in a container in AWS ECS/Fargate.
My DevOp would like to see more logs about what's going on -- but even when we enable the Keystone logs we don't see anything relevant to the file upload through the file adapter here.